]> git.saurik.com Git - apple/security.git/blob - Security/libsecurity_keychain/lib/SecPkcs8Templates.cpp
Security-57031.40.6.tar.gz
[apple/security.git] / Security / libsecurity_keychain / lib / SecPkcs8Templates.cpp
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.cpp - ASN1 templates for private keys in PKCS8 format.
26 */
27
28 #include "SecPkcs8Templates.h"
29 #include <Security/keyTemplates.h>
30 #include <Security/secasn1t.h>
31 #include <security_asn1/prtypes.h>
32 #include <stddef.h>
33
34 const SecAsn1Template impExpPKCS5_PBE_ParametersTemplate[] = {
35 { SEC_ASN1_SEQUENCE,
36 0, NULL, sizeof(impExpPKCS5_PBE_Parameters) },
37 { SEC_ASN1_OCTET_STRING,
38 offsetof(impExpPKCS5_PBE_Parameters,salt) },
39 /* iterations is unsigned - right? */
40 { SEC_ASN1_INTEGER,
41 offsetof(impExpPKCS5_PBE_Parameters,iterations) },
42 { 0 }
43 };
44
45 const SecAsn1Template impExpPKCS5_PBKDF2_ParamsTemplate[] = {
46 { SEC_ASN1_SEQUENCE,
47 0, NULL, sizeof(impExpPKCS5_PBKDF2_Params) },
48 { SEC_ASN1_OCTET_STRING,
49 offsetof(impExpPKCS5_PBKDF2_Params,salt) },
50 /* iterations is unsigned - right? */
51 { SEC_ASN1_INTEGER,
52 offsetof(impExpPKCS5_PBKDF2_Params,iterationCount) },
53 { SEC_ASN1_INTEGER | SEC_ASN1_OPTIONAL,
54 offsetof(impExpPKCS5_PBKDF2_Params,keyLengthInBytes) },
55 { SEC_ASN1_OBJECT_ID | SEC_ASN1_OPTIONAL,
56 offsetof(impExpPKCS5_PBKDF2_Params,prf) },
57 { 0 }
58 };
59
60 const SecAsn1Template impExpPKCS5_RC2ParamsTemplate[] = {
61 { SEC_ASN1_SEQUENCE,
62 0, NULL, sizeof(impExpPKCS5_RC2Params) },
63 { SEC_ASN1_INTEGER | SEC_ASN1_OPTIONAL,
64 offsetof(impExpPKCS5_RC2Params,version) },
65 { SEC_ASN1_OCTET_STRING,
66 offsetof(impExpPKCS5_RC2Params,iv) },
67 { 0 }
68 };
69
70 const SecAsn1Template impExpPKCS5_RC5ParamsTemplate[] = {
71 { SEC_ASN1_SEQUENCE,
72 0, NULL, sizeof(impExpPKCS5_RC5Params) },
73 { SEC_ASN1_INTEGER,
74 offsetof(impExpPKCS5_RC5Params,version) },
75 { SEC_ASN1_INTEGER,
76 offsetof(impExpPKCS5_RC5Params,rounds) },
77 { SEC_ASN1_INTEGER,
78 offsetof(impExpPKCS5_RC5Params,blockSizeInBits) },
79 { SEC_ASN1_OCTET_STRING,
80 offsetof(impExpPKCS5_RC5Params,iv) },
81 { 0 }
82 };
83
84 const SecAsn1Template impExpPKCS5_PBES2_ParamsTemplate[] = {
85 { SEC_ASN1_SEQUENCE,
86 0, NULL, sizeof(impExpPKCS5_PBES2_Params) },
87 { SEC_ASN1_INLINE,
88 offsetof(impExpPKCS5_PBES2_Params,keyDerivationFunc),
89 kSecAsn1AlgorithmIDTemplate },
90 { SEC_ASN1_INLINE,
91 offsetof(impExpPKCS5_PBES2_Params,encryptionScheme),
92 kSecAsn1AlgorithmIDTemplate },
93 { 0 }
94 };