summaryrefslogtreecommitdiffstats
path: root/security/nss/lib/softoken/lowkey.c
diff options
context:
space:
mode:
Diffstat (limited to 'security/nss/lib/softoken/lowkey.c')
-rw-r--r--security/nss/lib/softoken/lowkey.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/security/nss/lib/softoken/lowkey.c b/security/nss/lib/softoken/lowkey.c
index f47bda231d..5adae04263 100644
--- a/security/nss/lib/softoken/lowkey.c
+++ b/security/nss/lib/softoken/lowkey.c
@@ -9,6 +9,7 @@
#include "secasn1.h"
#include "secerr.h"
#include "softoken.h"
+#include "ec.h"
SEC_ASN1_MKSUB(SEC_AnyTemplate)
SEC_ASN1_MKSUB(SEC_BitStringTemplate)
@@ -381,6 +382,24 @@ nsslowkey_ConvertToPublicKey(NSSLOWKEYPrivateKey *privk)
pubk->arena = arena;
pubk->keyType = privk->keyType;
+
+ /* if the public key value doesn't exist, calculate it */
+ if (privk->u.ec.publicValue.len == 0) {
+ /* Checking if it's an ed25519 key. */
+ SECOidTag privKeyOIDTag = SECOID_FindOIDTag(&privk->u.ec.ecParams.curveOID);
+ if (privKeyOIDTag == SEC_OID_ED25519_PUBLIC_KEY) {
+ PORT_Memset(&privk->u.ec.publicValue, 0, sizeof(privk->u.ec.publicValue));
+ if (SECITEM_AllocItem(privk->arena, &privk->u.ec.publicValue, Ed25519_PUBLIC_KEYLEN) == NULL) {
+ break;
+ }
+
+ rv = ED_DerivePublicKey(&privk->u.ec.privateValue, &privk->u.ec.publicValue);
+ if (rv != CKR_OK) {
+ break;
+ }
+ }
+ }
+
rv = SECITEM_CopyItem(arena, &pubk->u.ec.publicValue,
&privk->u.ec.publicValue);
if (rv != SECSuccess)