Changeset 186 for pykcs11

Show
Ignore:
Timestamp:
02/21/10 15:34:58 (5 months ago)
Author:
lrousseau
Message:

fix PEP8 errors

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • pykcs11/trunk/samples/LowLevel/InitTokenPin.py

    r48 r186  
    5151    print "\t\tTokenInfo: flags=" + hex(tokenInfo.flags) + ", Model=" + tokenInfo.GetModel() 
    5252 
    53     print "\tC_OpenSession(): " + hex(a.C_OpenSession(slotList[0], PyKCS11.LowLevel.CKF_SERIAL_SESSION|PyKCS11.LowLevel.CKF_RW_SESSION, session)) 
     53    print "\tC_OpenSession(): " + hex(a.C_OpenSession(slotList[0], PyKCS11.LowLevel.CKF_SERIAL_SESSION | PyKCS11.LowLevel.CKF_RW_SESSION, session)) 
    5454    print "\t\tSession:" + str(session) 
    5555    print "\tC_GetSessionInfo(): " + hex(a.C_GetSessionInfo(session, sessionInfo)) 
     
    7070print "C_Finalize(): " + hex(a.C_Finalize()) 
    7171print a.Unload() 
    72  
  • pykcs11/trunk/samples/LowLevel/dumpit.py

    r92 r186  
    4141    print "\tC_SlotInfo(): " + hex(a.C_GetSlotInfo(slotList[x], slotInfo)) 
    4242    print "\t\tSlot N." + str(x) + ": ID=" + str(slotList[x]) + ", name='" + slotInfo.GetSlotDescription() + "'" 
    43     print "\tC_OpenSession(): " + hex(a.C_OpenSession(slotList[x], CKF_SERIAL_SESSION|CKF_RW_SESSION, session)) 
     43    print "\tC_OpenSession(): " + hex(a.C_OpenSession(slotList[x], CKF_SERIAL_SESSION | CKF_RW_SESSION, session)) 
    4444    print "\t\tSession:" + str(session) 
    4545    print "\tC_GetSessionInfo(): " + hex(a.C_GetSessionInfo(session, sessionInfo)) 
     
    4949    print "\t\tTokenInfo: Label=" + tokenInfo.GetLabel() + ", ManufacturerID=" + tokenInfo.GetManufacturerID() 
    5050    print "\t\tTokenInfo: flags=" + hex(tokenInfo.flags) + ", Model=" + tokenInfo.GetModel() 
    51      
     51 
    5252    print "\tC_Login(): " + hex(a.C_Login(session, CKU_USER, pin)) 
    5353    print "\tC_Logout(): " + hex(a.C_Logout(session)) 
     
    6262#SearchTemplate[1].SetBool(CKA_TOKEN, True) 
    6363 
    64 print "C_FindObjectsInit: " + hex(a.C_FindObjectsInit(session, SearchTemplate)) 
    65 print "C_FindObjects: " + hex(a.C_FindObjects(session, SearchResult)) 
    66 print "C_FindObjectsFinal: " + hex(a.C_FindObjectsFinal(session)) 
     64print "C_FindObjectsInit: " + hex(a.C_FindObjectsInit(session, SearchTemplate)) 
     65print "C_FindObjects: " + hex(a.C_FindObjects(session, SearchResult)) 
     66print "C_FindObjectsFinal: " + hex(a.C_FindObjectsFinal(session)) 
    6767 
    6868attributes = [ 
    69        ["CKA_CLASS", CKA_CLASS], 
    70        ["CKA_TOKEN", CKA_TOKEN], 
    71        ["CKA_PRIVATE", CKA_PRIVATE], 
    72        ["CKA_LABEL", CKA_LABEL], 
    73        ["CKA_APPLICATION", CKA_APPLICATION], 
    74        ["CKA_VALUE", CKA_VALUE], 
    75        ["CKA_CERTIFICATE_TYPE", CKA_CERTIFICATE_TYPE], 
    76        ["CKA_ISSUER", CKA_ISSUER], 
    77        ["CKA_SERIAL_NUMBER", CKA_SERIAL_NUMBER], 
    78        ["CKA_KEY_TYPE", CKA_KEY_TYPE], 
    79        ["CKA_SUBJECT", CKA_SUBJECT], 
    80        ["CKA_ID", CKA_ID], 
    81        ["CKA_SENSITIVE", CKA_SENSITIVE], 
    82        ["CKA_ENCRYPT", CKA_ENCRYPT], 
    83        ["CKA_DECRYPT", CKA_DECRYPT], 
    84        ["CKA_WRAP", CKA_WRAP], 
    85        ["CKA_UNWRAP", CKA_UNWRAP], 
    86        ["CKA_SIGN", CKA_SIGN], 
    87        ["CKA_SIGN_RECOVER", CKA_SIGN_RECOVER], 
    88        ["CKA_VERIFY", CKA_VERIFY], 
    89        ["CKA_VERIFY_RECOVER", CKA_VERIFY_RECOVER], 
    90        ["CKA_DERIVE", CKA_DERIVE], 
    91        ["CKA_START_DATE", CKA_START_DATE], 
    92        ["CKA_END_DATE", CKA_END_DATE], 
    93        ["CKA_MODULUS", CKA_MODULUS], 
    94        ["CKA_MODULUS_BITS", CKA_MODULUS_BITS], 
    95        ["CKA_PUBLIC_EXPONENT", CKA_PUBLIC_EXPONENT], 
    96        ["CKA_PRIVATE_EXPONENT", CKA_PRIVATE_EXPONENT], 
    97        ["CKA_PRIME_1", CKA_PRIME_1], 
    98        ["CKA_PRIME_2", CKA_PRIME_2], 
    99        ["CKA_EXPONENT_1", CKA_EXPONENT_1], 
    100        ["CKA_EXPONENT_2", CKA_EXPONENT_2], 
    101        ["CKA_COEFFICIENT", CKA_COEFFICIENT], 
    102        ["CKA_PRIME", CKA_PRIME], 
    103        ["CKA_SUBPRIME", CKA_SUBPRIME], 
    104        ["CKA_BASE", CKA_BASE], 
    105        ["CKA_VALUE_BITS", CKA_VALUE_BITS], 
    106        ["CKA_VALUE_LEN", CKA_VALUE_LEN], 
    107        ["CKA_EXTRACTABLE", CKA_EXTRACTABLE], 
    108        ["CKA_LOCAL", CKA_LOCAL], 
    109        ["CKA_NEVER_EXTRACTABLE", CKA_NEVER_EXTRACTABLE], 
    110        ["CKA_ALWAYS_SENSITIVE", CKA_ALWAYS_SENSITIVE], 
    111        ["CKA_MODIFIABLE", CKA_MODIFIABLE], 
    112        ["CKA_ECDSA_PARAMS", CKA_ECDSA_PARAMS], 
    113        ["CKA_EC_POINT", CKA_EC_POINT], 
    114        
     69    ["CKA_CLASS", CKA_CLASS], 
     70    ["CKA_TOKEN", CKA_TOKEN], 
     71    ["CKA_PRIVATE", CKA_PRIVATE], 
     72    ["CKA_LABEL", CKA_LABEL], 
     73    ["CKA_APPLICATION", CKA_APPLICATION], 
     74    ["CKA_VALUE", CKA_VALUE], 
     75    ["CKA_CERTIFICATE_TYPE", CKA_CERTIFICATE_TYPE], 
     76    ["CKA_ISSUER", CKA_ISSUER], 
     77    ["CKA_SERIAL_NUMBER", CKA_SERIAL_NUMBER], 
     78    ["CKA_KEY_TYPE", CKA_KEY_TYPE], 
     79    ["CKA_SUBJECT", CKA_SUBJECT], 
     80    ["CKA_ID", CKA_ID], 
     81    ["CKA_SENSITIVE", CKA_SENSITIVE], 
     82    ["CKA_ENCRYPT", CKA_ENCRYPT], 
     83    ["CKA_DECRYPT", CKA_DECRYPT], 
     84    ["CKA_WRAP", CKA_WRAP], 
     85    ["CKA_UNWRAP", CKA_UNWRAP], 
     86    ["CKA_SIGN", CKA_SIGN], 
     87    ["CKA_SIGN_RECOVER", CKA_SIGN_RECOVER], 
     88    ["CKA_VERIFY", CKA_VERIFY], 
     89    ["CKA_VERIFY_RECOVER", CKA_VERIFY_RECOVER], 
     90    ["CKA_DERIVE", CKA_DERIVE], 
     91    ["CKA_START_DATE", CKA_START_DATE], 
     92    ["CKA_END_DATE", CKA_END_DATE], 
     93    ["CKA_MODULUS", CKA_MODULUS], 
     94    ["CKA_MODULUS_BITS", CKA_MODULUS_BITS], 
     95    ["CKA_PUBLIC_EXPONENT", CKA_PUBLIC_EXPONENT], 
     96    ["CKA_PRIVATE_EXPONENT", CKA_PRIVATE_EXPONENT], 
     97    ["CKA_PRIME_1", CKA_PRIME_1], 
     98    ["CKA_PRIME_2", CKA_PRIME_2], 
     99    ["CKA_EXPONENT_1", CKA_EXPONENT_1], 
     100    ["CKA_EXPONENT_2", CKA_EXPONENT_2], 
     101    ["CKA_COEFFICIENT", CKA_COEFFICIENT], 
     102    ["CKA_PRIME", CKA_PRIME], 
     103    ["CKA_SUBPRIME", CKA_SUBPRIME], 
     104    ["CKA_BASE", CKA_BASE], 
     105    ["CKA_VALUE_BITS", CKA_VALUE_BITS], 
     106    ["CKA_VALUE_LEN", CKA_VALUE_LEN], 
     107    ["CKA_EXTRACTABLE", CKA_EXTRACTABLE], 
     108    ["CKA_LOCAL", CKA_LOCAL], 
     109    ["CKA_NEVER_EXTRACTABLE", CKA_NEVER_EXTRACTABLE], 
     110    ["CKA_ALWAYS_SENSITIVE", CKA_ALWAYS_SENSITIVE], 
     111    ["CKA_MODIFIABLE", CKA_MODIFIABLE], 
     112    ["CKA_ECDSA_PARAMS", CKA_ECDSA_PARAMS], 
     113    ["CKA_EC_POINT", CKA_EC_POINT], 
     114   
    115115 
    116116for x in SearchResult: 
    117        print "object: " + hex(x.value()) 
    118        valTemplate = ckattrlist(1) 
    119        for attr in attributes: 
    120                valTemplate[0].Reset() 
    121                valTemplate[0].SetType(attr[1]) 
    122                # first call to get the attribute size and reserve the memory 
    123                a.C_GetAttributeValue(session, x, valTemplate) 
    124                # second call to get the attribute value 
    125                rv = a.C_GetAttributeValue(session, x, valTemplate) 
    126                if (rv == CKR_OK): 
    127                        print "\t" + attr[0] + ": ", 
    128                        if (valTemplate[0].IsNum()): 
    129                                print valTemplate[0].GetNum() 
    130                        if (valTemplate[0].IsBool()): 
    131                                print valTemplate[0].GetBool() 
    132                        if (valTemplate[0].IsString()): 
    133                                print valTemplate[0].GetString() 
    134                        if (valTemplate[0].IsBin()): 
    135                                print "(" + str(valTemplate[0].GetLen()) + " bytes)", 
    136                                print map(hex, valTemplate[0].GetBin()) 
    137      
     117    print "object: " + hex(x.value()) 
     118    valTemplate = ckattrlist(1) 
     119    for attr in attributes: 
     120        valTemplate[0].Reset() 
     121        valTemplate[0].SetType(attr[1]) 
     122        # first call to get the attribute size and reserve the memory 
     123        a.C_GetAttributeValue(session, x, valTemplate) 
     124        # second call to get the attribute value 
     125        rv = a.C_GetAttributeValue(session, x, valTemplate) 
     126        if (rv == CKR_OK): 
     127            print "\t" + attr[0] + ": ", 
     128            if (valTemplate[0].IsNum()): 
     129                print valTemplate[0].GetNum() 
     130            if (valTemplate[0].IsBool()): 
     131                print valTemplate[0].GetBool() 
     132            if (valTemplate[0].IsString()): 
     133                print valTemplate[0].GetString() 
     134            if (valTemplate[0].IsBin()): 
     135                print "(" + str(valTemplate[0].GetLen()) + " bytes)", 
     136                print map(hex, valTemplate[0].GetBin()) 
     137 
    138138print "C_Logout(): " + hex(a.C_Logout(session)) 
    139139print "C_CloseSession(): " + hex(a.C_CloseSession(session)) 
    140140print "C_Finalize(): " + hex(a.C_Finalize()) 
    141141print a.Unload() 
    142  
  • pykcs11/trunk/samples/LowLevel/test.py

    r92 r186  
    4040    print "\tC_SlotInfo(): " + hex(a.C_GetSlotInfo(slotList[x], slotInfo)) 
    4141    print "\t\tSlot N." + str(x) + ": ID=" + str(slotList[x]) + ", name='" + slotInfo.GetSlotDescription() + "'" 
    42     print "\tC_OpenSession(): " + hex(a.C_OpenSession(slotList[x], PyKCS11.LowLevel.CKF_SERIAL_SESSION|PyKCS11.LowLevel.CKF_RW_SESSION, session)) 
     42    print "\tC_OpenSession(): " + hex(a.C_OpenSession(slotList[x], PyKCS11.LowLevel.CKF_SERIAL_SESSION | PyKCS11.LowLevel.CKF_RW_SESSION, session)) 
    4343    print "\t\tSession:" + str(session) 
    4444    print "\tC_GetSessionInfo(): " + hex(a.C_GetSessionInfo(session, sessionInfo)) 
     
    4848    print "\t\tTokenInfo: Label=" + tokenInfo.GetLabel() + ", ManufacturerID=" + tokenInfo.GetManufacturerID() 
    4949    print "\t\tTokenInfo: flags=" + hex(tokenInfo.flags) + ", Model=" + tokenInfo.GetModel() 
    50      
     50 
    5151    print "\tC_Login(): " + hex(a.C_Login(session, PyKCS11.LowLevel.CKU_USER, pin)) 
    5252    print "\tC_Logout(): " + hex(a.C_Logout(session)) 
     
    6161SearchTemplate[1].SetBool(PyKCS11.LowLevel.CKA_TOKEN, True) 
    6262 
    63 print "C_FindObjectsInit: " + hex(a.C_FindObjectsInit(session, SearchTemplate)) 
    64 print "C_FindObjects: " + hex(a.C_FindObjects(session, SearchResult)) 
    65 print "C_FindObjectsFinal: " + hex(a.C_FindObjectsFinal(session)) 
     63print "C_FindObjectsInit: " + hex(a.C_FindObjectsInit(session, SearchTemplate)) 
     64print "C_FindObjects: " + hex(a.C_FindObjects(session, SearchResult)) 
     65print "C_FindObjectsFinal: " + hex(a.C_FindObjectsFinal(session)) 
    6666 
    6767for x in SearchResult: 
     
    7373    #valTemplate[1].Reserve(4) 
    7474    print "C_GetAttributeValue(): " + hex(a.C_GetAttributeValue(session, x, valTemplate)) 
    75     print "CKA_LABEL Len: ", valTemplate[0].GetLen(), " CKA_CLASS Len: ",valTemplate[1].GetLen() 
    76     print "C_GetAttributeValue(): " + hex(a.C_GetAttributeValue(session, x, valTemplate))    
     75    print "CKA_LABEL Len: ", valTemplate[0].GetLen(), " CKA_CLASS Len: ", valTemplate[1].GetLen() 
     76    print "C_GetAttributeValue(): " + hex(a.C_GetAttributeValue(session, x, valTemplate)) 
    7777    print "\tCKO_CERTIFICATE: " + valTemplate[0].GetString() 
    7878    print "\tCKA_TOKEN: " + str(valTemplate[1].GetNum()) 
    79      
     79 
    8080print "C_Logout(): " + hex(a.C_Logout(session)) 
    8181print "C_CloseSession(): " + hex(a.C_CloseSession(session)) 
    8282print "C_Finalize(): " + hex(a.C_Finalize()) 
    8383print a.Unload() 
    84  
  • pykcs11/trunk/samples/LowLevel/test1.py

    r92 r186  
    4040    print "\tC_SlotInfo(): " + hex(a.C_GetSlotInfo(slotList[x], slotInfo)) 
    4141    print "\t\tSlot N." + str(x) + ": ID=" + str(slotList[x]) + ", name='" + slotInfo.GetSlotDescription() + "'" 
    42     print "\tC_OpenSession(): " + hex(a.C_OpenSession(slotList[x], PyKCS11.LowLevel.CKF_SERIAL_SESSION|PyKCS11.LowLevel.CKF_RW_SESSION, session)) 
     42    print "\tC_OpenSession(): " + hex(a.C_OpenSession(slotList[x], PyKCS11.LowLevel.CKF_SERIAL_SESSION | PyKCS11.LowLevel.CKF_RW_SESSION, session)) 
    4343    print "\t\tSession:" + str(session) 
    4444    print "\tC_GetSessionInfo(): " + hex(a.C_GetSessionInfo(session, sessionInfo)) 
     
    4848    print "\t\tTokenInfo: Label=" + tokenInfo.GetLabel() + ", ManufacturerID=" + tokenInfo.GetManufacturerID() 
    4949    print "\t\tTokenInfo: flags=" + hex(tokenInfo.flags) + ", Model=" + tokenInfo.GetModel() 
    50      
     50 
    5151    print "\tC_Login(): " + hex(a.C_Login(session, PyKCS11.LowLevel.CKU_USER, pin)) 
    5252    print "\tC_Logout(): " + hex(a.C_Logout(session)) 
    5353    print "\tC_CloseSession(): " + hex(a.C_CloseSession(session)) 
    5454 
    55 print "C_OpenSession(): " + hex(a.C_OpenSession(slotList[0], PyKCS11.LowLevel.CKF_RW_SESSION|PyKCS11.LowLevel.CKF_SERIAL_SESSION, session)) 
     55print "C_OpenSession(): " + hex(a.C_OpenSession(slotList[0], PyKCS11.LowLevel.CKF_RW_SESSION | PyKCS11.LowLevel.CKF_SERIAL_SESSION, session)) 
    5656print "C_Login(): " + hex(a.C_Login(session, PyKCS11.LowLevel.CKU_USER, pin)) 
    5757 
     
    6161SearchTemplate[1].SetBool(PyKCS11.LowLevel.CKA_TOKEN, True) 
    6262 
    63 print "C_FindObjectsInit: " + hex(a.C_FindObjectsInit(session, SearchTemplate)) 
    64 print "C_FindObjects: " + hex(a.C_FindObjects(session, SearchResult)) 
    65 print "C_FindObjectsFinal: " + hex(a.C_FindObjectsFinal(session)) 
     63print "C_FindObjectsInit: " + hex(a.C_FindObjectsInit(session, SearchTemplate)) 
     64print "C_FindObjects: " + hex(a.C_FindObjects(session, SearchResult)) 
     65print "C_FindObjectsFinal: " + hex(a.C_FindObjectsFinal(session)) 
    6666 
    6767for x in SearchResult: 
     
    7575    binval = list(valTemplate[0].GetBin()) 
    7676    print "binval=", binval 
    77     binval[0] = 0; 
     77    binval[0] = 0 
    7878    valTemplate[0].SetBin(PyKCS11.LowLevel.CKA_ISSUER, binval) 
    7979    binval = valTemplate[0].GetBin() # list(valTemplate[0].GetBin()) 
    8080    print "binval[0]=", binval[0] 
    81     binval[0] = 0; 
    82      
     81    binval[0] = 0 
     82 
    8383    print "C_SetAttributeValue(): " + hex(a.C_SetAttributeValue(session, x, valTemplate)) 
    84      
     84 
    8585print "C_Logout(): " + hex(a.C_Logout(session)) 
    8686print "C_CloseSession(): " + hex(a.C_CloseSession(session)) 
    8787print "C_Finalize(): " + hex(a.C_Finalize()) 
    8888print a.Unload() 
    89  
(C) 2006 bit4id srl, for informations please contact info@bit4id.com
visitors since August 21, 2006