| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/x509/x_x509a.c |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | /* | - | ||||||||||||||||||
| 2 | * Copyright 1999-2016 The OpenSSL Project Authors. All Rights Reserved. | - | ||||||||||||||||||
| 3 | * | - | ||||||||||||||||||
| 4 | * Licensed under the OpenSSL license (the "License"). You may not use | - | ||||||||||||||||||
| 5 | * this file except in compliance with the License. You can obtain a copy | - | ||||||||||||||||||
| 6 | * in the file LICENSE in the source distribution or at | - | ||||||||||||||||||
| 7 | * https://www.openssl.org/source/license.html | - | ||||||||||||||||||
| 8 | */ | - | ||||||||||||||||||
| 9 | - | |||||||||||||||||||
| 10 | #include <stdio.h> | - | ||||||||||||||||||
| 11 | #include "internal/cryptlib.h" | - | ||||||||||||||||||
| 12 | #include <openssl/evp.h> | - | ||||||||||||||||||
| 13 | #include <openssl/asn1t.h> | - | ||||||||||||||||||
| 14 | #include <openssl/x509.h> | - | ||||||||||||||||||
| 15 | #include "internal/x509_int.h" | - | ||||||||||||||||||
| 16 | - | |||||||||||||||||||
| 17 | /* | - | ||||||||||||||||||
| 18 | * X509_CERT_AUX routines. These are used to encode additional user | - | ||||||||||||||||||
| 19 | * modifiable data about a certificate. This data is appended to the X509 | - | ||||||||||||||||||
| 20 | * encoding when the *_X509_AUX routines are used. This means that the | - | ||||||||||||||||||
| 21 | * "traditional" X509 routines will simply ignore the extra data. | - | ||||||||||||||||||
| 22 | */ | - | ||||||||||||||||||
| 23 | - | |||||||||||||||||||
| 24 | static X509_CERT_AUX *aux_get(X509 *x); | - | ||||||||||||||||||
| 25 | - | |||||||||||||||||||
| 26 | ASN1_SEQUENCE(X509_CERT_AUX) = { | - | ||||||||||||||||||
| 27 | ASN1_SEQUENCE_OF_OPT(X509_CERT_AUX, trust, ASN1_OBJECT), | - | ||||||||||||||||||
| 28 | ASN1_IMP_SEQUENCE_OF_OPT(X509_CERT_AUX, reject, ASN1_OBJECT, 0), | - | ||||||||||||||||||
| 29 | ASN1_OPT(X509_CERT_AUX, alias, ASN1_UTF8STRING), | - | ||||||||||||||||||
| 30 | ASN1_OPT(X509_CERT_AUX, keyid, ASN1_OCTET_STRING), | - | ||||||||||||||||||
| 31 | ASN1_IMP_SEQUENCE_OF_OPT(X509_CERT_AUX, other, X509_ALGOR, 1) | - | ||||||||||||||||||
| 32 | } ASN1_SEQUENCE_END(X509_CERT_AUX) | - | ||||||||||||||||||
| 33 | - | |||||||||||||||||||
| 34 | IMPLEMENT_ASN1_FUNCTIONS(X509_CERT_AUX) executed 39780 times by 1 test: end of blockExecuted by:
executed 59 times by 1 test: return (X509_CERT_AUX *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, (&(X509_CERT_AUX_it)));Executed by:
executed 12 times by 1 test: return ASN1_item_i2d((ASN1_VALUE *)a, out, (&(X509_CERT_AUX_it)));Executed by:
never executed: return (X509_CERT_AUX *)ASN1_item_new((&(X509_CERT_AUX_it))); | 0-39780 | ||||||||||||||||||
| 35 | - | |||||||||||||||||||
| 36 | int X509_trusted(const X509 *x) | - | ||||||||||||||||||
| 37 | { | - | ||||||||||||||||||
| 38 | return x->aux ? 1 : 0; executed 1346 times by 1 test: return x->aux ? 1 : 0;Executed by:
| 0-1346 | ||||||||||||||||||
| 39 | } | - | ||||||||||||||||||
| 40 | - | |||||||||||||||||||
| 41 | static X509_CERT_AUX *aux_get(X509 *x) | - | ||||||||||||||||||
| 42 | { | - | ||||||||||||||||||
| 43 | if (x == NULL)
| 0 | ||||||||||||||||||
| 44 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 45 | if (x->aux == NULL && (x->aux = X509_CERT_AUX_new()) == NULL)
| 0 | ||||||||||||||||||
| 46 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 47 | return x->aux; never executed: return x->aux; | 0 | ||||||||||||||||||
| 48 | } | - | ||||||||||||||||||
| 49 | - | |||||||||||||||||||
| 50 | int X509_alias_set1(X509 *x, const unsigned char *name, int len) | - | ||||||||||||||||||
| 51 | { | - | ||||||||||||||||||
| 52 | X509_CERT_AUX *aux; | - | ||||||||||||||||||
| 53 | if (!name) {
| 0 | ||||||||||||||||||
| 54 | if (!x || !x->aux || !x->aux->alias)
| 0 | ||||||||||||||||||
| 55 | return 1; never executed: return 1; | 0 | ||||||||||||||||||
| 56 | ASN1_UTF8STRING_free(x->aux->alias); | - | ||||||||||||||||||
| 57 | x->aux->alias = NULL; | - | ||||||||||||||||||
| 58 | return 1; never executed: return 1; | 0 | ||||||||||||||||||
| 59 | } | - | ||||||||||||||||||
| 60 | if ((aux = aux_get(x)) == NULL)
| 0 | ||||||||||||||||||
| 61 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 62 | if (aux->alias == NULL && (aux->alias = ASN1_UTF8STRING_new()) == NULL)
| 0 | ||||||||||||||||||
| 63 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 64 | return ASN1_STRING_set(aux->alias, name, len); never executed: return ASN1_STRING_set(aux->alias, name, len); | 0 | ||||||||||||||||||
| 65 | } | - | ||||||||||||||||||
| 66 | - | |||||||||||||||||||
| 67 | int X509_keyid_set1(X509 *x, const unsigned char *id, int len) | - | ||||||||||||||||||
| 68 | { | - | ||||||||||||||||||
| 69 | X509_CERT_AUX *aux; | - | ||||||||||||||||||
| 70 | if (!id) {
| 0 | ||||||||||||||||||
| 71 | if (!x || !x->aux || !x->aux->keyid)
| 0 | ||||||||||||||||||
| 72 | return 1; never executed: return 1; | 0 | ||||||||||||||||||
| 73 | ASN1_OCTET_STRING_free(x->aux->keyid); | - | ||||||||||||||||||
| 74 | x->aux->keyid = NULL; | - | ||||||||||||||||||
| 75 | return 1; never executed: return 1; | 0 | ||||||||||||||||||
| 76 | } | - | ||||||||||||||||||
| 77 | if ((aux = aux_get(x)) == NULL)
| 0 | ||||||||||||||||||
| 78 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 79 | if (aux->keyid == NULL
| 0 | ||||||||||||||||||
| 80 | && (aux->keyid = ASN1_OCTET_STRING_new()) == NULL)
| 0 | ||||||||||||||||||
| 81 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 82 | return ASN1_STRING_set(aux->keyid, id, len); never executed: return ASN1_STRING_set(aux->keyid, id, len); | 0 | ||||||||||||||||||
| 83 | } | - | ||||||||||||||||||
| 84 | - | |||||||||||||||||||
| 85 | unsigned char *X509_alias_get0(X509 *x, int *len) | - | ||||||||||||||||||
| 86 | { | - | ||||||||||||||||||
| 87 | if (!x->aux || !x->aux->alias)
| 0 | ||||||||||||||||||
| 88 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 89 | if (len)
| 0 | ||||||||||||||||||
| 90 | *len = x->aux->alias->length; never executed: *len = x->aux->alias->length; | 0 | ||||||||||||||||||
| 91 | return x->aux->alias->data; never executed: return x->aux->alias->data; | 0 | ||||||||||||||||||
| 92 | } | - | ||||||||||||||||||
| 93 | - | |||||||||||||||||||
| 94 | unsigned char *X509_keyid_get0(X509 *x, int *len) | - | ||||||||||||||||||
| 95 | { | - | ||||||||||||||||||
| 96 | if (!x->aux || !x->aux->keyid)
| 0 | ||||||||||||||||||
| 97 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 98 | if (len)
| 0 | ||||||||||||||||||
| 99 | *len = x->aux->keyid->length; never executed: *len = x->aux->keyid->length; | 0 | ||||||||||||||||||
| 100 | return x->aux->keyid->data; never executed: return x->aux->keyid->data; | 0 | ||||||||||||||||||
| 101 | } | - | ||||||||||||||||||
| 102 | - | |||||||||||||||||||
| 103 | int X509_add1_trust_object(X509 *x, const ASN1_OBJECT *obj) | - | ||||||||||||||||||
| 104 | { | - | ||||||||||||||||||
| 105 | X509_CERT_AUX *aux; | - | ||||||||||||||||||
| 106 | ASN1_OBJECT *objtmp = NULL; | - | ||||||||||||||||||
| 107 | if (obj) {
| 0 | ||||||||||||||||||
| 108 | objtmp = OBJ_dup(obj); | - | ||||||||||||||||||
| 109 | if (!objtmp)
| 0 | ||||||||||||||||||
| 110 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 111 | } never executed: end of block | 0 | ||||||||||||||||||
| 112 | if ((aux = aux_get(x)) == NULL)
| 0 | ||||||||||||||||||
| 113 | goto err; never executed: goto err; | 0 | ||||||||||||||||||
| 114 | if (aux->trust == NULL
| 0 | ||||||||||||||||||
| 115 | && (aux->trust = sk_ASN1_OBJECT_new_null()) == NULL)
| 0 | ||||||||||||||||||
| 116 | goto err; never executed: goto err; | 0 | ||||||||||||||||||
| 117 | if (!objtmp || sk_ASN1_OBJECT_push(aux->trust, objtmp))
| 0 | ||||||||||||||||||
| 118 | return 1; never executed: return 1; | 0 | ||||||||||||||||||
| 119 | err: code before this statement never executed: err: | 0 | ||||||||||||||||||
| 120 | ASN1_OBJECT_free(objtmp); | - | ||||||||||||||||||
| 121 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 122 | } | - | ||||||||||||||||||
| 123 | - | |||||||||||||||||||
| 124 | int X509_add1_reject_object(X509 *x, const ASN1_OBJECT *obj) | - | ||||||||||||||||||
| 125 | { | - | ||||||||||||||||||
| 126 | X509_CERT_AUX *aux; | - | ||||||||||||||||||
| 127 | ASN1_OBJECT *objtmp; | - | ||||||||||||||||||
| 128 | if ((objtmp = OBJ_dup(obj)) == NULL)
| 0 | ||||||||||||||||||
| 129 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 130 | if ((aux = aux_get(x)) == NULL)
| 0 | ||||||||||||||||||
| 131 | goto err; never executed: goto err; | 0 | ||||||||||||||||||
| 132 | if (aux->reject == NULL
| 0 | ||||||||||||||||||
| 133 | && (aux->reject = sk_ASN1_OBJECT_new_null()) == NULL)
| 0 | ||||||||||||||||||
| 134 | goto err; never executed: goto err; | 0 | ||||||||||||||||||
| 135 | return sk_ASN1_OBJECT_push(aux->reject, objtmp); never executed: return sk_ASN1_OBJECT_push(aux->reject, objtmp); | 0 | ||||||||||||||||||
| 136 | err: | - | ||||||||||||||||||
| 137 | ASN1_OBJECT_free(objtmp); | - | ||||||||||||||||||
| 138 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 139 | } | - | ||||||||||||||||||
| 140 | - | |||||||||||||||||||
| 141 | void X509_trust_clear(X509 *x) | - | ||||||||||||||||||
| 142 | { | - | ||||||||||||||||||
| 143 | if (x->aux) {
| 0 | ||||||||||||||||||
| 144 | sk_ASN1_OBJECT_pop_free(x->aux->trust, ASN1_OBJECT_free); | - | ||||||||||||||||||
| 145 | x->aux->trust = NULL; | - | ||||||||||||||||||
| 146 | } never executed: end of block | 0 | ||||||||||||||||||
| 147 | } never executed: end of block | 0 | ||||||||||||||||||
| 148 | - | |||||||||||||||||||
| 149 | void X509_reject_clear(X509 *x) | - | ||||||||||||||||||
| 150 | { | - | ||||||||||||||||||
| 151 | if (x->aux) {
| 0 | ||||||||||||||||||
| 152 | sk_ASN1_OBJECT_pop_free(x->aux->reject, ASN1_OBJECT_free); | - | ||||||||||||||||||
| 153 | x->aux->reject = NULL; | - | ||||||||||||||||||
| 154 | } never executed: end of block | 0 | ||||||||||||||||||
| 155 | } never executed: end of block | 0 | ||||||||||||||||||
| 156 | - | |||||||||||||||||||
| 157 | STACK_OF(ASN1_OBJECT) *X509_get0_trust_objects(X509 *x) | - | ||||||||||||||||||
| 158 | { | - | ||||||||||||||||||
| 159 | if (x->aux != NULL)
| 0 | ||||||||||||||||||
| 160 | return x->aux->trust; never executed: return x->aux->trust; | 0 | ||||||||||||||||||
| 161 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 162 | } | - | ||||||||||||||||||
| 163 | - | |||||||||||||||||||
| 164 | STACK_OF(ASN1_OBJECT) *X509_get0_reject_objects(X509 *x) | - | ||||||||||||||||||
| 165 | { | - | ||||||||||||||||||
| 166 | if (x->aux != NULL)
| 0 | ||||||||||||||||||
| 167 | return x->aux->reject; never executed: return x->aux->reject; | 0 | ||||||||||||||||||
| 168 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 169 | } | - | ||||||||||||||||||
| Source code | Switch to Preprocessed file |