diff options
-rw-r--r-- | security/nss/lib/cryptohi/keyhi.h | 7 | ||||
-rw-r--r-- | security/nss/lib/cryptohi/seckey.c | 23 |
2 files changed, 30 insertions, 0 deletions
diff --git a/security/nss/lib/cryptohi/keyhi.h b/security/nss/lib/cryptohi/keyhi.h index e2a5abdad..46394bf10 100644 --- a/security/nss/lib/cryptohi/keyhi.h +++ b/security/nss/lib/cryptohi/keyhi.h @@ -135,6 +135,13 @@ SECKEY_ConvertAndDecodePublicKeyAndChallenge(char *pkacstr, char *challenge, void *cx); /* +** Encode a CERTSubjectPublicKeyInfo structure. into a +** DER encoded subject public key info. +*/ +SECItem * +SECKEY_EncodeDERSubjectPublicKeyInfo(SECKEYPublicKey *pubk); + +/* ** Decode a DER encoded subject public key info into a ** CERTSubjectPublicKeyInfo structure. */ diff --git a/security/nss/lib/cryptohi/seckey.c b/security/nss/lib/cryptohi/seckey.c index d26770f3b..d9ec73121 100644 --- a/security/nss/lib/cryptohi/seckey.c +++ b/security/nss/lib/cryptohi/seckey.c @@ -1401,6 +1401,29 @@ SECKEY_ConvertAndDecodePublicKey(char *pubkstr) return pubk; } +SECItem * +SECKEY_EncodeDERSubjectPublicKeyInfo(SECKEYPublicKey *pubk) +{ + CERTSubjectPublicKeyInfo *spki=NULL; + SECItem *spkiDER=NULL; + + /* get the subjectpublickeyinfo */ + spki = SECKEY_CreateSubjectPublicKeyInfo(pubk); + if( spki == NULL ) { + goto finish; + } + + /* DER-encode the subjectpublickeyinfo */ + spkiDER = SEC_ASN1EncodeItem(NULL /*arena*/, NULL/*dest*/, spki, + CERT_SubjectPublicKeyInfoTemplate); +finish: + if (spki!=NULL) { + SECKEY_DestroySubjectPublicKeyInfo(spki); + } + return spkiDER; +} + + CERTSubjectPublicKeyInfo * SECKEY_DecodeDERSubjectPublicKeyInfo(SECItem *spkider) { |