mirror of
https://github.com/chris2511/xca.git
synced 2026-09-12 19:51:05 +05:00
Close #496: PKCS11 access to AWS CloudHSM failed
It results in CKR_SLOT_ID_INVALID error. Use CK_SLOT_ID definition (unsigned long) consistently. It is 64 bit on Linux. Especially don't mangle it through an 'int' in line 226 of lib/pkcs11_lib.cpp
This commit is contained in:
parent
4b37902052
commit
06009705bb
@ -77,12 +77,13 @@ QList<unsigned long> pkcs11_lib::getSlotList()
|
||||
{
|
||||
CK_RV rv;
|
||||
CK_SLOT_ID *p11_slots = NULL;
|
||||
QList<unsigned long> sl;
|
||||
QList<CK_SLOT_ID> sl;
|
||||
unsigned long i, num_slots = 0;
|
||||
|
||||
if (!isLoaded())
|
||||
return sl;
|
||||
|
||||
qDebug() << "sizeof CK_SLOT_ID" << sizeof(CK_SLOT_ID) << sizeof(unsigned long);
|
||||
/* This one helps to avoid errors.
|
||||
* Fist time it fails, 2nd time it works */
|
||||
CALL_P11_C(this, C_GetSlotList, CK_TRUE, p11_slots, &num_slots);
|
||||
@ -221,9 +222,9 @@ slotidList pkcs11_lib_list::getSlotList() const
|
||||
if (!l->isLoaded())
|
||||
continue;
|
||||
try {
|
||||
QList<unsigned long> realids;
|
||||
QList<CK_SLOT_ID> realids;
|
||||
realids = l->getSlotList();
|
||||
foreach(int id, realids)
|
||||
for (CK_SLOT_ID id : realids)
|
||||
list << slotid(l, id);
|
||||
success = true;
|
||||
} catch (errorEx &e) {
|
||||
|
||||
@ -31,7 +31,7 @@ class pkcs11_lib : public QLibrary
|
||||
pkcs11_lib() = delete;
|
||||
~pkcs11_lib();
|
||||
|
||||
QList<unsigned long> getSlotList();
|
||||
QList<CK_SLOT_ID> getSlotList();
|
||||
QString driverInfo() const;
|
||||
QString filename() const
|
||||
{
|
||||
@ -71,15 +71,11 @@ class pkcs11_lib : public QLibrary
|
||||
|
||||
class slotid
|
||||
{
|
||||
public:
|
||||
CK_ULONG id;
|
||||
public:
|
||||
pkcs11_lib *lib;
|
||||
CK_SLOT_ID id;
|
||||
slotid() = default;
|
||||
slotid(pkcs11_lib *l, CK_ULONG i)
|
||||
{
|
||||
lib = l;
|
||||
id = i;
|
||||
}
|
||||
slotid(pkcs11_lib *l, CK_SLOT_ID i) : lib(l), id(i) { }
|
||||
void isValid() const
|
||||
{
|
||||
if (!lib)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user