Skip to content

Commit f6aea8a

Browse files
authored
Merge pull request #16 from SparkiDev/wolfpkcs11_fixup_3
Fixes: setting of label, init ecc object
2 parents a6e7ac4 + 8c12f1c commit f6aea8a

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

src/crypto.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3609,10 +3609,6 @@ CK_RV C_GenerateKeyPair(CK_SESSION_HANDLE hSession,
36093609
rv = AddObject(session, pub, pPublicKeyTemplate,
36103610
ulPublicKeyAttributeCount, phPublicKey);
36113611
}
3612-
if (rv == CKR_OK) {
3613-
rv = AddObject(session, priv, pPrivateKeyTemplate,
3614-
ulPrivateKeyAttributeCount, phPrivateKey);
3615-
}
36163612
#ifdef WOLFPKCS11_KEYPAIR_GEN_COMMON_LABEL
36173613
if (rv == CKR_OK) {
36183614
CK_ULONG len;
@@ -3630,6 +3626,10 @@ CK_RV C_GenerateKeyPair(CK_SESSION_HANDLE hSession,
36303626
}
36313627
}
36323628
#endif
3629+
if (rv == CKR_OK) {
3630+
rv = AddObject(session, priv, pPrivateKeyTemplate,
3631+
ulPrivateKeyAttributeCount, phPrivateKey);
3632+
}
36333633

36343634
if (rv != CKR_OK && pub != NULL)
36353635
WP11_Object_Free(pub);

src/internal.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1552,15 +1552,18 @@ static int wp11_Object_Decode_EccKey(WP11_Object* object)
15521552
sizeof(object->iv));
15531553
}
15541554
if (ret == 0) {
1555-
/* Decode RSA private key. */
1555+
ret = wc_ecc_init(&object->data.ecKey);
1556+
}
1557+
if (ret == 0) {
1558+
/* Decode ECC private key. */
15561559
ret = wc_EccPrivateKeyDecode(der, &idx, &object->data.ecKey, len);
15571560
XMEMSET(der, 0, len);
15581561
}
15591562
if (der != NULL)
15601563
XFREE(der, NULL, DYNAMIC_TYPE_TMP_BUFFER);
15611564
}
15621565
else {
1563-
/* Decode RSA public key. */
1566+
/* Decode ECC public key. */
15641567
ret = wc_EccPublicKeyDecode(object->keyData, &idx, &object->data.ecKey,
15651568
object->keyDataLen);
15661569
}

0 commit comments

Comments
 (0)