Index: pykcs11/trunk/samples/LowLevel/InitTokenPin.py =================================================================== --- pykcs11/trunk/samples/LowLevel/InitTokenPin.py (revision 48) +++ pykcs11/trunk/samples/LowLevel/InitTokenPin.py (revision 186) @@ -51,5 +51,5 @@ print "\t\tTokenInfo: flags=" + hex(tokenInfo.flags) + ", Model=" + tokenInfo.GetModel() - print "\tC_OpenSession(): " + hex(a.C_OpenSession(slotList[0], PyKCS11.LowLevel.CKF_SERIAL_SESSION|PyKCS11.LowLevel.CKF_RW_SESSION, session)) + print "\tC_OpenSession(): " + hex(a.C_OpenSession(slotList[0], PyKCS11.LowLevel.CKF_SERIAL_SESSION | PyKCS11.LowLevel.CKF_RW_SESSION, session)) print "\t\tSession:" + str(session) print "\tC_GetSessionInfo(): " + hex(a.C_GetSessionInfo(session, sessionInfo)) @@ -70,3 +70,2 @@ print "C_Finalize(): " + hex(a.C_Finalize()) print a.Unload() - Index: pykcs11/trunk/samples/LowLevel/test.py =================================================================== --- pykcs11/trunk/samples/LowLevel/test.py (revision 92) +++ pykcs11/trunk/samples/LowLevel/test.py (revision 186) @@ -40,5 +40,5 @@ print "\tC_SlotInfo(): " + hex(a.C_GetSlotInfo(slotList[x], slotInfo)) print "\t\tSlot N." + str(x) + ": ID=" + str(slotList[x]) + ", name='" + slotInfo.GetSlotDescription() + "'" - print "\tC_OpenSession(): " + hex(a.C_OpenSession(slotList[x], PyKCS11.LowLevel.CKF_SERIAL_SESSION|PyKCS11.LowLevel.CKF_RW_SESSION, session)) + print "\tC_OpenSession(): " + hex(a.C_OpenSession(slotList[x], PyKCS11.LowLevel.CKF_SERIAL_SESSION | PyKCS11.LowLevel.CKF_RW_SESSION, session)) print "\t\tSession:" + str(session) print "\tC_GetSessionInfo(): " + hex(a.C_GetSessionInfo(session, sessionInfo)) @@ -48,5 +48,5 @@ print "\t\tTokenInfo: Label=" + tokenInfo.GetLabel() + ", ManufacturerID=" + tokenInfo.GetManufacturerID() print "\t\tTokenInfo: flags=" + hex(tokenInfo.flags) + ", Model=" + tokenInfo.GetModel() - + print "\tC_Login(): " + hex(a.C_Login(session, PyKCS11.LowLevel.CKU_USER, pin)) print "\tC_Logout(): " + hex(a.C_Logout(session)) @@ -61,7 +61,7 @@ SearchTemplate[1].SetBool(PyKCS11.LowLevel.CKA_TOKEN, True) -print "C_FindObjectsInit: " + hex(a.C_FindObjectsInit(session, SearchTemplate)) -print "C_FindObjects: " + hex(a.C_FindObjects(session, SearchResult)) -print "C_FindObjectsFinal: " + hex(a.C_FindObjectsFinal(session)) +print "C_FindObjectsInit: " + hex(a.C_FindObjectsInit(session, SearchTemplate)) +print "C_FindObjects: " + hex(a.C_FindObjects(session, SearchResult)) +print "C_FindObjectsFinal: " + hex(a.C_FindObjectsFinal(session)) for x in SearchResult: @@ -73,12 +73,11 @@ #valTemplate[1].Reserve(4) print "C_GetAttributeValue(): " + hex(a.C_GetAttributeValue(session, x, valTemplate)) - print "CKA_LABEL Len: ", valTemplate[0].GetLen(), " CKA_CLASS Len: ",valTemplate[1].GetLen() - print "C_GetAttributeValue(): " + hex(a.C_GetAttributeValue(session, x, valTemplate)) + print "CKA_LABEL Len: ", valTemplate[0].GetLen(), " CKA_CLASS Len: ", valTemplate[1].GetLen() + print "C_GetAttributeValue(): " + hex(a.C_GetAttributeValue(session, x, valTemplate)) print "\tCKO_CERTIFICATE: " + valTemplate[0].GetString() print "\tCKA_TOKEN: " + str(valTemplate[1].GetNum()) - + print "C_Logout(): " + hex(a.C_Logout(session)) print "C_CloseSession(): " + hex(a.C_CloseSession(session)) print "C_Finalize(): " + hex(a.C_Finalize()) print a.Unload() - Index: pykcs11/trunk/samples/LowLevel/test1.py =================================================================== --- pykcs11/trunk/samples/LowLevel/test1.py (revision 92) +++ pykcs11/trunk/samples/LowLevel/test1.py (revision 186) @@ -40,5 +40,5 @@ print "\tC_SlotInfo(): " + hex(a.C_GetSlotInfo(slotList[x], slotInfo)) print "\t\tSlot N." + str(x) + ": ID=" + str(slotList[x]) + ", name='" + slotInfo.GetSlotDescription() + "'" - print "\tC_OpenSession(): " + hex(a.C_OpenSession(slotList[x], PyKCS11.LowLevel.CKF_SERIAL_SESSION|PyKCS11.LowLevel.CKF_RW_SESSION, session)) + print "\tC_OpenSession(): " + hex(a.C_OpenSession(slotList[x], PyKCS11.LowLevel.CKF_SERIAL_SESSION | PyKCS11.LowLevel.CKF_RW_SESSION, session)) print "\t\tSession:" + str(session) print "\tC_GetSessionInfo(): " + hex(a.C_GetSessionInfo(session, sessionInfo)) @@ -48,10 +48,10 @@ print "\t\tTokenInfo: Label=" + tokenInfo.GetLabel() + ", ManufacturerID=" + tokenInfo.GetManufacturerID() print "\t\tTokenInfo: flags=" + hex(tokenInfo.flags) + ", Model=" + tokenInfo.GetModel() - + print "\tC_Login(): " + hex(a.C_Login(session, PyKCS11.LowLevel.CKU_USER, pin)) print "\tC_Logout(): " + hex(a.C_Logout(session)) print "\tC_CloseSession(): " + hex(a.C_CloseSession(session)) -print "C_OpenSession(): " + hex(a.C_OpenSession(slotList[0], PyKCS11.LowLevel.CKF_RW_SESSION|PyKCS11.LowLevel.CKF_SERIAL_SESSION, session)) +print "C_OpenSession(): " + hex(a.C_OpenSession(slotList[0], PyKCS11.LowLevel.CKF_RW_SESSION | PyKCS11.LowLevel.CKF_SERIAL_SESSION, session)) print "C_Login(): " + hex(a.C_Login(session, PyKCS11.LowLevel.CKU_USER, pin)) @@ -61,7 +61,7 @@ SearchTemplate[1].SetBool(PyKCS11.LowLevel.CKA_TOKEN, True) -print "C_FindObjectsInit: " + hex(a.C_FindObjectsInit(session, SearchTemplate)) -print "C_FindObjects: " + hex(a.C_FindObjects(session, SearchResult)) -print "C_FindObjectsFinal: " + hex(a.C_FindObjectsFinal(session)) +print "C_FindObjectsInit: " + hex(a.C_FindObjectsInit(session, SearchTemplate)) +print "C_FindObjects: " + hex(a.C_FindObjects(session, SearchResult)) +print "C_FindObjectsFinal: " + hex(a.C_FindObjectsFinal(session)) for x in SearchResult: @@ -75,15 +75,14 @@ binval = list(valTemplate[0].GetBin()) print "binval=", binval - binval[0] = 0; + binval[0] = 0 valTemplate[0].SetBin(PyKCS11.LowLevel.CKA_ISSUER, binval) binval = valTemplate[0].GetBin() # list(valTemplate[0].GetBin()) print "binval[0]=", binval[0] - binval[0] = 0; - + binval[0] = 0 + print "C_SetAttributeValue(): " + hex(a.C_SetAttributeValue(session, x, valTemplate)) - + print "C_Logout(): " + hex(a.C_Logout(session)) print "C_CloseSession(): " + hex(a.C_CloseSession(session)) print "C_Finalize(): " + hex(a.C_Finalize()) print a.Unload() - Index: pykcs11/trunk/samples/LowLevel/dumpit.py =================================================================== --- pykcs11/trunk/samples/LowLevel/dumpit.py (revision 92) +++ pykcs11/trunk/samples/LowLevel/dumpit.py (revision 186) @@ -41,5 +41,5 @@ print "\tC_SlotInfo(): " + hex(a.C_GetSlotInfo(slotList[x], slotInfo)) print "\t\tSlot N." + str(x) + ": ID=" + str(slotList[x]) + ", name='" + slotInfo.GetSlotDescription() + "'" - print "\tC_OpenSession(): " + hex(a.C_OpenSession(slotList[x], CKF_SERIAL_SESSION|CKF_RW_SESSION, session)) + print "\tC_OpenSession(): " + hex(a.C_OpenSession(slotList[x], CKF_SERIAL_SESSION | CKF_RW_SESSION, session)) print "\t\tSession:" + str(session) print "\tC_GetSessionInfo(): " + hex(a.C_GetSessionInfo(session, sessionInfo)) @@ -49,5 +49,5 @@ print "\t\tTokenInfo: Label=" + tokenInfo.GetLabel() + ", ManufacturerID=" + tokenInfo.GetManufacturerID() print "\t\tTokenInfo: flags=" + hex(tokenInfo.flags) + ", Model=" + tokenInfo.GetModel() - + print "\tC_Login(): " + hex(a.C_Login(session, CKU_USER, pin)) print "\tC_Logout(): " + hex(a.C_Logout(session)) @@ -62,81 +62,80 @@ #SearchTemplate[1].SetBool(CKA_TOKEN, True) -print "C_FindObjectsInit: " + hex(a.C_FindObjectsInit(session, SearchTemplate)) -print "C_FindObjects: " + hex(a.C_FindObjects(session, SearchResult)) -print "C_FindObjectsFinal: " + hex(a.C_FindObjectsFinal(session)) +print "C_FindObjectsInit: " + hex(a.C_FindObjectsInit(session, SearchTemplate)) +print "C_FindObjects: " + hex(a.C_FindObjects(session, SearchResult)) +print "C_FindObjectsFinal: " + hex(a.C_FindObjectsFinal(session)) attributes = [ - ["CKA_CLASS", CKA_CLASS], - ["CKA_TOKEN", CKA_TOKEN], - ["CKA_PRIVATE", CKA_PRIVATE], - ["CKA_LABEL", CKA_LABEL], - ["CKA_APPLICATION", CKA_APPLICATION], - ["CKA_VALUE", CKA_VALUE], - ["CKA_CERTIFICATE_TYPE", CKA_CERTIFICATE_TYPE], - ["CKA_ISSUER", CKA_ISSUER], - ["CKA_SERIAL_NUMBER", CKA_SERIAL_NUMBER], - ["CKA_KEY_TYPE", CKA_KEY_TYPE], - ["CKA_SUBJECT", CKA_SUBJECT], - ["CKA_ID", CKA_ID], - ["CKA_SENSITIVE", CKA_SENSITIVE], - ["CKA_ENCRYPT", CKA_ENCRYPT], - ["CKA_DECRYPT", CKA_DECRYPT], - ["CKA_WRAP", CKA_WRAP], - ["CKA_UNWRAP", CKA_UNWRAP], - ["CKA_SIGN", CKA_SIGN], - ["CKA_SIGN_RECOVER", CKA_SIGN_RECOVER], - ["CKA_VERIFY", CKA_VERIFY], - ["CKA_VERIFY_RECOVER", CKA_VERIFY_RECOVER], - ["CKA_DERIVE", CKA_DERIVE], - ["CKA_START_DATE", CKA_START_DATE], - ["CKA_END_DATE", CKA_END_DATE], - ["CKA_MODULUS", CKA_MODULUS], - ["CKA_MODULUS_BITS", CKA_MODULUS_BITS], - ["CKA_PUBLIC_EXPONENT", CKA_PUBLIC_EXPONENT], - ["CKA_PRIVATE_EXPONENT", CKA_PRIVATE_EXPONENT], - ["CKA_PRIME_1", CKA_PRIME_1], - ["CKA_PRIME_2", CKA_PRIME_2], - ["CKA_EXPONENT_1", CKA_EXPONENT_1], - ["CKA_EXPONENT_2", CKA_EXPONENT_2], - ["CKA_COEFFICIENT", CKA_COEFFICIENT], - ["CKA_PRIME", CKA_PRIME], - ["CKA_SUBPRIME", CKA_SUBPRIME], - ["CKA_BASE", CKA_BASE], - ["CKA_VALUE_BITS", CKA_VALUE_BITS], - ["CKA_VALUE_LEN", CKA_VALUE_LEN], - ["CKA_EXTRACTABLE", CKA_EXTRACTABLE], - ["CKA_LOCAL", CKA_LOCAL], - ["CKA_NEVER_EXTRACTABLE", CKA_NEVER_EXTRACTABLE], - ["CKA_ALWAYS_SENSITIVE", CKA_ALWAYS_SENSITIVE], - ["CKA_MODIFIABLE", CKA_MODIFIABLE], - ["CKA_ECDSA_PARAMS", CKA_ECDSA_PARAMS], - ["CKA_EC_POINT", CKA_EC_POINT], - ] + ["CKA_CLASS", CKA_CLASS], + ["CKA_TOKEN", CKA_TOKEN], + ["CKA_PRIVATE", CKA_PRIVATE], + ["CKA_LABEL", CKA_LABEL], + ["CKA_APPLICATION", CKA_APPLICATION], + ["CKA_VALUE", CKA_VALUE], + ["CKA_CERTIFICATE_TYPE", CKA_CERTIFICATE_TYPE], + ["CKA_ISSUER", CKA_ISSUER], + ["CKA_SERIAL_NUMBER", CKA_SERIAL_NUMBER], + ["CKA_KEY_TYPE", CKA_KEY_TYPE], + ["CKA_SUBJECT", CKA_SUBJECT], + ["CKA_ID", CKA_ID], + ["CKA_SENSITIVE", CKA_SENSITIVE], + ["CKA_ENCRYPT", CKA_ENCRYPT], + ["CKA_DECRYPT", CKA_DECRYPT], + ["CKA_WRAP", CKA_WRAP], + ["CKA_UNWRAP", CKA_UNWRAP], + ["CKA_SIGN", CKA_SIGN], + ["CKA_SIGN_RECOVER", CKA_SIGN_RECOVER], + ["CKA_VERIFY", CKA_VERIFY], + ["CKA_VERIFY_RECOVER", CKA_VERIFY_RECOVER], + ["CKA_DERIVE", CKA_DERIVE], + ["CKA_START_DATE", CKA_START_DATE], + ["CKA_END_DATE", CKA_END_DATE], + ["CKA_MODULUS", CKA_MODULUS], + ["CKA_MODULUS_BITS", CKA_MODULUS_BITS], + ["CKA_PUBLIC_EXPONENT", CKA_PUBLIC_EXPONENT], + ["CKA_PRIVATE_EXPONENT", CKA_PRIVATE_EXPONENT], + ["CKA_PRIME_1", CKA_PRIME_1], + ["CKA_PRIME_2", CKA_PRIME_2], + ["CKA_EXPONENT_1", CKA_EXPONENT_1], + ["CKA_EXPONENT_2", CKA_EXPONENT_2], + ["CKA_COEFFICIENT", CKA_COEFFICIENT], + ["CKA_PRIME", CKA_PRIME], + ["CKA_SUBPRIME", CKA_SUBPRIME], + ["CKA_BASE", CKA_BASE], + ["CKA_VALUE_BITS", CKA_VALUE_BITS], + ["CKA_VALUE_LEN", CKA_VALUE_LEN], + ["CKA_EXTRACTABLE", CKA_EXTRACTABLE], + ["CKA_LOCAL", CKA_LOCAL], + ["CKA_NEVER_EXTRACTABLE", CKA_NEVER_EXTRACTABLE], + ["CKA_ALWAYS_SENSITIVE", CKA_ALWAYS_SENSITIVE], + ["CKA_MODIFIABLE", CKA_MODIFIABLE], + ["CKA_ECDSA_PARAMS", CKA_ECDSA_PARAMS], + ["CKA_EC_POINT", CKA_EC_POINT], + ] for x in SearchResult: - print "object: " + hex(x.value()) - valTemplate = ckattrlist(1) - for attr in attributes: - valTemplate[0].Reset() - valTemplate[0].SetType(attr[1]) - # first call to get the attribute size and reserve the memory - a.C_GetAttributeValue(session, x, valTemplate) - # second call to get the attribute value - rv = a.C_GetAttributeValue(session, x, valTemplate) - if (rv == CKR_OK): - print "\t" + attr[0] + ": ", - if (valTemplate[0].IsNum()): - print valTemplate[0].GetNum() - if (valTemplate[0].IsBool()): - print valTemplate[0].GetBool() - if (valTemplate[0].IsString()): - print valTemplate[0].GetString() - if (valTemplate[0].IsBin()): - print "(" + str(valTemplate[0].GetLen()) + " bytes)", - print map(hex, valTemplate[0].GetBin()) - + print "object: " + hex(x.value()) + valTemplate = ckattrlist(1) + for attr in attributes: + valTemplate[0].Reset() + valTemplate[0].SetType(attr[1]) + # first call to get the attribute size and reserve the memory + a.C_GetAttributeValue(session, x, valTemplate) + # second call to get the attribute value + rv = a.C_GetAttributeValue(session, x, valTemplate) + if (rv == CKR_OK): + print "\t" + attr[0] + ": ", + if (valTemplate[0].IsNum()): + print valTemplate[0].GetNum() + if (valTemplate[0].IsBool()): + print valTemplate[0].GetBool() + if (valTemplate[0].IsString()): + print valTemplate[0].GetString() + if (valTemplate[0].IsBin()): + print "(" + str(valTemplate[0].GetLen()) + " bytes)", + print map(hex, valTemplate[0].GetBin()) + print "C_Logout(): " + hex(a.C_Logout(session)) print "C_CloseSession(): " + hex(a.C_CloseSession(session)) print "C_Finalize(): " + hex(a.C_Finalize()) print a.Unload() -