diff options
author | Jon Spillett <jon.spillett@oracle.com> | 2019-09-19 15:39:13 +1000 |
---|---|---|
committer | Pauli <paul.dale@oracle.com> | 2020-08-07 07:59:48 +1000 |
commit | c5ec6dcf0bdd15354a1440632766e19540487c58 (patch) | |
tree | c95f50468b0d3470ceaf7f5025db6b4fbc4d83b2 /crypto/pkcs12/p12_crt.c | |
parent | 15c9aa3aef77c642ef2b6c84bba2b57b35ed083e (diff) |
Add new APIs to get PKCS12 secretBag OID and value
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/10063)
Diffstat (limited to 'crypto/pkcs12/p12_crt.c')
-rw-r--r-- | crypto/pkcs12/p12_crt.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/crypto/pkcs12/p12_crt.c b/crypto/pkcs12/p12_crt.c index f75b2437c9..699f1b7d61 100644 --- a/crypto/pkcs12/p12_crt.c +++ b/crypto/pkcs12/p12_crt.c @@ -207,6 +207,24 @@ PKCS12_SAFEBAG *PKCS12_add_key(STACK_OF(PKCS12_SAFEBAG) **pbags, } +PKCS12_SAFEBAG *PKCS12_add_secret(STACK_OF(PKCS12_SAFEBAG) **pbags, + int nid_type, const unsigned char *value, int len) +{ + PKCS12_SAFEBAG *bag = NULL; + + /* Add secret, storing the value as an octet string */ + if ((bag = PKCS12_SAFEBAG_create_secret(nid_type, V_ASN1_OCTET_STRING, value, len)) == NULL) + goto err; + + if (!pkcs12_add_bag(pbags, bag)) + goto err; + + return bag; + err: + PKCS12_SAFEBAG_free(bag); + return NULL; +} + int PKCS12_add_safe(STACK_OF(PKCS7) **psafes, STACK_OF(PKCS12_SAFEBAG) *bags, int nid_safe, int iter, const char *pass) { |