Changeset 115

Show
Ignore:
Timestamp:
02/11/08 09:09:17 (2 years ago)
Author:
lrousseau
Message:

add getMechanismList() method

See Ticket #11

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • pykcs11/trunk/PyKCS11/__init__.py

    r101 r115  
    445445        return s 
    446446 
     447    def getMechanismList(self, slot): 
     448        """ 
     449        C_GetMechanismList 
     450 
     451        @return: the list of available mechanisms for a slot 
     452        @rtype: list 
     453        """ 
     454        mechanismList = PyKCS11.LowLevel.ckintlist() 
     455        rv = self.lib.C_GetMechanismList(slot, mechanismList) 
     456        if rv != CKR_OK: 
     457            raise PyKCS11Error(rv) 
     458 
     459        m = [] 
     460        for x in xrange(len(mechanismList)): 
     461            m.append(CKM[mechanismList[x]]) 
     462        return m 
     463 
    447464class Mechanism: 
    448465    """Wraps CK_MECHANISM""" 
  • pykcs11/trunk/samples/getinfo.py

    r99 r115  
    116116    colorize("  utcTime:", t.utcTime) 
    117117 
     118    m = pkcs11.getMechanismList(slots[slot]) 
     119    print "  Mechanism list: " 
     120    for x in m: 
     121        print "   " + blue + x + normal 
     122 
    118123    if pin_available: 
    119124        session.logout() 
  • pykcs11/trunk/src/pkcs11lib.cpp

    r111 r115  
    952952} 
    953953 
     954CK_RV CPKCS11Lib::C_GetMechanismList( 
     955        unsigned long slotID, 
     956        vector<long> &mechanismList) 
     957{ 
     958        CPKCS11LIB_PROLOGUE(C_GetMechanismList); 
     959 
     960        CK_ULONG i; 
     961        mechanismList.clear(); 
     962        CK_MECHANISM_TYPE ck_mechanismList[1024]; 
     963        CK_ULONG ulCount = sizeof(ck_mechanismList)/sizeof(ck_mechanismList[0]); 
     964        rv = m_pFunc->C_GetMechanismList(slotID, ck_mechanismList, &ulCount); 
     965        if (CKR_OK == rv) 
     966                for(i=0; i<ulCount; i++) 
     967                        mechanismList.push_back(ck_mechanismList[i]); 
     968 
     969        CPKCS11LIB_EPILOGUE; 
     970        return rv; 
     971} 
     972 
    954973/////////////////////////////////////////////////////////////////////////////// 
    955974 
  • pykcs11/trunk/src/pkcs11lib.h

    r112 r115  
    283283                unsigned long* pSlot); 
    284284 
     285        CK_RV C_GetMechanismList( 
     286                unsigned long slotID, 
     287                vector<long> &mechanismList); 
     288 
    285289}; 
    286290 
(C) 2006 bit4id srl, for informations please contact info@bit4id.com
visitors since August 21, 2006