hssign (1294B)
1 Load aolkeypk11.dll 2 C_Initialize NULL 3 C_GetSlotList false NULL slotCount 4 NewArray slotList CK_ULONG slotCount 5 C_GetSlotList false slotList slotCount 6 #change the following to the appropriate slot id 7 #set slotID slotList[0] 8 set slotID 1 9 C_GetSlotInfo slotID slotInfo 10 C_GetTokenInfo slotID tokenInfo 11 C_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 # 35 NewTemplate search CKA_CLASS 36 SetTemplate search 0 CKO_PRIVATE_KEY 37 NewArray privateKey CK_ULONG 1 38 C_FindObjectsInit session search 1 39 C_FindObjects session privateKey 1 count 40 C_FindObjectsFinal session 41 # sign 42 NewMechanism rsaParams CKM_RSA_PKCS 43 NewArray sign data 128 44 NewArray sdata data 20 45 C_SignInit session rsaParams privateKey 46 C_Sign session sdata sizeof(sdata) sign sizeof(sign) 47 #C_Logout session 48