Debian Codegraph @

debian/rust-vendor/aws-lc-sys/aws-lc/crypto/x509/x509rset.c

raw
1 // Copyright (C) 1995-1998 Eric Young ([email protected]) All rights reserved.
2 // SPDX-License-Identifier: Apache-2.0
3
4 #include <openssl/asn1.h>
5 #include <openssl/evp.h>
6 #include <openssl/obj.h>
7 #include <openssl/x509.h>
8
9 #include "internal.h"
10
11
12 int X509_REQ_set_version(X509_REQ *x, long version) {
13 if (x == NULL) {
14 return 0;
15 }
16 if (version != X509_REQ_VERSION_1) {
17 OPENSSL_PUT_ERROR(X509, X509_R_INVALID_VERSION);
18 return 0;
19 }
20 return ASN1_INTEGER_set_int64(x->req_info->version, version);
21 }
22
23 int X509_REQ_set_subject_name(X509_REQ *x, X509_NAME *name) {
24 if ((x == NULL) || (x->req_info == NULL)) {
25 return 0;
26 }
27 return (X509_NAME_set(&x->req_info->subject, name));
28 }
29
30 int X509_REQ_set_pubkey(X509_REQ *x, EVP_PKEY *pkey) {
31 if ((x == NULL) || (x->req_info == NULL)) {
32 return 0;
33 }
34 return (X509_PUBKEY_set(&x->req_info->pubkey, pkey));
35 }
36
37 int X509_REQ_set1_signature_algo(X509_REQ *req, const X509_ALGOR *algo) {
38 X509_ALGOR *copy = X509_ALGOR_dup(algo);
39 if (copy == NULL) {
40 return 0;
41 }
42
43 X509_ALGOR_free(req->sig_alg);
44 req->sig_alg = copy;
45 return 1;
46 }
47
48 int X509_REQ_set1_signature_value(X509_REQ *req, const uint8_t *sig,
49 size_t sig_len) {
50 if (!ASN1_STRING_set(req->signature, sig, sig_len)) {
51 return 0;
52 }
53 req->signature->flags &= ~(ASN1_STRING_FLAG_BITS_LEFT | 0x07);
54 req->signature->flags |= ASN1_STRING_FLAG_BITS_LEFT;
55 return 1;
56 }