== API

To learn about the API, either download an official release tar.gz file and look in doc/html/ (more details in doc/README file), or install pyhsm and start reading the pydoc documentation.


== Installation

=== Quick Ubuntu guide :

 $ sudo add-apt-repository ppa:yubico/stable
 $ sudo apt-get update
 $ sudo apt-get install python-pyhsm
 $ pydoc pyhsm
 $ pydoc pyhsm.base

=== Windows

python-pyhsm has been tested on Windows with Python 2.6 (2.7 will probably also work) from http://www.python.org/.

You need to install pySerial (tested with pyserial-2.5.win32.exe) from http://pypi.python.org/pypi/pyserial.

When you first insert the YubiHSM in your computer, Windows will indicate it cannot install the hardware. Download the .INF file from http://www.yubico.com/yubihsm/ and select that in the Windows dialog.

Now, you should be able to communicate with the YubiHSM from Python like this (for this simple test, I put a copy of the pyhsm source tree in Z:\tmp\pyhsm) :

 Z:\tmp\pyhsm>c:\Python26\python.exe
 Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)] on win32
 Type "help", "copyright", "credits" or "license" for more information.
 >>> import sys
 >>> sys.path.append("Z:\\tmp\\pyhsm\\Lib")
 >>> import pyhsm
 >>> hsm = pyhsm.YHSM(device = "COM3")
 >>> hsm.info()
 <YHSM_Cmd_System_Info instance at 0x191a148: ver=(0, 9, 8), proto=1, ...>
 >>>

Here is how to for example get five bytes of random binary data from the YubiHSM :

 >>> hsm.random(5)
 '\x9c\x0fu\xcfP'
 >>> hsm.random(5).encode("hex")
 'b562456719'
 >>>
