]> git.saurik.com Git - apple/security.git/blob - Security/libsecurity_keychain/lib/SecPkcs8Templates.h
Security-57031.40.6.tar.gz
[apple/security.git] / Security / libsecurity_keychain / lib / SecPkcs8Templates.h
1 /*
2 * Copyright (c) 2000-2004,2011,2014 Apple Inc. All Rights Reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24 /*
25 * SecPkcs8Templates.h - ASN1 templates for private keys in PKCS8 format.
26 */
27
28 #ifndef _SEC_PKCS8_TEMPLATES_H_
29 #define _SEC_PKCS8_TEMPLATES_H_
30
31 #include <Security/cssmtype.h>
32 #include <Security/x509defs.h>
33 #include <Security/secasn1t.h>
34
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38
39 /*
40 * This one is the AlgorithmID.Parameters field for PKCS5 v1.5.
41 * It looks mighty similar to pkcs-12PbeParams except that this
42 * one has a fixed salt size of 8 bytes (not that we enforce that
43 * at decode time).
44 */
45 typedef struct {
46 CSSM_DATA salt;
47 CSSM_DATA iterations;
48 } impExpPKCS5_PBE_Parameters;
49
50 extern const SecAsn1Template impExpPKCS5_PBE_ParametersTemplate[];
51
52 /*
53 * This is the AlgorithmID.Parameters of the keyDerivationFunc component
54 * of a PBES2-params. PKCS v2.0 only. We do not handle the CHOICE salt;
55 * only the specified flavor (as an OCTET STRING).
56 */
57 typedef struct {
58 CSSM_DATA salt;
59 CSSM_DATA iterationCount;
60 CSSM_DATA keyLengthInBytes; // optional
61 CSSM_OID prf; // optional, default algid-hmacWithSHA1
62 } impExpPKCS5_PBKDF2_Params;
63
64 extern const SecAsn1Template impExpPKCS5_PBKDF2_ParamsTemplate[];
65
66 /*
67 * AlgorithmID.Parameters for encryptionScheme component of of a PBES2-params.
68 * This one for RC2:
69 */
70 typedef struct {
71 CSSM_DATA version; // optional
72 CSSM_DATA iv; // 8 bytes
73 } impExpPKCS5_RC2Params;
74
75 extern const SecAsn1Template impExpPKCS5_RC2ParamsTemplate[];
76
77 /*
78 * This one for RC5.
79 */
80 typedef struct {
81 CSSM_DATA version; // not optional
82 CSSM_DATA rounds; // 8..127
83 CSSM_DATA blockSizeInBits; // 64 | 128
84 CSSM_DATA iv; // optional, default is all zeroes
85 } impExpPKCS5_RC5Params;
86
87 extern const SecAsn1Template impExpPKCS5_RC5ParamsTemplate[];
88
89 /*
90 * The top-level AlgID.Parameters for PKCS5 v2.0.
91 * keyDerivationFunc.Parameters is a impExpPKCS5_PBKDF2_Params.
92 * encryptionScheme.Parameters depends on the encryption algorithm:
93 *
94 * DES, 3DES: encryptionScheme.Parameters is an OCTET STRING containing the
95 * 8-byte IV.
96 * RC2: encryptionScheme.Parameters is impExpPKCS5_RC2Params.
97 * RC5: encryptionScheme.Parameters is impExpPKCS5_RC5Params.
98 */
99 typedef struct {
100 CSSM_X509_ALGORITHM_IDENTIFIER keyDerivationFunc;
101 CSSM_X509_ALGORITHM_IDENTIFIER encryptionScheme;
102 } impExpPKCS5_PBES2_Params;
103
104 extern const SecAsn1Template impExpPKCS5_PBES2_ParamsTemplate[];
105
106 #ifdef __cplusplus
107 }
108 #endif
109
110 #endif /* _SEC_PKCS8_TEMPLATES_H_ */