Changes between Version 2 and Version 3 of revisionSoftwareXCA


Ignore:
Timestamp:
May 3, 2017, 10:19:14 AM (7 years ago)
Author:
aaraujo
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • revisionSoftwareXCA

    v2 v3  
    88
    99[[Image(xcaOptions.png)]]
     10
     11Add, Remove, Search.
     12
     13
     14
     15'''Options.cpp'''
     16{{{
     17addLib(QString fname)
     18
     19pkcs11:load_lib(fname, false)
     20
     21
     22class pkcs11
     23{
     24        friend class pk11_attribute;
     25        friend class pk11_attr_ulong;
     26        friend class pk11_attr_data;
     27
     28        private:
     29                static pkcs11_lib_list libs;
     30                slotid p11slot;
     31                CK_SESSION_HANDLE session;
     32                CK_OBJECT_HANDLE p11obj;
     33
     34        public:
     35                pkcs11();
     36                ~pkcs11();
     37
     38                static bool loaded() {
     39                        return libs.count() != 0;
     40                }
     41                static pkcs11_lib *load_lib(QString fname, bool silent);
     42                static pkcs11_lib *get_lib(QString fname)
     43                {
     44                        return libs.get_lib(fname);
     45                }
     46                static bool remove_lib(QString fname)
     47                {
     48                        return libs.remove_lib(fname);
     49                }
     50                static void remove_libs()
     51                {
     52                        while (!libs.isEmpty())
     53                                delete libs.takeFirst();
     54                }
     55                static void load_libs(QString list, bool silent);
     56                static pkcs11_lib_list get_libs()
     57                {
     58                        return libs;
     59                }
     60                tkInfo tokenInfo(slotid slot);
     61                tkInfo tokenInfo()
     62                {
     63                        return tokenInfo(p11slot);
     64                }
     65                QString driverInfo(slotid slot)
     66                {
     67                        return slot.lib->driverInfo();
     68                }
     69                slotidList getSlotList()
     70                {
     71                        return libs.getSlotList();
     72                }
     73
     74                bool selectToken(slotid *slot, QWidget *w);
     75                void changePin(slotid slot, bool so);
     76                void initPin(slotid slot);
     77                void initToken(slotid slot, unsigned char *pin,
     78                        int pinlen, QString label);
     79                QList<CK_MECHANISM_TYPE> mechanismList(slotid slot);
     80                void mechanismInfo(slotid slot, CK_MECHANISM_TYPE m,
     81                        CK_MECHANISM_INFO *info);
     82                void startSession(slotid slot, bool rw = false);
     83
     84                /* Session based functions */
     85                void loadAttribute(pk11_attribute &attribute,
     86                                   CK_OBJECT_HANDLE object);
     87                void storeAttribute(pk11_attribute &attribute,
     88                                   CK_OBJECT_HANDLE object);
     89                QList<CK_OBJECT_HANDLE> objectList(pk11_attlist &atts);
     90                QString tokenLogin(QString name, bool so, bool force=false);
     91                void getRandom();
     92                void logout();
     93                bool needsLogin(bool so);
     94                void login(unsigned char *pin, unsigned long pinlen, bool so);
     95
     96                void setPin(unsigned char *oldPin, unsigned long oldPinLen,
     97                        unsigned char *pin, unsigned long pinLen);
     98                CK_OBJECT_HANDLE createObject(pk11_attlist &attrs);
     99                pk11_attr_data findUniqueID(unsigned long oclass);
     100                pk11_attr_data generateKey(QString name,
     101                        unsigned long ec_rsa_mech, unsigned long bits, int nid);
     102                int deleteObjects(QList<CK_OBJECT_HANDLE> objects);
     103                EVP_PKEY *getPrivateKey(EVP_PKEY *pub, CK_OBJECT_HANDLE obj);
     104                int encrypt(int flen, const unsigned char *from,
     105                                unsigned char *to, int tolen, unsigned long m);
     106                int decrypt(int flen, const unsigned char *from,
     107                                unsigned char *to, int tolen, unsigned long m);
     108
     109};
     110
     111
     112
     113}}}
     114
     115
     116'''Search'''
     117{{{
     118bool searchThread::checkLib(QString file)
     119{
     120        qint64 siz;
     121        int r = -1;
     122
     123        QFile qf(file);
     124        siz = qf.size();
     125        if (qf.open(QIODevice::ReadOnly)) {
     126                uchar *p = qf.map(0, siz);
     127                r = QByteArray::fromRawData((char*)p, siz)
     128                        .indexOf("C_GetFunctionList");
     129                qf.unmap(p);
     130                qf.close();
     131        }
     132        return r != -1;
     133}
     134}}}
     135
     136
     137
     138
     139
     140
     141