Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Side by Side Diff: nss/lib/softoken/lowkey.c

Issue 1843333003: Update NSPR to 4.12 and NSS to 3.23 on iOS (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/nss.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* This Source Code Form is subject to the terms of the Mozilla Public 1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 #include "lowkeyi.h" 4 #include "lowkeyi.h"
5 #include "secoid.h" 5 #include "secoid.h"
6 #include "secitem.h" 6 #include "secitem.h"
7 #include "secder.h" 7 #include "secder.h"
8 #include "base64.h" 8 #include "base64.h"
9 #include "secasn1.h" 9 #include "secasn1.h"
10 #include "secerr.h" 10 #include "secerr.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 offsetof(NSSLOWKEYPrivateKeyInfo, attributes), 46 offsetof(NSSLOWKEYPrivateKeyInfo, attributes),
47 nsslowkey_SetOfAttributeTemplate }, 47 nsslowkey_SetOfAttributeTemplate },
48 { 0 } 48 { 0 }
49 }; 49 };
50 50
51 const SEC_ASN1Template nsslowkey_PQGParamsTemplate[] = { 51 const SEC_ASN1Template nsslowkey_PQGParamsTemplate[] = {
52 { SEC_ASN1_SEQUENCE, 0, NULL, sizeof(PQGParams) }, 52 { SEC_ASN1_SEQUENCE, 0, NULL, sizeof(PQGParams) },
53 { SEC_ASN1_INTEGER, offsetof(PQGParams,prime) }, 53 { SEC_ASN1_INTEGER, offsetof(PQGParams,prime) },
54 { SEC_ASN1_INTEGER, offsetof(PQGParams,subPrime) }, 54 { SEC_ASN1_INTEGER, offsetof(PQGParams,subPrime) },
55 { SEC_ASN1_INTEGER, offsetof(PQGParams,base) }, 55 { SEC_ASN1_INTEGER, offsetof(PQGParams,base) },
56 { 0, } 56 { 0 }
57 }; 57 };
58 58
59 const SEC_ASN1Template nsslowkey_RSAPrivateKeyTemplate[] = { 59 const SEC_ASN1Template nsslowkey_RSAPrivateKeyTemplate[] = {
60 { SEC_ASN1_SEQUENCE, 0, NULL, sizeof(NSSLOWKEYPrivateKey) }, 60 { SEC_ASN1_SEQUENCE, 0, NULL, sizeof(NSSLOWKEYPrivateKey) },
61 { SEC_ASN1_INTEGER, offsetof(NSSLOWKEYPrivateKey,u.rsa.version) }, 61 { SEC_ASN1_INTEGER, offsetof(NSSLOWKEYPrivateKey,u.rsa.version) },
62 { SEC_ASN1_INTEGER, offsetof(NSSLOWKEYPrivateKey,u.rsa.modulus) }, 62 { SEC_ASN1_INTEGER, offsetof(NSSLOWKEYPrivateKey,u.rsa.modulus) },
63 { SEC_ASN1_INTEGER, offsetof(NSSLOWKEYPrivateKey,u.rsa.publicExponent) }, 63 { SEC_ASN1_INTEGER, offsetof(NSSLOWKEYPrivateKey,u.rsa.publicExponent) },
64 { SEC_ASN1_INTEGER, offsetof(NSSLOWKEYPrivateKey,u.rsa.privateExponent) }, 64 { SEC_ASN1_INTEGER, offsetof(NSSLOWKEYPrivateKey,u.rsa.privateExponent) },
65 { SEC_ASN1_INTEGER, offsetof(NSSLOWKEYPrivateKey,u.rsa.prime1) }, 65 { SEC_ASN1_INTEGER, offsetof(NSSLOWKEYPrivateKey,u.rsa.prime1) },
66 { SEC_ASN1_INTEGER, offsetof(NSSLOWKEYPrivateKey,u.rsa.prime2) }, 66 { SEC_ASN1_INTEGER, offsetof(NSSLOWKEYPrivateKey,u.rsa.prime2) },
67 { SEC_ASN1_INTEGER, offsetof(NSSLOWKEYPrivateKey,u.rsa.exponent1) }, 67 { SEC_ASN1_INTEGER, offsetof(NSSLOWKEYPrivateKey,u.rsa.exponent1) },
68 { SEC_ASN1_INTEGER, offsetof(NSSLOWKEYPrivateKey,u.rsa.exponent2) }, 68 { SEC_ASN1_INTEGER, offsetof(NSSLOWKEYPrivateKey,u.rsa.exponent2) },
69 { SEC_ASN1_INTEGER, offsetof(NSSLOWKEYPrivateKey,u.rsa.coefficient) }, 69 { SEC_ASN1_INTEGER, offsetof(NSSLOWKEYPrivateKey,u.rsa.coefficient) },
70 { 0 } 70 { 0 }
71 }; 71 };
72 72
73 73
74 const SEC_ASN1Template nsslowkey_DSAPrivateKeyTemplate[] = { 74 const SEC_ASN1Template nsslowkey_DSAPrivateKeyTemplate[] = {
75 { SEC_ASN1_SEQUENCE, 0, NULL, sizeof(NSSLOWKEYPrivateKey) }, 75 { SEC_ASN1_SEQUENCE, 0, NULL, sizeof(NSSLOWKEYPrivateKey) },
76 { SEC_ASN1_INTEGER, offsetof(NSSLOWKEYPrivateKey,u.dsa.publicValue) }, 76 { SEC_ASN1_INTEGER, offsetof(NSSLOWKEYPrivateKey,u.dsa.publicValue) },
77 { SEC_ASN1_INTEGER, offsetof(NSSLOWKEYPrivateKey,u.dsa.privateValue) }, 77 { SEC_ASN1_INTEGER, offsetof(NSSLOWKEYPrivateKey,u.dsa.privateValue) },
78 { 0, } 78 { 0 }
79 }; 79 };
80 80
81 const SEC_ASN1Template nsslowkey_DSAPrivateKeyExportTemplate[] = { 81 const SEC_ASN1Template nsslowkey_DSAPrivateKeyExportTemplate[] = {
82 { SEC_ASN1_INTEGER, offsetof(NSSLOWKEYPrivateKey,u.dsa.privateValue) }, 82 { SEC_ASN1_INTEGER, offsetof(NSSLOWKEYPrivateKey,u.dsa.privateValue) },
83 }; 83 };
84 84
85 const SEC_ASN1Template nsslowkey_DHPrivateKeyTemplate[] = { 85 const SEC_ASN1Template nsslowkey_DHPrivateKeyTemplate[] = {
86 { SEC_ASN1_SEQUENCE, 0, NULL, sizeof(NSSLOWKEYPrivateKey) }, 86 { SEC_ASN1_SEQUENCE, 0, NULL, sizeof(NSSLOWKEYPrivateKey) },
87 { SEC_ASN1_INTEGER, offsetof(NSSLOWKEYPrivateKey,u.dh.publicValue) }, 87 { SEC_ASN1_INTEGER, offsetof(NSSLOWKEYPrivateKey,u.dh.publicValue) },
88 { SEC_ASN1_INTEGER, offsetof(NSSLOWKEYPrivateKey,u.dh.privateValue) }, 88 { SEC_ASN1_INTEGER, offsetof(NSSLOWKEYPrivateKey,u.dh.privateValue) },
89 { SEC_ASN1_INTEGER, offsetof(NSSLOWKEYPrivateKey,u.dh.base) }, 89 { SEC_ASN1_INTEGER, offsetof(NSSLOWKEYPrivateKey,u.dh.base) },
90 { SEC_ASN1_INTEGER, offsetof(NSSLOWKEYPrivateKey,u.dh.prime) }, 90 { SEC_ASN1_INTEGER, offsetof(NSSLOWKEYPrivateKey,u.dh.prime) },
91 { 0, } 91 { 0 }
92 }; 92 };
93 93
94 #ifndef NSS_DISABLE_ECC 94 #ifndef NSS_DISABLE_ECC
95 95
96 /* XXX This is just a placeholder for later when we support 96 /* XXX This is just a placeholder for later when we support
97 * generic curves and need full-blown support for parsing EC 97 * generic curves and need full-blown support for parsing EC
98 * parameters. For now, we only support named curves in which 98 * parameters. For now, we only support named curves in which
99 * EC params are simply encoded as an object ID and we don't 99 * EC params are simply encoded as an object ID and we don't
100 * use nsslowkey_ECParamsTemplate. 100 * use nsslowkey_ECParamsTemplate.
101 */ 101 */
102 const SEC_ASN1Template nsslowkey_ECParamsTemplate[] = { 102 const SEC_ASN1Template nsslowkey_ECParamsTemplate[] = {
103 { SEC_ASN1_CHOICE, offsetof(ECParams,type), NULL, sizeof(ECParams) }, 103 { SEC_ASN1_CHOICE, offsetof(ECParams,type), NULL, sizeof(ECParams) },
104 { SEC_ASN1_OBJECT_ID, offsetof(ECParams,curveOID), NULL, ec_params_named }, 104 { SEC_ASN1_OBJECT_ID, offsetof(ECParams,curveOID), NULL, ec_params_named },
105 { 0, } 105 { 0 }
106 }; 106 };
107 107
108 108
109 /* NOTE: The SECG specification allows the private key structure 109 /* NOTE: The SECG specification allows the private key structure
110 * to contain curve parameters but recommends that they be stored 110 * to contain curve parameters but recommends that they be stored
111 * in the PrivateKeyAlgorithmIdentifier field of the PrivateKeyInfo 111 * in the PrivateKeyAlgorithmIdentifier field of the PrivateKeyInfo
112 * instead. 112 * instead.
113 */ 113 */
114 const SEC_ASN1Template nsslowkey_ECPrivateKeyTemplate[] = { 114 const SEC_ASN1Template nsslowkey_ECPrivateKeyTemplate[] = {
115 { SEC_ASN1_SEQUENCE, 0, NULL, sizeof(NSSLOWKEYPrivateKey) }, 115 { SEC_ASN1_SEQUENCE, 0, NULL, sizeof(NSSLOWKEYPrivateKey) },
(...skipping 15 matching lines...) Expand all
131 { SEC_ASN1_OPTIONAL | SEC_ASN1_CONSTRUCTED | 131 { SEC_ASN1_OPTIONAL | SEC_ASN1_CONSTRUCTED |
132 SEC_ASN1_EXPLICIT | SEC_ASN1_CONTEXT_SPECIFIC | 0, 132 SEC_ASN1_EXPLICIT | SEC_ASN1_CONTEXT_SPECIFIC | 0,
133 offsetof(NSSLOWKEYPrivateKey,u.ec.ecParams), 133 offsetof(NSSLOWKEYPrivateKey,u.ec.ecParams),
134 nsslowkey_ECParamsTemplate }, 134 nsslowkey_ECParamsTemplate },
135 #endif 135 #endif
136 { SEC_ASN1_OPTIONAL | SEC_ASN1_CONSTRUCTED | 136 { SEC_ASN1_OPTIONAL | SEC_ASN1_CONSTRUCTED |
137 SEC_ASN1_EXPLICIT | SEC_ASN1_CONTEXT_SPECIFIC | 137 SEC_ASN1_EXPLICIT | SEC_ASN1_CONTEXT_SPECIFIC |
138 SEC_ASN1_XTRN | 1, 138 SEC_ASN1_XTRN | 1,
139 offsetof(NSSLOWKEYPrivateKey,u.ec.publicValue), 139 offsetof(NSSLOWKEYPrivateKey,u.ec.publicValue),
140 SEC_ASN1_SUB(SEC_BitStringTemplate) }, 140 SEC_ASN1_SUB(SEC_BitStringTemplate) },
141 { 0, } 141 { 0 }
142 }; 142 };
143 #endif /* NSS_DISABLE_ECC */ 143 #endif /* NSS_DISABLE_ECC */
144 /* 144 /*
145 * See bugzilla bug 125359 145 * See bugzilla bug 125359
146 * Since NSS (via PKCS#11) wants to handle big integers as unsigned ints, 146 * Since NSS (via PKCS#11) wants to handle big integers as unsigned ints,
147 * all of the templates above that en/decode into integers must be converted 147 * all of the templates above that en/decode into integers must be converted
148 * from ASN.1's signed integer type. This is done by marking either the 148 * from ASN.1's signed integer type. This is done by marking either the
149 * source or destination (encoding or decoding, respectively) type as 149 * source or destination (encoding or decoding, respectively) type as
150 * siUnsignedInteger. 150 * siUnsignedInteger.
151 */ 151 */
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 483
484 loser: 484 loser:
485 485
486 if(rv != SECSuccess) { 486 if(rv != SECSuccess) {
487 PORT_FreeArena(poolp, PR_TRUE); 487 PORT_FreeArena(poolp, PR_TRUE);
488 returnKey = NULL; 488 returnKey = NULL;
489 } 489 }
490 490
491 return returnKey; 491 return returnKey;
492 } 492 }
OLDNEW
« no previous file with comments | « nss/lib/softoken/lgglue.c ('k') | nss/lib/softoken/lowpbe.h » ('j') | nss/lib/util/secoid.c » ('J')

Powered by Google App Engine
This is Rietveld 408576698