We have pretty silently added a Windows personalization API for Yubikeys and due to the amount of support questions, it seems somewhat appropriate to give a primer on the basics and the programming model.
An initial word of caution: Using the personalization API would overwrite your current configuration data. If you have a key that is configured to work with the Yubico authentication server, this function will no longer work.First of all, where do I get it ?The configuration component and sample code is available as an installable MSI at
http://www.yubico.com/developers/personalization/Why Windows ?The low-level interface to communicate with USB devices differs a lot between operating systems. We made the first reference implementation for Windows and decided to make it available as a COM/ActiveX component.
Why COM/ActiveX ?COM provides a pretty nice encapsulation and allow it to be used in a variety of settings, from simple interfacing to most programming languages to an add-in in an Internet Explorer web page. Although some people could argue that a .net implementation would be more fashionable, interfacing a COM component in a .net environment is straightforward, but a .net assembly in a Win32 setting is pretty useless.
Any plans outside Windows environments ?Absolutely - we've posted a basic LibUSB embryo on Google Code with the hope that someone picks up the ball. If not, we'll give it a shot later on, but we have quite a few things on the agenda so it may take some time. Check it out at
http://code.google.com/p/yubico-usb-win32/ LibUSB is an USB interface encapsulation that should allow pretty painless portability between a variety of OSes, including Win32, MacOS and Linux. Check it out at
http://libusb.wiki.sourceforge.net/Before you tell about the concepts, is there any documentation available ?There is a PDF included in the installer that describes the concepts and the programming model. This one should provide reasonably complete reference to develop an application from scratch.
Yeah, RTFM, RTFM... Tell me the basics and I might read it later...Without going into the specifics on how COM works, the component works by the means of properties that can be set and a few methods that can be invoked. Optionally, events/callbacks can be used to get asyncronous notifications.
Configuring a Yubikey with a 6-byte pubic id, a private id, an AES key and a trailing CR is straightforward. The following pseudo-code illustrates how
ykStaticId = '471158125913'
ykUID = '123456789abc'
ykKey = '277e34c4f584be8b1d1268d2c70af8c'
ykFlagProperty(ykFLAG_APPEND_CR) = TRUE
IF ykProgram = ykOK THEN
Success
ELSE
Failure
ENDIF
What are these flag properties ? What can I do with them ?All binary kind of on-off properties are set with these flags. The following flags can be set:
ykFLAG_TAB_FIRST - Send TAB as first character
ykFLAG_APPEND_TAB1 - Send TAB after first part
ykFLAG_APPEND_TAB2 - Send TAB after second part
ykFLAG_APPEND_DELAY1 - Append a short delay after first part is sent
ykFLAG_APPEND_DELAY2 - Append a short delay after second part is sent
ykFLAG_APPEND_CR - Append a CR after last character
ykFLAG_SEND_REF - Send a reference string first. This sends the entire modhex alphabet as a prefix
ykFLAG_TICKET_FIRST - Send the OTP part first and then the ID part, i.e. swap order of static ID and OTP
ykFLAG_PACING_10MS - Add 10 ms intra-character pacing
ykFLAG_PACING_20MS - Add 20 ms intra-character pacing
ykFLAG_ALLOW_HIDTRIG - Allow trigger by CAPS and NUM (works in Windows environments only)
ykFLAG_STATIC_TICKET - The key will generate static tickets only. Requires firmware 1.3.0 or later
Can I change a single property on an already configured key without changing what's already there ?No - all properties are updated at ykProgram
Do I need to restore all properties after an ykProgram to a known value ?All properties are preserved until changed. Invoking the ykClear method resets all properties to null / FALSE values.
Any examples included ?There are sample code examples included for Visual C++, Visual Basic and ActiveX component usage in a HTML page
What prevents anyone from using this component to sabotage or hijack my issued keys ?You can set a 6-byte configuration key using the ykNewPWD property. If set, the ykCurPWD needs to be set prior to any programming operation. The default is that this feature is disabled
I programmed a key and now it is just flashing every three seconds or so. What's wrong ?This means that the key has been set to unconfigured mode, i.e. the factory default state where no valid configuration is present. Calling ykProgram without setting any property to any value causes this to happen.
What about the callbacks/events you mentioned ?If desired, the component can generate an asychronous event when a device is inserted or removed. This can be useful to avoid having the application to poll for a device insert. In an automated setting, the ykInserted event notification can be used to automatically trigger a program operation. The ykRemoved notification can then be used to restore the state machine to a waiting-for-key-insert state.
What is the ykEnableDebug property ?It is a feature for testing that the calling code does what you expect it to do. As each property or method is invoked, a debug message box is displayed with arguments if applicable.
Just a few starting topics... Please post your further questions as they come up.
Finally and maybe stated ad nauseam:
Remember that using the configuration API will overwrite your current configuration. Evaluation keys configured to work with the Yubico authentication server will no longer work there if the configuration is changed !Regards,
JakobE
Hardware- and firmware guy @ Yubico