diff options
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libcrypto/x509/x509_req.c | 45 |
1 files changed, 13 insertions, 32 deletions
diff --git a/src/lib/libcrypto/x509/x509_req.c b/src/lib/libcrypto/x509/x509_req.c index 556e32b317..cbf731cc5a 100644 --- a/src/lib/libcrypto/x509/x509_req.c +++ b/src/lib/libcrypto/x509/x509_req.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: x509_req.c,v 1.24 2021/11/01 20:53:08 tb Exp $ */ | 1 | /* $OpenBSD: x509_req.c,v 1.25 2021/11/03 12:53:25 schwarze Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -232,46 +232,27 @@ X509_REQ_get_extensions(X509_REQ *req) | |||
| 232 | ext->value.sequence->length, &X509_EXTENSIONS_it); | 232 | ext->value.sequence->length, &X509_EXTENSIONS_it); |
| 233 | } | 233 | } |
| 234 | 234 | ||
| 235 | /* Add a STACK_OF extensions to a certificate request: allow alternative OIDs | 235 | /* |
| 236 | * in case we want to create a non standard one. | 236 | * Add a STACK_OF extensions to a certificate request: allow alternative OIDs |
| 237 | * in case we want to create a non-standard one. | ||
| 237 | */ | 238 | */ |
| 238 | 239 | ||
| 239 | int | 240 | int |
| 240 | X509_REQ_add_extensions_nid(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts, | 241 | X509_REQ_add_extensions_nid(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts, |
| 241 | int nid) | 242 | int nid) |
| 242 | { | 243 | { |
| 243 | ASN1_TYPE *at = NULL; | 244 | unsigned char *ext = NULL; |
| 244 | X509_ATTRIBUTE *attr = NULL; | 245 | int extlen; |
| 246 | int rv; | ||
| 245 | 247 | ||
| 246 | if (!(at = ASN1_TYPE_new()) || | 248 | extlen = i2d_X509_EXTENSIONS(exts, &ext); |
| 247 | !(at->value.sequence = ASN1_STRING_new())) | 249 | if (extlen <= 0) |
| 248 | goto err; | 250 | return 0; |
| 249 | 251 | ||
| 250 | at->type = V_ASN1_SEQUENCE; | 252 | rv = X509_REQ_add1_attr_by_NID(req, nid, V_ASN1_SEQUENCE, ext, extlen); |
| 251 | /* Generate encoding of extensions */ | 253 | free(ext); |
| 252 | at->value.sequence->length = ASN1_item_i2d((ASN1_VALUE *)exts, | ||
| 253 | &at->value.sequence->data, &X509_EXTENSIONS_it); | ||
| 254 | if (!(attr = X509_ATTRIBUTE_new())) | ||
| 255 | goto err; | ||
| 256 | if (!(attr->value.set = sk_ASN1_TYPE_new_null())) | ||
| 257 | goto err; | ||
| 258 | if (!sk_ASN1_TYPE_push(attr->value.set, at)) | ||
| 259 | goto err; | ||
| 260 | at = NULL; | ||
| 261 | attr->single = 0; | ||
| 262 | attr->object = OBJ_nid2obj(nid); | ||
| 263 | if (!req->req_info->attributes) { | ||
| 264 | if (!(req->req_info->attributes = sk_X509_ATTRIBUTE_new_null())) | ||
| 265 | goto err; | ||
| 266 | } | ||
| 267 | if (!sk_X509_ATTRIBUTE_push(req->req_info->attributes, attr)) | ||
| 268 | goto err; | ||
| 269 | return 1; | ||
| 270 | 254 | ||
| 271 | err: | 255 | return rv; |
| 272 | X509_ATTRIBUTE_free(attr); | ||
| 273 | ASN1_TYPE_free(at); | ||
| 274 | return 0; | ||
| 275 | } | 256 | } |
| 276 | 257 | ||
| 277 | /* This is the normal usage: use the "official" OID */ | 258 | /* This is the normal usage: use the "official" OID */ |
