Graham Leggett wrote:
I am trying to call PK11_CreateContextBySymKey and it is returning NULL.
Using PORT_GetError, the error code returned is zero.Reverse engineering the PK11_CreateContextBySymKey function, I have found that the function returns NULL in a number of locations, many without any attempt to set an error code, which effectively means it is impossible to distinguish one error from another.
From the debugger trace below, is there any obvious reason why the above function should return null?
253 cipherMech = CKM_DES3_CBC_PAD; (gdb) 254 break; (gdb) 271 keyItem.data = (unsigned char*)key; (gdb) 272 keyItem.len = keyLen; (gdb) 274 PK11SlotInfo * slot = PK11_GetBestSlot(cipherMech, NULL); (gdb) 277 block->key = PK11_ImportSymKey(slot, (gdb) print slot $1 = (PK11SlotInfo *) 0x812600 (gdb) next 285 if (slot) { (gdb) print block->key $2 = (PK11SymKey *) 0x310f20 (gdb) next 286 PK11_FreeSlot(slot); (gdb) 289 switch (type) { (gdb) 294 if (mode == MODE_CBC) { (gdb) print block->key $3 = (PK11SymKey *) 0x310f20 (gdb) next326 block->ctx = PK11_CreateContextBySymKey(CKM_DES3_ECB, CKA_ENCRYPT, block->key, NULL);
(gdb) 327 block->ivSize = 0; (gdb) print block->ctx $4 = (PK11Context *) 0x0 ^^^^^^^^^^^^^^^^^^^^^^^^ context returned is NULL (gdb) next 386 perr = PORT_GetError(); (gdb) 387 if (perr) { (gdb) print perr $5 = 0 ^^^^^^ error returned is zero Regards, Graham --
smime.p7s
Description: S/MIME Cryptographic Signature
_______________________________________________ dev-tech-crypto mailing list dev-tech-crypto@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-tech-crypto