OLD | NEW |
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 | 4 |
5 #include "cert.h" | 5 #include "cert.h" |
6 #include "certt.h" | 6 #include "certt.h" |
7 #include "secder.h" | 7 #include "secder.h" |
8 #include "key.h" | 8 #include "key.h" |
9 #include "secitem.h" | 9 #include "secitem.h" |
10 #include "secasn1.h" | 10 #include "secasn1.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 SEC_ASN1_CHOOSER_IMPLEMENT(CERT_CertificateRequestTemplate) | 45 SEC_ASN1_CHOOSER_IMPLEMENT(CERT_CertificateRequestTemplate) |
46 | 46 |
47 CERTCertificate * | 47 CERTCertificate * |
48 CERT_CreateCertificate(unsigned long serialNumber, | 48 CERT_CreateCertificate(unsigned long serialNumber, |
49 CERTName *issuer, | 49 CERTName *issuer, |
50 CERTValidity *validity, | 50 CERTValidity *validity, |
51 CERTCertificateRequest *req) | 51 CERTCertificateRequest *req) |
52 { | 52 { |
53 CERTCertificate *c; | 53 CERTCertificate *c; |
54 int rv; | 54 int rv; |
55 PRArenaPool *arena; | 55 PLArenaPool *arena; |
56 | 56 |
57 arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE); | 57 arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE); |
58 | 58 |
59 if ( !arena ) { | 59 if ( !arena ) { |
60 return(0); | 60 return(0); |
61 } | 61 } |
62 | 62 |
63 c = (CERTCertificate *)PORT_ArenaZAlloc(arena, sizeof(CERTCertificate)); | 63 c = (CERTCertificate *)PORT_ArenaZAlloc(arena, sizeof(CERTCertificate)); |
64 | 64 |
65 if (!c) { | 65 if (!c) { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 * single attribute of the cert request. In this implementation there is at most | 117 * single attribute of the cert request. In this implementation there is at most |
118 * one attribute and it is always of type SEC_OID_PKCS9_EXTENSION_REQUEST. | 118 * one attribute and it is always of type SEC_OID_PKCS9_EXTENSION_REQUEST. |
119 */ | 119 */ |
120 | 120 |
121 CERTCertificateRequest * | 121 CERTCertificateRequest * |
122 CERT_CreateCertificateRequest(CERTName *subject, | 122 CERT_CreateCertificateRequest(CERTName *subject, |
123 CERTSubjectPublicKeyInfo *spki, | 123 CERTSubjectPublicKeyInfo *spki, |
124 SECItem **attributes) | 124 SECItem **attributes) |
125 { | 125 { |
126 CERTCertificateRequest *certreq; | 126 CERTCertificateRequest *certreq; |
127 PRArenaPool *arena; | 127 PLArenaPool *arena; |
128 CERTAttribute * attribute; | 128 CERTAttribute * attribute; |
129 SECOidData * oidData; | 129 SECOidData * oidData; |
130 SECStatus rv; | 130 SECStatus rv; |
131 int i = 0; | 131 int i = 0; |
132 | 132 |
133 arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE); | 133 arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE); |
134 if ( arena == NULL ) { | 134 if ( arena == NULL ) { |
135 return NULL; | 135 return NULL; |
136 } | 136 } |
137 | 137 |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 setCRExt(void *o, CERTCertExtension **exts) | 233 setCRExt(void *o, CERTCertExtension **exts) |
234 { | 234 { |
235 ((CERTCertificateRequest *)o)->attributes = (struct CERTAttributeStr **)exts
; | 235 ((CERTCertificateRequest *)o)->attributes = (struct CERTAttributeStr **)exts
; |
236 } | 236 } |
237 | 237 |
238 /* | 238 /* |
239 ** Set up to start gathering cert extensions for a cert request. | 239 ** Set up to start gathering cert extensions for a cert request. |
240 ** The list is created as CertExtensions and converted to an | 240 ** The list is created as CertExtensions and converted to an |
241 ** attribute list by CERT_FinishCRAttributes(). | 241 ** attribute list by CERT_FinishCRAttributes(). |
242 */ | 242 */ |
243 extern void *cert_StartExtensions(void *owner, PRArenaPool *ownerArena, | 243 extern void *cert_StartExtensions(void *owner, PLArenaPool *ownerArena, |
244 void (*setExts)(void *object, CERTCertExtension **exts)); | 244 void (*setExts)(void *object, CERTCertExtension **exts)); |
245 void * | 245 void * |
246 CERT_StartCertificateRequestAttributes(CERTCertificateRequest *req) | 246 CERT_StartCertificateRequestAttributes(CERTCertificateRequest *req) |
247 { | 247 { |
248 return (cert_StartExtensions ((void *)req, req->arena, setCRExt)); | 248 return (cert_StartExtensions ((void *)req, req->arena, setCRExt)); |
249 } | 249 } |
250 | 250 |
251 /* | 251 /* |
252 ** At entry req->attributes actually contains an list of cert extensions-- | 252 ** At entry req->attributes actually contains an list of cert extensions-- |
253 ** req-attributes is overloaded until the list is DER encoded (the first | 253 ** req-attributes is overloaded until the list is DER encoded (the first |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 | 315 |
316 if ((*req->attributes)->attrValue == NULL) { | 316 if ((*req->attributes)->attrValue == NULL) { |
317 PORT_SetError(SEC_ERROR_INVALID_ARGS); | 317 PORT_SetError(SEC_ERROR_INVALID_ARGS); |
318 return SECFailure; | 318 return SECFailure; |
319 } | 319 } |
320 | 320 |
321 return(SEC_ASN1DecodeItem(req->arena, exts, | 321 return(SEC_ASN1DecodeItem(req->arena, exts, |
322 SEC_ASN1_GET(CERT_SequenceOfCertExtensionTemplate), | 322 SEC_ASN1_GET(CERT_SequenceOfCertExtensionTemplate), |
323 (*req->attributes)->attrValue[0])); | 323 (*req->attributes)->attrValue[0])); |
324 } | 324 } |
OLD | NEW |