User's Manual

57
0x57, 0x4b, 0x21, 0x94, 0x82, 0x38, 0x68, 0xf8, 0xf8, 0x54, 0x38, 0xa1, 0x6d,
0x05, 0x70, 0x39,
};
int main() {
SKEY_DATA key;
printf("SmartKey AES example\n");
memset(&key, 0, sizeof(key));
strncpy(key.label, "SMARTKEY", LABEL_LENGTH);
key.command = LOCATING_MODE;
msclink(&key);
if (key.status != 0) {
MessageBox(NULL, "SmartKey not found", "Error", MB_ICONERROR |
MB_SYSTEMMODAL);
exit(1);
}
key.command = EXT_MODEL_READING_MODE;
msclink(&key);
if (key.status != 0) {
MessageBox(NULL, "SmartKey not found", "Error", MB_ICONERROR |
MB_SYSTEMMODAL);
exit(1);
}
if ((key.data[3] & 0x1) == 0) {
MessageBox(NULL, "This SmartKey model doesn't support AES commands",
"Error", MB_ICONERROR | MB_SYSTEMMODAL);
exit(1);
}
if (MessageBox(NULL, "Set the AES keys ? The operation cannot be undone
!", "Warning", MB_YESNO | MB_ICONWARNING | MB_SYSTEMMODAL) != IDYES) {
exit(1);
}
memcpy(key.ext_data, serial, 16);
memcpy(key.ext_data + 16, aeskey, 16*20);
key.command = AES_SET_MODE;
msclink(&key);
if (key.status != 0) {
MessageBox(NULL, "Error setting the AES keys and serial.\n\rPlease
note that you can set them ONLY ONE TIME!", "Error", MB_ICONERROR |
MB_SYSTEMMODAL);
exit(1);
}
MessageBox(NULL, "AES keys setup correctly", "Information",
MB_ICONINFORMATION | MB_SYSTEMMODAL);
return 0;
}
Usekey
This example uses the AES keys.
#include "skeydrv.h"
#include "aes.h"
#include <stdlib.h>