michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef _P12T_H_ michael@0: #define _P12T_H_ michael@0: michael@0: #include "secoid.h" michael@0: #include "key.h" michael@0: #include "pkcs11.h" michael@0: #include "secpkcs7.h" michael@0: #include "secdig.h" /* for SGNDigestInfo */ michael@0: #include "pkcs12t.h" michael@0: michael@0: #define SEC_PKCS12_VERSION 3 michael@0: michael@0: /* structure declarations */ michael@0: typedef struct sec_PKCS12PFXItemStr sec_PKCS12PFXItem; michael@0: typedef struct sec_PKCS12MacDataStr sec_PKCS12MacData; michael@0: typedef struct sec_PKCS12AuthenticatedSafeStr sec_PKCS12AuthenticatedSafe; michael@0: typedef struct sec_PKCS12SafeContentsStr sec_PKCS12SafeContents; michael@0: typedef struct sec_PKCS12SafeBagStr sec_PKCS12SafeBag; michael@0: typedef struct sec_PKCS12PKCS8ShroudedKeyBagStr sec_PKCS12PKCS8ShroudedKeyBag; michael@0: typedef struct sec_PKCS12CertBagStr sec_PKCS12CertBag; michael@0: typedef struct sec_PKCS12CRLBagStr sec_PKCS12CRLBag; michael@0: typedef struct sec_PKCS12SecretBag sec_PKCS12SecretBag; michael@0: typedef struct sec_PKCS12AttributeStr sec_PKCS12Attribute; michael@0: michael@0: struct sec_PKCS12CertBagStr { michael@0: /* what type of cert is stored? */ michael@0: SECItem bagID; michael@0: michael@0: /* certificate information */ michael@0: union { michael@0: SECItem x509Cert; michael@0: SECItem SDSICert; michael@0: } value; michael@0: }; michael@0: michael@0: struct sec_PKCS12CRLBagStr { michael@0: /* what type of cert is stored? */ michael@0: SECItem bagID; michael@0: michael@0: /* certificate information */ michael@0: union { michael@0: SECItem x509CRL; michael@0: } value; michael@0: }; michael@0: michael@0: struct sec_PKCS12SecretBag { michael@0: /* what type of secret? */ michael@0: SECItem secretType; michael@0: michael@0: /* secret information. ssshhhh be vewy vewy quiet. */ michael@0: SECItem secretContent; michael@0: }; michael@0: michael@0: struct sec_PKCS12AttributeStr { michael@0: SECItem attrType; michael@0: SECItem **attrValue; michael@0: }; michael@0: michael@0: struct sec_PKCS12SafeBagStr { michael@0: michael@0: /* What type of bag are we using? */ michael@0: SECItem safeBagType; michael@0: michael@0: /* Dependent upon the type of bag being used. */ michael@0: union { michael@0: SECKEYPrivateKeyInfo *pkcs8KeyBag; michael@0: SECKEYEncryptedPrivateKeyInfo *pkcs8ShroudedKeyBag; michael@0: sec_PKCS12CertBag *certBag; michael@0: sec_PKCS12CRLBag *crlBag; michael@0: sec_PKCS12SecretBag *secretBag; michael@0: sec_PKCS12SafeContents *safeContents; michael@0: } safeBagContent; michael@0: michael@0: sec_PKCS12Attribute **attribs; michael@0: michael@0: /* used locally */ michael@0: SECOidData *bagTypeTag; michael@0: PLArenaPool *arena; michael@0: unsigned int nAttribs; michael@0: michael@0: /* used for validation/importing */ michael@0: PRBool problem, noInstall, validated, hasKey, unused, installed; michael@0: int error; michael@0: michael@0: PRBool swapUnicodeBytes; michael@0: PK11SlotInfo *slot; michael@0: SECItem *pwitem; michael@0: PRBool oldBagType; michael@0: SECPKCS12TargetTokenCAs tokenCAs; michael@0: }; michael@0: michael@0: struct sec_PKCS12SafeContentsStr { michael@0: sec_PKCS12SafeBag **safeBags; michael@0: SECItem **encodedSafeBags; michael@0: michael@0: /* used locally */ michael@0: PLArenaPool *arena; michael@0: unsigned int bagCount; michael@0: }; michael@0: michael@0: struct sec_PKCS12MacDataStr { michael@0: SGNDigestInfo safeMac; michael@0: SECItem macSalt; michael@0: SECItem iter; michael@0: }; michael@0: michael@0: struct sec_PKCS12PFXItemStr { michael@0: michael@0: SECItem version; michael@0: michael@0: /* Content type will either be Data (password integrity mode) michael@0: * or signedData (public-key integrity mode) michael@0: */ michael@0: SEC_PKCS7ContentInfo *authSafe; michael@0: SECItem encodedAuthSafe; michael@0: michael@0: /* Only present in password integrity mode */ michael@0: sec_PKCS12MacData macData; michael@0: SECItem encodedMacData; michael@0: }; michael@0: michael@0: struct sec_PKCS12AuthenticatedSafeStr { michael@0: /* Content type will either be encryptedData (password privacy mode) michael@0: * or envelopedData (public-key privacy mode) michael@0: */ michael@0: SEC_PKCS7ContentInfo **safes; michael@0: SECItem **encodedSafes; michael@0: michael@0: /* used locally */ michael@0: unsigned int safeCount; michael@0: SECItem dummySafe; michael@0: }; michael@0: michael@0: extern const SEC_ASN1Template sec_PKCS12PFXItemTemplate[]; michael@0: extern const SEC_ASN1Template sec_PKCS12MacDataTemplate[]; michael@0: extern const SEC_ASN1Template sec_PKCS12AuthenticatedSafeTemplate[]; michael@0: extern const SEC_ASN1Template sec_PKCS12SafeContentsTemplate[]; michael@0: extern const SEC_ASN1Template sec_PKCS12SafeContentsDecodeTemplate[]; michael@0: extern const SEC_ASN1Template sec_PKCS12NestedSafeContentsDecodeTemplate[]; michael@0: extern const SEC_ASN1Template sec_PKCS12CertBagTemplate[]; michael@0: extern const SEC_ASN1Template sec_PKCS12CRLBagTemplate[]; michael@0: extern const SEC_ASN1Template sec_PKCS12SecretBagTemplate[]; michael@0: extern const SEC_ASN1Template sec_PKCS12PointerToCertBagTemplate[]; michael@0: extern const SEC_ASN1Template sec_PKCS12PointerToCRLBagTemplate[]; michael@0: extern const SEC_ASN1Template sec_PKCS12PointerToSecretBagTemplate[]; michael@0: extern const SEC_ASN1Template sec_PKCS12PointerToSafeContentsTemplate[]; michael@0: extern const SEC_ASN1Template sec_PKCS12AttributeTemplate[]; michael@0: extern const SEC_ASN1Template sec_PKCS12PointerToContentInfoTemplate[]; michael@0: extern const SEC_ASN1Template sec_PKCS12SafeBagTemplate[]; michael@0: michael@0: #endif