security/nss/cmd/pk11util/scripts/hssign

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/security/nss/cmd/pk11util/scripts/hssign	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,48 @@
     1.4 +Load aolkeypk11.dll
     1.5 +C_Initialize NULL
     1.6 +C_GetSlotList false NULL slotCount
     1.7 +NewArray slotList CK_ULONG slotCount
     1.8 +C_GetSlotList false slotList slotCount
     1.9 +#change the following to the appropriate slot id
    1.10 +#set slotID slotList[0]
    1.11 +set slotID 1
    1.12 +C_GetSlotInfo slotID slotInfo
    1.13 +C_GetTokenInfo slotID tokenInfo
    1.14 +C_OpenSession slotID CK_SESSION_SERIAL session
    1.15 +#
    1.16 +#uncomment the following line and include the correct password
    1.17 +#for authenticated tokens
    1.18 +#C_Login session CKU_USER 0000 4
    1.19 +#
    1.20 +# build the search template
    1.21 +#
    1.22 +#NewTemplate search CKA_CLASS
    1.23 +#SetTemplate search 0 CKO_CERTIFICATE
    1.24 +#NewArray certID CK_ULONG 1
    1.25 +#C_FindObjectsInit session search 1
    1.26 +#C_FindObjects session certID 1 count
    1.27 +#C_FindObjectsFinal session
    1.28 +#
    1.29 +# now read the cert out
    1.30 +#
    1.31 +#NewTemplate derCert CKA_VALUE
    1.32 +#C_GetAttributeValue session certID derCert 1
    1.33 +#BuildTemplate derCert
    1.34 +#C_GetAttributeValue session certID derCert 1
    1.35 +#
    1.36 +# Do a signature
    1.37 +#
    1.38 +NewTemplate search CKA_CLASS
    1.39 +SetTemplate search 0 CKO_PRIVATE_KEY
    1.40 +NewArray privateKey CK_ULONG 1
    1.41 +C_FindObjectsInit session search 1
    1.42 +C_FindObjects session privateKey 1 count
    1.43 +C_FindObjectsFinal session
    1.44 +# sign
    1.45 +NewMechanism rsaParams CKM_RSA_PKCS
    1.46 +NewArray sign data 128
    1.47 +NewArray sdata data 20
    1.48 +C_SignInit session rsaParams privateKey
    1.49 +C_Sign session sdata sizeof(sdata) sign sizeof(sign)
    1.50 +#C_Logout session
    1.51 +

mercurial