1Load aolkeypk11.dll
2C_Initialize NULL
3C_GetSlotList false NULL slotCount
4NewArray slotList CK_ULONG slotCount
5C_GetSlotList false slotList slotCount
6#change the following to the appropriate slot id
7#set slotID slotList[0]
8set slotID 1
9C_GetSlotInfo slotID slotInfo
10C_GetTokenInfo slotID tokenInfo
11C_OpenSession slotID CK_SESSION_SERIAL session
12#
13#uncomment the following line and include the correct password
14#for authenticated tokens
15#C_Login session CKU_USER 0000 4
16#
17# build the search template
18#
19#NewTemplate search CKA_CLASS
20#SetTemplate search 0 CKO_CERTIFICATE
21#NewArray certID CK_ULONG 1
22#C_FindObjectsInit session search 1
23#C_FindObjects session certID 1 count
24#C_FindObjectsFinal session
25#
26# now read the cert out
27#
28#NewTemplate derCert CKA_VALUE
29#C_GetAttributeValue session certID derCert 1
30#BuildTemplate derCert
31#C_GetAttributeValue session certID derCert 1
32#
33# Do a signature
34#
35NewTemplate search CKA_CLASS
36SetTemplate search 0 CKO_PRIVATE_KEY
37NewArray privateKey CK_ULONG 1
38C_FindObjectsInit session search 1
39C_FindObjects session privateKey 1 count
40C_FindObjectsFinal session
41# sign
42NewMechanism rsaParams CKM_RSA_PKCS
43NewArray sign data 128
44NewArray sdata data 20
45C_SignInit session rsaParams privateKey
46C_Sign session sdata sizeof(sdata) sign sizeof(sign)
47#C_Logout session
48
49