Back to index

lightning-sunbird  0.9+nobinonly
p12t.h
Go to the documentation of this file.
00001 /* ***** BEGIN LICENSE BLOCK *****
00002  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00003  *
00004  * The contents of this file are subject to the Mozilla Public License Version
00005  * 1.1 (the "License"); you may not use this file except in compliance with
00006  * the License. You may obtain a copy of the License at
00007  * http://www.mozilla.org/MPL/
00008  *
00009  * Software distributed under the License is distributed on an "AS IS" basis,
00010  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00011  * for the specific language governing rights and limitations under the
00012  * License.
00013  *
00014  * The Original Code is the Netscape security libraries.
00015  *
00016  * The Initial Developer of the Original Code is
00017  * Netscape Communications Corporation.
00018  * Portions created by the Initial Developer are Copyright (C) 1994-2000
00019  * the Initial Developer. All Rights Reserved.
00020  *
00021  * Contributor(s):
00022  *
00023  * Alternatively, the contents of this file may be used under the terms of
00024  * either the GNU General Public License Version 2 or later (the "GPL"), or
00025  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00026  * in which case the provisions of the GPL or the LGPL are applicable instead
00027  * of those above. If you wish to allow use of your version of this file only
00028  * under the terms of either the GPL or the LGPL, and not to allow others to
00029  * use your version of this file under the terms of the MPL, indicate your
00030  * decision by deleting the provisions above and replace them with the notice
00031  * and other provisions required by the GPL or the LGPL. If you do not delete
00032  * the provisions above, a recipient may use your version of this file under
00033  * the terms of any one of the MPL, the GPL or the LGPL.
00034  *
00035  * ***** END LICENSE BLOCK ***** */
00036 
00037 #ifndef _P12T_H_
00038 #define _P12T_H_
00039 
00040 #include "secoid.h"
00041 #include "key.h"
00042 #include "pkcs11.h"
00043 #include "secpkcs7.h"
00044 #include "secdig.h"  /* for SGNDigestInfo */
00045 #include "pkcs12t.h"
00046 
00047 #define SEC_PKCS12_VERSION  3
00048 
00049 /* structure declarations */
00050 typedef struct sec_PKCS12PFXItemStr sec_PKCS12PFXItem;
00051 typedef struct sec_PKCS12MacDataStr sec_PKCS12MacData;
00052 typedef struct sec_PKCS12AuthenticatedSafeStr sec_PKCS12AuthenticatedSafe;
00053 typedef struct sec_PKCS12SafeContentsStr sec_PKCS12SafeContents;
00054 typedef struct sec_PKCS12SafeBagStr sec_PKCS12SafeBag;
00055 typedef struct sec_PKCS12PKCS8ShroudedKeyBagStr sec_PKCS12PKCS8ShroudedKeyBag;
00056 typedef struct sec_PKCS12CertBagStr sec_PKCS12CertBag;
00057 typedef struct sec_PKCS12CRLBagStr sec_PKCS12CRLBag;
00058 typedef struct sec_PKCS12SecretBag sec_PKCS12SecretBag;
00059 typedef struct sec_PKCS12AttributeStr sec_PKCS12Attribute;
00060 
00061 struct sec_PKCS12CertBagStr {
00062     /* what type of cert is stored? */
00063     SECItem bagID;
00064 
00065     /* certificate information */
00066     union {
00067        SECItem x509Cert;
00068        SECItem SDSICert;
00069     } value;
00070 };
00071 
00072 struct sec_PKCS12CRLBagStr {
00073     /* what type of cert is stored? */
00074     SECItem bagID;
00075 
00076     /* certificate information */
00077     union {
00078        SECItem x509CRL;
00079     } value;
00080 };
00081 
00082 struct sec_PKCS12SecretBag {
00083     /* what type of secret? */
00084     SECItem secretType;
00085 
00086     /* secret information.  ssshhhh be vewy vewy quiet. */
00087     SECItem secretContent;
00088 };
00089 
00090 struct sec_PKCS12AttributeStr {
00091     SECItem attrType;
00092     SECItem **attrValue;
00093 };
00094 
00095 struct sec_PKCS12SafeBagStr {
00096 
00097     /* What type of bag are we using? */
00098     SECItem safeBagType;
00099 
00100     /* Dependent upon the type of bag being used. */
00101     union {
00102        SECKEYPrivateKeyInfo *pkcs8KeyBag;
00103        SECKEYEncryptedPrivateKeyInfo *pkcs8ShroudedKeyBag;
00104        sec_PKCS12CertBag *certBag;
00105        sec_PKCS12CRLBag *crlBag;
00106        sec_PKCS12SecretBag *secretBag;
00107        sec_PKCS12SafeContents *safeContents;
00108     } safeBagContent;
00109 
00110     sec_PKCS12Attribute **attribs;
00111 
00112     /* used locally */
00113     SECOidData *bagTypeTag;
00114     PRArenaPool *arena;
00115     unsigned int nAttribs;
00116 
00117     /* used for validation/importing */
00118     PRBool problem, noInstall, validated, hasKey, unused, installed;
00119     int error;
00120 
00121     PRBool swapUnicodeBytes;
00122     PK11SlotInfo *slot;
00123     SECItem *pwitem;
00124     PRBool oldBagType;
00125     SECPKCS12TargetTokenCAs tokenCAs;
00126 };
00127     
00128 struct sec_PKCS12SafeContentsStr {
00129     sec_PKCS12SafeBag **safeBags;
00130     SECItem **encodedSafeBags;
00131     
00132     /* used locally */
00133     PRArenaPool *arena;
00134     unsigned int bagCount;
00135 };
00136 
00137 struct sec_PKCS12MacDataStr {
00138     SGNDigestInfo safeMac;
00139     SECItem macSalt;
00140     SECItem iter;
00141 };
00142 
00143 struct sec_PKCS12PFXItemStr {
00144 
00145     SECItem version;
00146 
00147     /* Content type will either be Data (password integrity mode)
00148      * or signedData (public-key integrity mode)
00149      */
00150     SEC_PKCS7ContentInfo *authSafe;
00151     SECItem encodedAuthSafe;
00152 
00153     /* Only present in password integrity mode */
00154     sec_PKCS12MacData macData;
00155     SECItem encodedMacData;
00156 };
00157 
00158 struct sec_PKCS12AuthenticatedSafeStr {
00159     /* Content type will either be encryptedData (password privacy mode)
00160      * or envelopedData (public-key privacy mode)
00161      */
00162     SEC_PKCS7ContentInfo **safes;
00163     SECItem **encodedSafes;
00164 
00165     /* used locally */
00166     unsigned int safeCount;
00167     SECItem dummySafe;
00168 };
00169 
00170 extern const SEC_ASN1Template sec_PKCS12PFXItemTemplate[];
00171 extern const SEC_ASN1Template sec_PKCS12MacDataTemplate[];
00172 extern const SEC_ASN1Template sec_PKCS12AuthenticatedSafeTemplate[];
00173 extern const SEC_ASN1Template sec_PKCS12SafeContentsTemplate[];
00174 extern const SEC_ASN1Template sec_PKCS12SafeContentsDecodeTemplate[];
00175 extern const SEC_ASN1Template sec_PKCS12NestedSafeContentsDecodeTemplate[];
00176 extern const SEC_ASN1Template sec_PKCS12CertBagTemplate[];
00177 extern const SEC_ASN1Template sec_PKCS12CRLBagTemplate[];
00178 extern const SEC_ASN1Template sec_PKCS12SecretBagTemplate[];
00179 extern const SEC_ASN1Template sec_PKCS12PointerToCertBagTemplate[];
00180 extern const SEC_ASN1Template sec_PKCS12PointerToCRLBagTemplate[];
00181 extern const SEC_ASN1Template sec_PKCS12PointerToSecretBagTemplate[];
00182 extern const SEC_ASN1Template sec_PKCS12PointerToSafeContentsTemplate[];
00183 extern const SEC_ASN1Template sec_PKCS12AttributeTemplate[];
00184 extern const SEC_ASN1Template sec_PKCS12PointerToContentInfoTemplate[];
00185 extern const SEC_ASN1Template sec_PKCS12SafeBagTemplate[];
00186 
00187 #endif