1 /* ***** BEGIN LICENSE BLOCK *****
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 * The contents of this file are subject to the Mozilla Public License Version
5 * 1.1 (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 * http://www.mozilla.org/MPL/
9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 * for the specific language governing rights and limitations under the
14 * The Original Code is the Netscape security libraries.
16 * The Initial Developer of the Original Code is
17 * Netscape Communications Corporation.
18 * Portions created by the Initial Developer are Copyright (C) 1994-2000
19 * the Initial Developer. All Rights Reserved.
23 * Alternatively, the contents of this file may be used under the terms of
24 * either the GNU General Public License Version 2 or later (the "GPL"), or
25 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
26 * in which case the provisions of the GPL or the LGPL are applicable instead
27 * of those above. If you wish to allow use of your version of this file only
28 * under the terms of either the GPL or the LGPL, and not to allow others to
29 * use your version of this file under the terms of the MPL, indicate your
30 * decision by deleting the provisions above and replace them with the notice
31 * and other provisions required by the GPL or the LGPL. If you do not delete
32 * the provisions above, a recipient may use your version of this file under
33 * the terms of any one of the MPL, the GPL or the LGPL.
35 * ***** END LICENSE BLOCK ***** */
50 #define SALT_LENGTH 16
52 SEC_ASN1_MKSUB(SECKEY_PrivateKeyInfoTemplate
)
53 SEC_ASN1_MKSUB(sgn_DigestInfoTemplate
)
56 sec_pkcs12_algtag_to_mech(SECOidTag algtag
)
64 return CKM_SHA_1_HMAC
;
66 return CKM_SHA256_HMAC
;
68 return CKM_SHA384_HMAC
;
70 return CKM_SHA512_HMAC
;
74 return CKM_INVALID_MECHANISM
;
77 /* helper functions */
78 /* returns proper bag type template based upon object type tag */
79 const SEC_ASN1Template
*
80 sec_pkcs12_choose_bag_type_old(void *src_or_dest
, PRBool encoding
)
82 const SEC_ASN1Template
*theTemplate
;
83 SEC_PKCS12SafeBag
*safebag
;
86 if (src_or_dest
== NULL
) {
90 safebag
= (SEC_PKCS12SafeBag
*)src_or_dest
;
92 oiddata
= safebag
->safeBagTypeTag
;
93 if (oiddata
== NULL
) {
94 oiddata
= SECOID_FindOID(&safebag
->safeBagType
);
95 safebag
->safeBagTypeTag
= oiddata
;
98 switch (oiddata
->offset
) {
100 theTemplate
= SEC_ASN1_GET(SEC_PointerToAnyTemplate
);
102 case SEC_OID_PKCS12_KEY_BAG_ID
:
103 theTemplate
= SEC_PointerToPKCS12KeyBagTemplate
;
105 case SEC_OID_PKCS12_CERT_AND_CRL_BAG_ID
:
106 theTemplate
= SEC_PointerToPKCS12CertAndCRLBagTemplate_OLD
;
108 case SEC_OID_PKCS12_SECRET_BAG_ID
:
109 theTemplate
= SEC_PointerToPKCS12SecretBagTemplate
;
115 const SEC_ASN1Template
*
116 sec_pkcs12_choose_bag_type(void *src_or_dest
, PRBool encoding
)
118 const SEC_ASN1Template
*theTemplate
;
119 SEC_PKCS12SafeBag
*safebag
;
122 if (src_or_dest
== NULL
) {
126 safebag
= (SEC_PKCS12SafeBag
*)src_or_dest
;
128 oiddata
= safebag
->safeBagTypeTag
;
129 if (oiddata
== NULL
) {
130 oiddata
= SECOID_FindOID(&safebag
->safeBagType
);
131 safebag
->safeBagTypeTag
= oiddata
;
134 switch (oiddata
->offset
) {
136 theTemplate
= SEC_ASN1_GET(SEC_AnyTemplate
);
138 case SEC_OID_PKCS12_KEY_BAG_ID
:
139 theTemplate
= SEC_PKCS12PrivateKeyBagTemplate
;
141 case SEC_OID_PKCS12_CERT_AND_CRL_BAG_ID
:
142 theTemplate
= SEC_PKCS12CertAndCRLBagTemplate
;
144 case SEC_OID_PKCS12_SECRET_BAG_ID
:
145 theTemplate
= SEC_PKCS12SecretBagTemplate
;
151 /* returns proper cert crl template based upon type tag */
152 const SEC_ASN1Template
*
153 sec_pkcs12_choose_cert_crl_type_old(void *src_or_dest
, PRBool encoding
)
155 const SEC_ASN1Template
*theTemplate
;
156 SEC_PKCS12CertAndCRL
*certbag
;
159 if (src_or_dest
== NULL
) {
163 certbag
= (SEC_PKCS12CertAndCRL
*)src_or_dest
;
164 oiddata
= certbag
->BagTypeTag
;
165 if (oiddata
== NULL
) {
166 oiddata
= SECOID_FindOID(&certbag
->BagID
);
167 certbag
->BagTypeTag
= oiddata
;
170 switch (oiddata
->offset
) {
172 theTemplate
= SEC_ASN1_GET(SEC_PointerToAnyTemplate
);
174 case SEC_OID_PKCS12_X509_CERT_CRL_BAG
:
175 theTemplate
= SEC_PointerToPKCS12X509CertCRLTemplate_OLD
;
177 case SEC_OID_PKCS12_SDSI_CERT_BAG
:
178 theTemplate
= SEC_PointerToPKCS12SDSICertTemplate
;
184 const SEC_ASN1Template
*
185 sec_pkcs12_choose_cert_crl_type(void *src_or_dest
, PRBool encoding
)
187 const SEC_ASN1Template
*theTemplate
;
188 SEC_PKCS12CertAndCRL
*certbag
;
191 if (src_or_dest
== NULL
) {
195 certbag
= (SEC_PKCS12CertAndCRL
*)src_or_dest
;
196 oiddata
= certbag
->BagTypeTag
;
197 if (oiddata
== NULL
) {
198 oiddata
= SECOID_FindOID(&certbag
->BagID
);
199 certbag
->BagTypeTag
= oiddata
;
202 switch (oiddata
->offset
) {
204 theTemplate
= SEC_ASN1_GET(SEC_PointerToAnyTemplate
);
206 case SEC_OID_PKCS12_X509_CERT_CRL_BAG
:
207 theTemplate
= SEC_PointerToPKCS12X509CertCRLTemplate
;
209 case SEC_OID_PKCS12_SDSI_CERT_BAG
:
210 theTemplate
= SEC_PointerToPKCS12SDSICertTemplate
;
216 /* returns appropriate shroud template based on object type tag */
217 const SEC_ASN1Template
*
218 sec_pkcs12_choose_shroud_type(void *src_or_dest
, PRBool encoding
)
220 const SEC_ASN1Template
*theTemplate
;
221 SEC_PKCS12ESPVKItem
*espvk
;
224 if (src_or_dest
== NULL
) {
228 espvk
= (SEC_PKCS12ESPVKItem
*)src_or_dest
;
229 oiddata
= espvk
->espvkTag
;
230 if (oiddata
== NULL
) {
231 oiddata
= SECOID_FindOID(&espvk
->espvkOID
);
232 espvk
->espvkTag
= oiddata
;
235 switch (oiddata
->offset
) {
237 theTemplate
= SEC_ASN1_GET(SEC_PointerToAnyTemplate
);
239 case SEC_OID_PKCS12_PKCS8_KEY_SHROUDING
:
241 SEC_ASN1_GET(SECKEY_PointerToEncryptedPrivateKeyInfoTemplate
);
247 /* generate SALT placing it into the character array passed in.
248 * it is assumed that salt_dest is an array of appropriate size
249 * XXX We might want to generate our own random context
252 sec_pkcs12_generate_salt(void)
256 salt
= (SECItem
*)PORT_ZAlloc(sizeof(SECItem
));
258 PORT_SetError(SEC_ERROR_NO_MEMORY
);
261 salt
->data
= (unsigned char *)PORT_ZAlloc(sizeof(unsigned char) *
263 salt
->len
= SALT_LENGTH
;
264 if(salt
->data
== NULL
) {
265 PORT_SetError(SEC_ERROR_NO_MEMORY
);
266 SECITEM_ZfreeItem(salt
, PR_TRUE
);
270 PK11_GenerateRandom(salt
->data
, salt
->len
);
275 /* generate KEYS -- as per PKCS12 section 7.
279 sec_pkcs12_generate_key_from_password(SECOidTag algorithm
,
283 unsigned char *pre_hash
=NULL
;
284 unsigned char *hash_dest
=NULL
;
290 if((salt
== NULL
) || (password
== NULL
)) {
294 poolp
= PORT_NewArena(DER_DEFAULT_CHUNKSIZE
);
296 PORT_SetError(SEC_ERROR_NO_MEMORY
);
300 pre_hash
= (unsigned char *)PORT_ArenaZAlloc(poolp
, sizeof(char) *
301 (salt
->len
+password
->len
));
302 if(pre_hash
== NULL
) {
303 PORT_SetError(SEC_ERROR_NO_MEMORY
);
307 hash_dest
= (unsigned char *)PORT_ArenaZAlloc(poolp
,
308 sizeof(unsigned char) * SHA1_LENGTH
);
309 if(hash_dest
== NULL
) {
310 PORT_SetError(SEC_ERROR_NO_MEMORY
);
314 PORT_Memcpy(pre_hash
, salt
->data
, salt
->len
);
315 /* handle password of 0 length case */
316 if(password
->len
> 0) {
317 PORT_Memcpy(&(pre_hash
[salt
->len
]), password
->data
, password
->len
);
320 res
= PK11_HashBuf(SEC_OID_SHA1
, hash_dest
, pre_hash
,
321 (salt
->len
+password
->len
));
322 if(res
== SECFailure
) {
323 PORT_SetError(SEC_ERROR_NO_MEMORY
);
331 key
= (SECItem
*)PORT_ZAlloc(sizeof(SECItem
));
333 PORT_SetError(SEC_ERROR_NO_MEMORY
);
336 key
->data
= (unsigned char *)PORT_ZAlloc(sizeof(unsigned char)
338 if(key
->data
== NULL
) {
339 PORT_SetError(SEC_ERROR_NO_MEMORY
);
343 PORT_Memcpy(key
->data
, &hash_dest
[SHA1_LENGTH
-key
->len
], key
->len
);
350 PORT_FreeArena(poolp
, PR_TRUE
);
354 PORT_FreeArena(poolp
, PR_TRUE
);
356 SECITEM_ZfreeItem(key
, PR_TRUE
);
361 /* MAC is generated per PKCS 12 section 6. It is expected that key, msg
362 * and mac_dest are pre allocated, non-NULL arrays. msg_len is passed in
363 * because it is not known how long the message actually is. String
364 * manipulation routines will not necessarily work because msg may have
368 sec_pkcs12_generate_old_mac(SECItem
*key
,
372 PRArenaPool
*temparena
= NULL
;
373 unsigned char *hash_dest
=NULL
, *hash_src1
=NULL
, *hash_src2
= NULL
;
377 if((key
== NULL
) || (msg
== NULL
))
380 /* allocate return item */
381 mac
= (SECItem
*)PORT_ZAlloc(sizeof(SECItem
));
384 mac
->data
= (unsigned char *)PORT_ZAlloc(sizeof(unsigned char)
386 mac
->len
= SHA1_LENGTH
;
387 if(mac
->data
== NULL
)
390 /* allocate temporary items */
391 temparena
= PORT_NewArena(DER_DEFAULT_CHUNKSIZE
);
392 if(temparena
== NULL
)
395 hash_src1
= (unsigned char *)PORT_ArenaZAlloc(temparena
,
396 sizeof(unsigned char) * (16+msg
->len
));
397 if(hash_src1
== NULL
)
400 hash_src2
= (unsigned char *)PORT_ArenaZAlloc(temparena
,
401 sizeof(unsigned char) * (SHA1_LENGTH
+16));
402 if(hash_src2
== NULL
)
405 hash_dest
= (unsigned char *)PORT_ArenaZAlloc(temparena
,
406 sizeof(unsigned char) * SHA1_LENGTH
);
407 if(hash_dest
== NULL
)
410 /* perform mac'ing as per PKCS 12 */
412 /* first round of hashing */
413 for(i
= 0; i
< 16; i
++)
414 hash_src1
[i
] = key
->data
[i
] ^ 0x36;
415 PORT_Memcpy(&(hash_src1
[16]), msg
->data
, msg
->len
);
416 res
= PK11_HashBuf(SEC_OID_SHA1
, hash_dest
, hash_src1
, (16+msg
->len
));
417 if(res
== SECFailure
)
420 /* second round of hashing */
421 for(i
= 0; i
< 16; i
++)
422 hash_src2
[i
] = key
->data
[i
] ^ 0x5c;
423 PORT_Memcpy(&(hash_src2
[16]), hash_dest
, SHA1_LENGTH
);
424 res
= PK11_HashBuf(SEC_OID_SHA1
, mac
->data
, hash_src2
, SHA1_LENGTH
+16);
425 if(res
== SECFailure
)
428 PORT_FreeArena(temparena
, PR_TRUE
);
432 if(temparena
!= NULL
)
433 PORT_FreeArena(temparena
, PR_TRUE
);
435 SECITEM_ZfreeItem(mac
, PR_TRUE
);
439 /* MAC is generated per PKCS 12 section 6. It is expected that key, msg
440 * and mac_dest are pre allocated, non-NULL arrays. msg_len is passed in
441 * because it is not known how long the message actually is. String
442 * manipulation routines will not necessarily work because msg may have
446 sec_pkcs12_generate_mac(SECItem
*key
,
450 SECStatus res
= SECFailure
;
452 PK11Context
*pk11cx
= NULL
;
453 SECItem ignore
= {0};
455 if((key
== NULL
) || (msg
== NULL
)) {
459 if(old_method
== PR_TRUE
) {
460 return sec_pkcs12_generate_old_mac(key
, msg
);
463 /* allocate return item */
464 mac
= SECITEM_AllocItem(NULL
, NULL
, SHA1_LENGTH
);
469 pk11cx
= PK11_CreateContextByRawKey(NULL
, CKM_SHA_1_HMAC
, PK11_OriginDerive
,
470 CKA_SIGN
, key
, &ignore
, NULL
);
471 if (pk11cx
== NULL
) {
475 res
= PK11_DigestBegin(pk11cx
);
476 if (res
== SECFailure
) {
480 res
= PK11_DigestOp(pk11cx
, msg
->data
, msg
->len
);
481 if (res
== SECFailure
) {
485 res
= PK11_DigestFinal(pk11cx
, mac
->data
, &mac
->len
, SHA1_LENGTH
);
486 if (res
== SECFailure
) {
490 PK11_DestroyContext(pk11cx
, PR_TRUE
);
495 if(res
!= SECSuccess
) {
496 SECITEM_ZfreeItem(mac
, PR_TRUE
);
499 PK11_DestroyContext(pk11cx
, PR_TRUE
);
506 /* compute the thumbprint of the DER cert and create a digest info
507 * to store it in and return the digest info.
508 * a return of NULL indicates an error.
511 sec_pkcs12_compute_thumbprint(SECItem
*der_cert
)
513 SGNDigestInfo
*thumb
= NULL
;
515 PRArenaPool
*temparena
= NULL
;
516 SECStatus rv
= SECFailure
;
521 temparena
= PORT_NewArena(SEC_ASN1_DEFAULT_ARENA_SIZE
);
522 if(temparena
== NULL
) {
526 digest
.data
= (unsigned char *)PORT_ArenaZAlloc(temparena
,
527 sizeof(unsigned char) *
529 /* digest data and create digest info */
530 if(digest
.data
!= NULL
) {
531 digest
.len
= SHA1_LENGTH
;
532 rv
= PK11_HashBuf(SEC_OID_SHA1
, digest
.data
, der_cert
->data
,
534 if(rv
== SECSuccess
) {
535 thumb
= SGN_CreateDigestInfo(SEC_OID_SHA1
,
539 PORT_SetError(SEC_ERROR_NO_MEMORY
);
542 PORT_SetError(SEC_ERROR_NO_MEMORY
);
545 PORT_FreeArena(temparena
, PR_TRUE
);
550 /* create a virtual password per PKCS 12, the password is converted
551 * to unicode, the salt is prepended to it, and then the whole thing
554 sec_pkcs12_create_virtual_password(SECItem
*password
, SECItem
*salt
,
557 SECItem uniPwd
= {siBuffer
, NULL
,0}, *retPwd
= NULL
;
559 if((password
== NULL
) || (salt
== NULL
)) {
563 if(password
->len
== 0) {
564 uniPwd
.data
= (unsigned char*)PORT_ZAlloc(2);
570 uniPwd
.data
= (unsigned char*)PORT_ZAlloc(password
->len
* 3);
571 uniPwd
.len
= password
->len
* 3;
572 if(!PORT_UCS2_ASCIIConversion(PR_TRUE
, password
->data
, password
->len
,
573 uniPwd
.data
, uniPwd
.len
, &uniPwd
.len
, swap
)) {
574 SECITEM_ZfreeItem(&uniPwd
, PR_FALSE
);
579 retPwd
= (SECItem
*)PORT_ZAlloc(sizeof(SECItem
));
584 /* allocate space and copy proper data */
585 retPwd
->len
= uniPwd
.len
+ salt
->len
;
586 retPwd
->data
= (unsigned char *)PORT_Alloc(retPwd
->len
);
587 if(retPwd
->data
== NULL
) {
592 PORT_Memcpy(retPwd
->data
, salt
->data
, salt
->len
);
593 PORT_Memcpy((retPwd
->data
+ salt
->len
), uniPwd
.data
, uniPwd
.len
);
595 SECITEM_ZfreeItem(&uniPwd
, PR_FALSE
);
600 PORT_SetError(SEC_ERROR_NO_MEMORY
);
601 SECITEM_ZfreeItem(&uniPwd
, PR_FALSE
);
605 /* appends a shrouded key to a key bag. this is used for exporting
606 * to store externally wrapped keys. it is used when importing to convert
610 sec_pkcs12_append_shrouded_key(SEC_PKCS12BaggageItem
*bag
,
611 SEC_PKCS12ESPVKItem
*espvk
)
614 void *mark
= NULL
, *dummy
= NULL
;
616 if((bag
== NULL
) || (espvk
== NULL
))
619 mark
= PORT_ArenaMark(bag
->poolp
);
622 size
= (bag
->nEspvks
+ 1) * sizeof(SEC_PKCS12ESPVKItem
*);
623 dummy
= (SEC_PKCS12ESPVKItem
**)PORT_ArenaGrow(bag
->poolp
,
625 size
+ sizeof(SEC_PKCS12ESPVKItem
*));
626 bag
->espvks
= (SEC_PKCS12ESPVKItem
**)dummy
;
628 PORT_SetError(SEC_ERROR_NO_MEMORY
);
632 bag
->espvks
[bag
->nEspvks
] = espvk
;
634 bag
->espvks
[bag
->nEspvks
] = NULL
;
636 PORT_ArenaUnmark(bag
->poolp
, mark
);
640 PORT_ArenaRelease(bag
->poolp
, mark
);
644 /* search a certificate list for a nickname, a thumbprint, or both
645 * within a certificate bag. if the certificate could not be
646 * found or an error occurs, NULL is returned;
648 static SEC_PKCS12CertAndCRL
*
649 sec_pkcs12_find_cert_in_certbag(SEC_PKCS12CertAndCRLBag
*certbag
,
650 SECItem
*nickname
, SGNDigestInfo
*thumbprint
)
652 PRBool search_both
= PR_FALSE
, search_nickname
= PR_FALSE
;
655 if((certbag
== NULL
) || ((nickname
== NULL
) && (thumbprint
== NULL
))) {
659 if(thumbprint
&& nickname
) {
660 search_both
= PR_TRUE
;
664 search_nickname
= PR_TRUE
;
669 while(certbag
->certAndCRLs
[i
] != NULL
) {
670 SEC_PKCS12CertAndCRL
*cert
= certbag
->certAndCRLs
[i
];
672 if(SECOID_FindOIDTag(&cert
->BagID
) == SEC_OID_PKCS12_X509_CERT_CRL_BAG
) {
674 /* check nicknames */
675 if(search_nickname
) {
676 if(SECITEM_CompareItem(nickname
, &cert
->nickname
) == SECEqual
) {
680 /* check thumbprints */
681 SECItem
**derCertList
;
683 /* get pointer to certificate list, does not need to
684 * be freed since it is within the arena which will
687 derCertList
= SEC_PKCS7GetCertificateList(&cert
->value
.x509
->certOrCRL
);
689 if(derCertList
!= NULL
) {
690 while(derCertList
[j
] != NULL
) {
693 di
= sec_pkcs12_compute_thumbprint(derCertList
[j
]);
695 eq
= SGN_CompareDigestInfo(thumbprint
, di
);
696 SGN_DestroyDigestInfo(di
);
698 /* copy the derCert for later reference */
699 cert
->value
.x509
->derLeafCert
= derCertList
[j
];
703 /* an error occurred */
716 search_both
= PR_FALSE
;
717 search_nickname
= PR_FALSE
;
724 /* search a key list for a nickname, a thumbprint, or both
725 * within a key bag. if the key could not be
726 * found or an error occurs, NULL is returned;
728 static SEC_PKCS12PrivateKey
*
729 sec_pkcs12_find_key_in_keybag(SEC_PKCS12PrivateKeyBag
*keybag
,
730 SECItem
*nickname
, SGNDigestInfo
*thumbprint
)
732 PRBool search_both
= PR_FALSE
, search_nickname
= PR_FALSE
;
735 if((keybag
== NULL
) || ((nickname
== NULL
) && (thumbprint
== NULL
))) {
739 if(keybag
->privateKeys
== NULL
) {
743 if(thumbprint
&& nickname
) {
744 search_both
= PR_TRUE
;
748 search_nickname
= PR_TRUE
;
753 while(keybag
->privateKeys
[i
] != NULL
) {
754 SEC_PKCS12PrivateKey
*key
= keybag
->privateKeys
[i
];
756 /* check nicknames */
757 if(search_nickname
) {
758 if(SECITEM_CompareItem(nickname
, &key
->pvkData
.nickname
) == SECEqual
) {
763 SGNDigestInfo
**assocCerts
= key
->pvkData
.assocCerts
;
764 if((assocCerts
== NULL
) || (assocCerts
[0] == NULL
)) {
769 while(assocCerts
[j
] != NULL
) {
771 eq
= SGN_CompareDigestInfo(thumbprint
, assocCerts
[j
]);
782 search_both
= PR_FALSE
;
783 search_nickname
= PR_FALSE
;
790 /* seach the safe first then try the baggage bag
791 * safe and bag contain certs and keys to search
792 * objType is the object type to look for
793 * bagType is the type of bag that was found by sec_pkcs12_find_object
794 * index is the entity in safe->safeContents or bag->unencSecrets which
796 * nickname and thumbprint are the search criteria
798 * a return of null indicates no match
801 sec_pkcs12_try_find(SEC_PKCS12SafeContents
*safe
,
802 SEC_PKCS12BaggageItem
*bag
,
803 SECOidTag objType
, SECOidTag bagType
, int index
,
804 SECItem
*nickname
, SGNDigestInfo
*thumbprint
)
809 if((safe
== NULL
) && (bag
== NULL
)) {
813 searchSafe
= (safe
== NULL
? PR_FALSE
: PR_TRUE
);
815 case SEC_OID_PKCS12_CERT_AND_CRL_BAG_ID
:
816 if(objType
== bagType
) {
817 SEC_PKCS12CertAndCRLBag
*certBag
;
820 certBag
= safe
->contents
[i
]->safeContent
.certAndCRLBag
;
822 certBag
= bag
->unencSecrets
[i
]->safeContent
.certAndCRLBag
;
824 return sec_pkcs12_find_cert_in_certbag(certBag
, nickname
,
828 case SEC_OID_PKCS12_KEY_BAG_ID
:
829 if(objType
== bagType
) {
830 SEC_PKCS12PrivateKeyBag
*keyBag
;
833 keyBag
= safe
->contents
[i
]->safeContent
.keyBag
;
835 keyBag
= bag
->unencSecrets
[i
]->safeContent
.keyBag
;
837 return sec_pkcs12_find_key_in_keybag(keyBag
, nickname
,
848 /* searches both the baggage and the safe areas looking for
849 * object of specified type matching either the nickname or the
850 * thumbprint specified.
852 * safe and baggage store certs and keys
853 * objType is the OID for the bag type to be searched:
854 * SEC_OID_PKCS12_KEY_BAG_ID, or
855 * SEC_OID_PKCS12_CERT_AND_CRL_BAG_ID
856 * nickname and thumbprint are the search criteria
858 * if no match found, NULL returned and error set
861 sec_pkcs12_find_object(SEC_PKCS12SafeContents
*safe
,
862 SEC_PKCS12Baggage
*baggage
,
865 SGNDigestInfo
*thumbprint
)
870 if(((safe
== NULL
) && (thumbprint
== NULL
)) ||
871 ((nickname
== NULL
) && (thumbprint
== NULL
))) {
876 if((safe
!= NULL
) && (safe
->contents
!= NULL
)) {
877 while(safe
->contents
[i
] != NULL
) {
878 SECOidTag bagType
= SECOID_FindOIDTag(&safe
->contents
[i
]->safeBagType
);
879 retItem
= sec_pkcs12_try_find(safe
, NULL
, objType
, bagType
, i
,
880 nickname
, thumbprint
);
881 if(retItem
!= NULL
) {
888 if((baggage
!= NULL
) && (baggage
->bags
!= NULL
)) {
890 while(baggage
->bags
[i
] != NULL
) {
891 SEC_PKCS12BaggageItem
*xbag
= baggage
->bags
[i
];
893 if(xbag
->unencSecrets
!= NULL
) {
894 while(xbag
->unencSecrets
[j
] != NULL
) {
896 bagType
= SECOID_FindOIDTag(&xbag
->unencSecrets
[j
]->safeBagType
);
897 retItem
= sec_pkcs12_try_find(NULL
, xbag
, objType
, bagType
,
898 j
, nickname
, thumbprint
);
899 if(retItem
!= NULL
) {
909 PORT_SetError(SEC_ERROR_PKCS12_UNABLE_TO_LOCATE_OBJECT_BY_NAME
);
913 /* this function converts a password to unicode and encures that the
914 * required double 0 byte be placed at the end of the string
917 sec_pkcs12_convert_item_to_unicode(PRArenaPool
*arena
, SECItem
*dest
,
918 SECItem
*src
, PRBool zeroTerm
,
919 PRBool asciiConvert
, PRBool toUnicode
)
921 PRBool success
= PR_FALSE
;
923 PORT_SetError(SEC_ERROR_INVALID_ARGS
);
927 dest
->len
= src
->len
* 3 + 2;
929 dest
->data
= (unsigned char*)PORT_ArenaZAlloc(arena
, dest
->len
);
931 dest
->data
= (unsigned char*)PORT_ZAlloc(dest
->len
);
940 success
= PORT_UCS2_UTF8Conversion(toUnicode
, src
->data
, src
->len
, dest
->data
,
941 dest
->len
, &dest
->len
);
943 #ifndef IS_LITTLE_ENDIAN
944 PRBool swapUnicode
= PR_FALSE
;
946 PRBool swapUnicode
= PR_TRUE
;
948 success
= PORT_UCS2_ASCIIConversion(toUnicode
, src
->data
, src
->len
, dest
->data
,
949 dest
->len
, &dest
->len
, swapUnicode
);
954 PORT_Free(dest
->data
);
961 if((dest
->data
[dest
->len
-1] || dest
->data
[dest
->len
-2]) && zeroTerm
) {
962 if(dest
->len
+ 2 > 3 * src
->len
) {
964 dest
->data
= (unsigned char*)PORT_ArenaGrow(arena
,
965 dest
->data
, dest
->len
,
968 dest
->data
= (unsigned char*)PORT_Realloc(dest
->data
,
977 dest
->data
[dest
->len
-1] = dest
->data
[dest
->len
-2] = 0;
983 /* pkcs 12 templates */
984 static const SEC_ASN1TemplateChooserPtr sec_pkcs12_shroud_chooser
=
985 sec_pkcs12_choose_shroud_type
;
987 const SEC_ASN1Template SEC_PKCS12CodedSafeBagTemplate
[] =
989 { SEC_ASN1_SEQUENCE
, 0, NULL
, sizeof(SEC_PKCS12SafeBag
) },
990 { SEC_ASN1_OBJECT_ID
, offsetof(SEC_PKCS12SafeBag
, safeBagType
) },
991 { SEC_ASN1_ANY
, offsetof(SEC_PKCS12SafeBag
, derSafeContent
) },
995 const SEC_ASN1Template SEC_PKCS12CodedCertBagTemplate
[] =
997 { SEC_ASN1_SEQUENCE
, 0, NULL
, sizeof(SEC_PKCS12CertAndCRL
) },
998 { SEC_ASN1_OBJECT_ID
, offsetof(SEC_PKCS12CertAndCRL
, BagID
) },
999 { SEC_ASN1_ANY
, offsetof(SEC_PKCS12CertAndCRL
, derValue
) },
1003 const SEC_ASN1Template SEC_PKCS12CodedCertAndCRLBagTemplate
[] =
1005 { SEC_ASN1_SET_OF
, offsetof(SEC_PKCS12CertAndCRLBag
, certAndCRLs
),
1006 SEC_PKCS12CodedCertBagTemplate
},
1009 const SEC_ASN1Template SEC_PKCS12ESPVKItemTemplate_OLD
[] =
1011 { SEC_ASN1_SEQUENCE
, 0, NULL
, sizeof(SEC_PKCS12ESPVKItem
) },
1012 { SEC_ASN1_OBJECT_ID
, offsetof(SEC_PKCS12ESPVKItem
, espvkOID
) },
1013 { SEC_ASN1_INLINE
, offsetof(SEC_PKCS12ESPVKItem
, espvkData
),
1014 SEC_PKCS12PVKSupportingDataTemplate_OLD
},
1015 { SEC_ASN1_EXPLICIT
| SEC_ASN1_CONSTRUCTED
| SEC_ASN1_CONTEXT_SPECIFIC
|
1016 SEC_ASN1_DYNAMIC
| 0, offsetof(SEC_PKCS12ESPVKItem
, espvkCipherText
),
1017 &sec_pkcs12_shroud_chooser
},
1021 const SEC_ASN1Template SEC_PKCS12ESPVKItemTemplate
[] =
1023 { SEC_ASN1_SEQUENCE
, 0, NULL
, sizeof(SEC_PKCS12ESPVKItem
) },
1024 { SEC_ASN1_OBJECT_ID
, offsetof(SEC_PKCS12ESPVKItem
, espvkOID
) },
1025 { SEC_ASN1_INLINE
, offsetof(SEC_PKCS12ESPVKItem
, espvkData
),
1026 SEC_PKCS12PVKSupportingDataTemplate
},
1027 { SEC_ASN1_EXPLICIT
| SEC_ASN1_CONSTRUCTED
| SEC_ASN1_CONTEXT_SPECIFIC
|
1028 SEC_ASN1_DYNAMIC
| 0, offsetof(SEC_PKCS12ESPVKItem
, espvkCipherText
),
1029 &sec_pkcs12_shroud_chooser
},
1033 const SEC_ASN1Template SEC_PKCS12PVKAdditionalDataTemplate
[] =
1035 { SEC_ASN1_SEQUENCE
, 0, NULL
, sizeof(SEC_PKCS12PVKAdditionalData
) },
1036 { SEC_ASN1_OBJECT_ID
,
1037 offsetof(SEC_PKCS12PVKAdditionalData
, pvkAdditionalType
) },
1038 { SEC_ASN1_CONSTRUCTED
| SEC_ASN1_CONTEXT_SPECIFIC
| 0,
1039 offsetof(SEC_PKCS12PVKAdditionalData
, pvkAdditionalContent
) },
1043 const SEC_ASN1Template SEC_PKCS12PVKSupportingDataTemplate_OLD
[] =
1045 { SEC_ASN1_SEQUENCE
, 0, NULL
, sizeof(SEC_PKCS12PVKSupportingData
) },
1046 { SEC_ASN1_SET_OF
| SEC_ASN1_XTRN
,
1047 offsetof(SEC_PKCS12PVKSupportingData
, assocCerts
),
1048 SEC_ASN1_SUB(sgn_DigestInfoTemplate
) },
1049 { SEC_ASN1_OPTIONAL
| SEC_ASN1_BOOLEAN
,
1050 offsetof(SEC_PKCS12PVKSupportingData
, regenerable
) },
1051 { SEC_ASN1_PRINTABLE_STRING
,
1052 offsetof(SEC_PKCS12PVKSupportingData
, nickname
) },
1053 { SEC_ASN1_ANY
| SEC_ASN1_OPTIONAL
,
1054 offsetof(SEC_PKCS12PVKSupportingData
, pvkAdditionalDER
) },
1058 const SEC_ASN1Template SEC_PKCS12PVKSupportingDataTemplate
[] =
1060 { SEC_ASN1_SEQUENCE
, 0, NULL
, sizeof(SEC_PKCS12PVKSupportingData
) },
1061 { SEC_ASN1_SET_OF
| SEC_ASN1_XTRN
,
1062 offsetof(SEC_PKCS12PVKSupportingData
, assocCerts
),
1063 SEC_ASN1_SUB(sgn_DigestInfoTemplate
) },
1064 { SEC_ASN1_OPTIONAL
| SEC_ASN1_BOOLEAN
,
1065 offsetof(SEC_PKCS12PVKSupportingData
, regenerable
) },
1066 { SEC_ASN1_BMP_STRING
,
1067 offsetof(SEC_PKCS12PVKSupportingData
, uniNickName
) },
1068 { SEC_ASN1_ANY
| SEC_ASN1_OPTIONAL
,
1069 offsetof(SEC_PKCS12PVKSupportingData
, pvkAdditionalDER
) },
1073 const SEC_ASN1Template SEC_PKCS12BaggageItemTemplate
[] =
1075 { SEC_ASN1_SEQUENCE
, 0, NULL
, sizeof(SEC_PKCS12BaggageItem
) },
1076 { SEC_ASN1_SET_OF
, offsetof(SEC_PKCS12BaggageItem
, espvks
),
1077 SEC_PKCS12ESPVKItemTemplate
},
1078 { SEC_ASN1_SET_OF
, offsetof(SEC_PKCS12BaggageItem
, unencSecrets
),
1079 SEC_PKCS12SafeBagTemplate
},
1080 /*{ SEC_ASN1_SET_OF, offsetof(SEC_PKCS12BaggageItem, unencSecrets),
1081 SEC_PKCS12CodedSafeBagTemplate }, */
1085 const SEC_ASN1Template SEC_PKCS12BaggageTemplate
[] =
1087 { SEC_ASN1_SET_OF
, offsetof(SEC_PKCS12Baggage
, bags
),
1088 SEC_PKCS12BaggageItemTemplate
},
1091 const SEC_ASN1Template SEC_PKCS12BaggageTemplate_OLD
[] =
1093 { SEC_ASN1_SET_OF
, offsetof(SEC_PKCS12Baggage_OLD
, espvks
),
1094 SEC_PKCS12ESPVKItemTemplate_OLD
},
1097 static const SEC_ASN1TemplateChooserPtr sec_pkcs12_bag_chooser
=
1098 sec_pkcs12_choose_bag_type
;
1100 static const SEC_ASN1TemplateChooserPtr sec_pkcs12_bag_chooser_old
=
1101 sec_pkcs12_choose_bag_type_old
;
1103 const SEC_ASN1Template SEC_PKCS12SafeBagTemplate_OLD
[] =
1105 { SEC_ASN1_SEQUENCE
, 0, NULL
, sizeof(SEC_PKCS12SafeBag
) },
1106 { SEC_ASN1_OBJECT_ID
, offsetof(SEC_PKCS12SafeBag
, safeBagType
) },
1107 { SEC_ASN1_DYNAMIC
| SEC_ASN1_CONSTRUCTED
| SEC_ASN1_EXPLICIT
|
1108 SEC_ASN1_CONTEXT_SPECIFIC
| 0,
1109 offsetof(SEC_PKCS12SafeBag
, safeContent
),
1110 &sec_pkcs12_bag_chooser_old
},
1114 const SEC_ASN1Template SEC_PKCS12SafeBagTemplate
[] =
1116 { SEC_ASN1_SEQUENCE
, 0, NULL
, sizeof(SEC_PKCS12SafeBag
) },
1117 { SEC_ASN1_OBJECT_ID
, offsetof(SEC_PKCS12SafeBag
, safeBagType
) },
1118 { SEC_ASN1_DYNAMIC
| SEC_ASN1_POINTER
,
1119 offsetof(SEC_PKCS12SafeBag
, safeContent
),
1120 &sec_pkcs12_bag_chooser
},
1121 { SEC_ASN1_OPTIONAL
| SEC_ASN1_BMP_STRING
,
1122 offsetof(SEC_PKCS12SafeBag
, uniSafeBagName
) },
1126 const SEC_ASN1Template SEC_PKCS12SafeContentsTemplate_OLD
[] =
1129 offsetof(SEC_PKCS12SafeContents
, contents
),
1130 SEC_PKCS12SafeBagTemplate_OLD
}
1133 const SEC_ASN1Template SEC_PKCS12SafeContentsTemplate
[] =
1136 offsetof(SEC_PKCS12SafeContents
, contents
),
1137 SEC_PKCS12SafeBagTemplate
} /* here */
1140 const SEC_ASN1Template SEC_PKCS12PrivateKeyTemplate
[] =
1142 { SEC_ASN1_SEQUENCE
, 0, NULL
, sizeof(SEC_PKCS12PrivateKey
) },
1143 { SEC_ASN1_INLINE
, offsetof(SEC_PKCS12PrivateKey
, pvkData
),
1144 SEC_PKCS12PVKSupportingDataTemplate
},
1145 { SEC_ASN1_INLINE
| SEC_ASN1_XTRN
,
1146 offsetof(SEC_PKCS12PrivateKey
, pkcs8data
),
1147 SEC_ASN1_SUB(SECKEY_PrivateKeyInfoTemplate
) },
1151 const SEC_ASN1Template SEC_PKCS12PrivateKeyBagTemplate
[] =
1153 { SEC_ASN1_SEQUENCE
, 0, NULL
, sizeof(SEC_PKCS12PrivateKeyBag
) },
1154 { SEC_ASN1_SET_OF
, offsetof(SEC_PKCS12PrivateKeyBag
, privateKeys
),
1155 SEC_PKCS12PrivateKeyTemplate
},
1159 const SEC_ASN1Template SEC_PKCS12X509CertCRLTemplate_OLD
[] =
1161 { SEC_ASN1_SEQUENCE
, 0, NULL
, sizeof(SEC_PKCS12X509CertCRL
) },
1162 { SEC_ASN1_INLINE
, offsetof(SEC_PKCS12X509CertCRL
, certOrCRL
),
1163 sec_PKCS7ContentInfoTemplate
},
1164 { SEC_ASN1_INLINE
| SEC_ASN1_XTRN
,
1165 offsetof(SEC_PKCS12X509CertCRL
, thumbprint
),
1166 SEC_ASN1_SUB(sgn_DigestInfoTemplate
) },
1170 const SEC_ASN1Template SEC_PKCS12X509CertCRLTemplate
[] =
1172 { SEC_ASN1_SEQUENCE
, 0, NULL
, sizeof(SEC_PKCS12X509CertCRL
) },
1173 { SEC_ASN1_INLINE
, offsetof(SEC_PKCS12X509CertCRL
, certOrCRL
),
1174 sec_PKCS7ContentInfoTemplate
},
1178 const SEC_ASN1Template SEC_PKCS12SDSICertTemplate
[] =
1180 { SEC_ASN1_SEQUENCE
, 0, NULL
, sizeof(SEC_PKCS12X509CertCRL
) },
1181 { SEC_ASN1_IA5_STRING
, offsetof(SEC_PKCS12SDSICert
, value
) },
1185 static const SEC_ASN1TemplateChooserPtr sec_pkcs12_cert_crl_chooser_old
=
1186 sec_pkcs12_choose_cert_crl_type_old
;
1188 static const SEC_ASN1TemplateChooserPtr sec_pkcs12_cert_crl_chooser
=
1189 sec_pkcs12_choose_cert_crl_type
;
1191 const SEC_ASN1Template SEC_PKCS12CertAndCRLTemplate_OLD
[] =
1193 { SEC_ASN1_SEQUENCE
, 0, NULL
, sizeof(SEC_PKCS12CertAndCRL
) },
1194 { SEC_ASN1_OBJECT_ID
, offsetof(SEC_PKCS12CertAndCRL
, BagID
) },
1195 { SEC_ASN1_CONTEXT_SPECIFIC
| SEC_ASN1_EXPLICIT
|
1196 SEC_ASN1_DYNAMIC
| SEC_ASN1_CONSTRUCTED
| 0,
1197 offsetof(SEC_PKCS12CertAndCRL
, value
),
1198 &sec_pkcs12_cert_crl_chooser_old
},
1202 const SEC_ASN1Template SEC_PKCS12CertAndCRLTemplate
[] =
1204 { SEC_ASN1_SEQUENCE
, 0, NULL
, sizeof(SEC_PKCS12CertAndCRL
) },
1205 { SEC_ASN1_OBJECT_ID
, offsetof(SEC_PKCS12CertAndCRL
, BagID
) },
1206 { SEC_ASN1_DYNAMIC
| SEC_ASN1_CONSTRUCTED
| SEC_ASN1_EXPLICIT
|
1207 SEC_ASN1_CONTEXT_SPECIFIC
| 0,
1208 offsetof(SEC_PKCS12CertAndCRL
, value
),
1209 &sec_pkcs12_cert_crl_chooser
},
1213 const SEC_ASN1Template SEC_PKCS12CertAndCRLBagTemplate
[] =
1215 { SEC_ASN1_SET_OF
, offsetof(SEC_PKCS12CertAndCRLBag
, certAndCRLs
),
1216 SEC_PKCS12CertAndCRLTemplate
},
1219 const SEC_ASN1Template SEC_PKCS12CertAndCRLBagTemplate_OLD
[] =
1221 { SEC_ASN1_SEQUENCE
, 0, NULL
, sizeof(SEC_PKCS12CertAndCRLBag
) },
1222 { SEC_ASN1_SET_OF
, offsetof(SEC_PKCS12CertAndCRLBag
, certAndCRLs
),
1223 SEC_PKCS12CertAndCRLTemplate_OLD
},
1227 const SEC_ASN1Template SEC_PKCS12SecretAdditionalTemplate
[] =
1229 { SEC_ASN1_SEQUENCE
, 0, NULL
, sizeof(SEC_PKCS12SecretAdditional
) },
1230 { SEC_ASN1_OBJECT_ID
,
1231 offsetof(SEC_PKCS12SecretAdditional
, secretAdditionalType
) },
1232 { SEC_ASN1_CONTEXT_SPECIFIC
| SEC_ASN1_EXPLICIT
,
1233 offsetof(SEC_PKCS12SecretAdditional
, secretAdditionalContent
) },
1237 const SEC_ASN1Template SEC_PKCS12SecretTemplate
[] =
1239 { SEC_ASN1_SEQUENCE
, 0, NULL
, sizeof(SEC_PKCS12Secret
) },
1240 { SEC_ASN1_BMP_STRING
, offsetof(SEC_PKCS12Secret
, uniSecretName
) },
1241 { SEC_ASN1_ANY
, offsetof(SEC_PKCS12Secret
, value
) },
1242 { SEC_ASN1_INLINE
| SEC_ASN1_OPTIONAL
,
1243 offsetof(SEC_PKCS12Secret
, secretAdditional
),
1244 SEC_PKCS12SecretAdditionalTemplate
},
1248 const SEC_ASN1Template SEC_PKCS12SecretItemTemplate
[] =
1250 { SEC_ASN1_SEQUENCE
, 0, NULL
, sizeof(SEC_PKCS12Secret
) },
1251 { SEC_ASN1_INLINE
| SEC_ASN1_CONTEXT_SPECIFIC
| 0,
1252 offsetof(SEC_PKCS12SecretItem
, secret
), SEC_PKCS12SecretTemplate
},
1253 { SEC_ASN1_INLINE
| SEC_ASN1_CONTEXT_SPECIFIC
| 1,
1254 offsetof(SEC_PKCS12SecretItem
, subFolder
), SEC_PKCS12SafeBagTemplate
},
1258 const SEC_ASN1Template SEC_PKCS12SecretBagTemplate
[] =
1260 { SEC_ASN1_SET_OF
, offsetof(SEC_PKCS12SecretBag
, secrets
),
1261 SEC_PKCS12SecretItemTemplate
},
1264 const SEC_ASN1Template SEC_PKCS12MacDataTemplate
[] =
1266 { SEC_ASN1_SEQUENCE
, 0, NULL
, sizeof(SEC_PKCS12PFXItem
) },
1267 { SEC_ASN1_INLINE
| SEC_ASN1_XTRN
, offsetof(SEC_PKCS12MacData
, safeMac
),
1268 SEC_ASN1_SUB(sgn_DigestInfoTemplate
) },
1269 { SEC_ASN1_BIT_STRING
, offsetof(SEC_PKCS12MacData
, macSalt
) },
1273 const SEC_ASN1Template SEC_PKCS12PFXItemTemplate
[] =
1275 { SEC_ASN1_SEQUENCE
, 0, NULL
, sizeof(SEC_PKCS12PFXItem
) },
1276 { SEC_ASN1_OPTIONAL
|
1277 SEC_ASN1_CONSTRUCTED
| SEC_ASN1_CONTEXT_SPECIFIC
| 0,
1278 offsetof(SEC_PKCS12PFXItem
, macData
), SEC_PKCS12MacDataTemplate
},
1279 { SEC_ASN1_CONSTRUCTED
| SEC_ASN1_CONTEXT_SPECIFIC
| 1,
1280 offsetof(SEC_PKCS12PFXItem
, authSafe
),
1281 sec_PKCS7ContentInfoTemplate
},
1285 const SEC_ASN1Template SEC_PKCS12PFXItemTemplate_OLD
[] =
1287 { SEC_ASN1_SEQUENCE
, 0, NULL
, sizeof(SEC_PKCS12PFXItem
) },
1288 { SEC_ASN1_OPTIONAL
|
1289 SEC_ASN1_CONSTRUCTED
| SEC_ASN1_CONTEXT_SPECIFIC
| SEC_ASN1_XTRN
| 0,
1290 offsetof(SEC_PKCS12PFXItem
, old_safeMac
),
1291 SEC_ASN1_SUB(sgn_DigestInfoTemplate
) },
1292 { SEC_ASN1_OPTIONAL
| SEC_ASN1_BIT_STRING
,
1293 offsetof(SEC_PKCS12PFXItem
, old_macSalt
) },
1294 { SEC_ASN1_CONSTRUCTED
| SEC_ASN1_CONTEXT_SPECIFIC
| 1,
1295 offsetof(SEC_PKCS12PFXItem
, authSafe
),
1296 sec_PKCS7ContentInfoTemplate
},
1300 const SEC_ASN1Template SEC_PKCS12AuthenticatedSafeTemplate
[] =
1302 { SEC_ASN1_SEQUENCE
, 0, NULL
, sizeof(SEC_PKCS12AuthenticatedSafe
) },
1303 { SEC_ASN1_OPTIONAL
| SEC_ASN1_INTEGER
,
1304 offsetof(SEC_PKCS12AuthenticatedSafe
, version
) },
1305 { SEC_ASN1_OPTIONAL
| SEC_ASN1_OBJECT_ID
,
1306 offsetof(SEC_PKCS12AuthenticatedSafe
, transportMode
) },
1307 { SEC_ASN1_BIT_STRING
| SEC_ASN1_OPTIONAL
,
1308 offsetof(SEC_PKCS12AuthenticatedSafe
, privacySalt
) },
1309 { SEC_ASN1_OPTIONAL
| SEC_ASN1_SET_OF
,
1310 offsetof(SEC_PKCS12AuthenticatedSafe
, baggage
.bags
),
1311 SEC_PKCS12BaggageItemTemplate
},
1313 offsetof(SEC_PKCS12AuthenticatedSafe
, safe
),
1314 sec_PKCS7ContentInfoTemplate
},
1318 const SEC_ASN1Template SEC_PKCS12AuthenticatedSafeTemplate_OLD
[] =
1320 { SEC_ASN1_SEQUENCE
, 0, NULL
, sizeof(SEC_PKCS12AuthenticatedSafe
) },
1321 { SEC_ASN1_OPTIONAL
| SEC_ASN1_INTEGER
,
1322 offsetof(SEC_PKCS12AuthenticatedSafe
, version
) },
1323 { SEC_ASN1_OPTIONAL
| SEC_ASN1_INTEGER
,
1324 offsetof(SEC_PKCS12AuthenticatedSafe
, transportMode
) },
1325 { SEC_ASN1_BIT_STRING
,
1326 offsetof(SEC_PKCS12AuthenticatedSafe
, privacySalt
) },
1327 { SEC_ASN1_OPTIONAL
| SEC_ASN1_CONSTRUCTED
|
1328 SEC_ASN1_CONTEXT_SPECIFIC
| 0,
1329 offsetof(SEC_PKCS12AuthenticatedSafe
, old_baggage
),
1330 SEC_PKCS12BaggageTemplate_OLD
},
1331 { SEC_ASN1_CONSTRUCTED
| SEC_ASN1_CONTEXT_SPECIFIC
| 1,
1332 offsetof(SEC_PKCS12AuthenticatedSafe
, old_safe
),
1333 sec_PKCS7ContentInfoTemplate
},
1337 const SEC_ASN1Template SEC_PointerToPKCS12KeyBagTemplate
[] =
1339 { SEC_ASN1_POINTER
, 0, SEC_PKCS12PrivateKeyBagTemplate
}
1342 const SEC_ASN1Template SEC_PointerToPKCS12CertAndCRLBagTemplate_OLD
[] =
1344 { SEC_ASN1_POINTER
, 0, SEC_PKCS12CertAndCRLBagTemplate_OLD
}
1347 const SEC_ASN1Template SEC_PointerToPKCS12CertAndCRLBagTemplate
[] =
1349 { SEC_ASN1_POINTER
, 0, SEC_PKCS12CertAndCRLBagTemplate
}
1352 const SEC_ASN1Template SEC_PointerToPKCS12SecretBagTemplate
[] =
1354 { SEC_ASN1_POINTER
, 0, SEC_PKCS12SecretBagTemplate
}
1357 const SEC_ASN1Template SEC_PointerToPKCS12X509CertCRLTemplate_OLD
[] =
1359 { SEC_ASN1_POINTER
, 0, SEC_PKCS12X509CertCRLTemplate_OLD
}
1362 const SEC_ASN1Template SEC_PointerToPKCS12X509CertCRLTemplate
[] =
1364 { SEC_ASN1_POINTER
, 0, SEC_PKCS12X509CertCRLTemplate
}
1367 const SEC_ASN1Template SEC_PointerToPKCS12SDSICertTemplate
[] =
1369 { SEC_ASN1_POINTER
, 0, SEC_PKCS12SDSICertTemplate
}