summaryrefslogtreecommitdiff
path: root/security/nss
diff options
context:
space:
mode:
authorrelyea%netscape.com <devnull@localhost>2001-06-07 21:47:29 +0000
committerrelyea%netscape.com <devnull@localhost>2001-06-07 21:47:29 +0000
commit753db08eac0699a8f6311d7cf4b5d950a0fdfe31 (patch)
treecc297a422a8b9e528bcf011743d39c51b04b7898 /security/nss
parent73086b1f698f0478e401ea2565a451bddd1a3628 (diff)
downloadnss-hg-753db08eac0699a8f6311d7cf4b5d950a0fdfe31.tar.gz
Add function to encode a SPKI structure.
Diffstat (limited to 'security/nss')
-rw-r--r--security/nss/lib/cryptohi/keyhi.h7
-rw-r--r--security/nss/lib/cryptohi/seckey.c23
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)
{