| Line | Source | Count |
| 1 | | - |
| 2 | | - |
| 3 | | - |
| 4 | | - |
| 5 | | - |
| 6 | | - |
| 7 | | - |
| 8 | | - |
| 9 | | - |
| 10 | | - |
| 11 | | - |
| 12 | | - |
| 13 | | - |
| 14 | | - |
| 15 | | - |
| 16 | | - |
| 17 | | - |
| 18 | | - |
| 19 | | - |
| 20 | | - |
| 21 | | - |
| 22 | | - |
| 23 | | - |
| 24 | | - |
| 25 | | - |
| 26 | | - |
| 27 | | - |
| 28 | | - |
| 29 | | - |
| 30 | | - |
| 31 | | - |
| 32 | | - |
| 33 | | - |
| 34 | | - |
| 35 | | - |
| 36 | | - |
| 37 | | - |
| 38 | | - |
| 39 | | - |
| 40 | | - |
| 41 | | - |
| 42 | | - |
| 43 | | - |
| 44 | | - |
| 45 | | - |
| 46 | | - |
| 47 | | - |
| 48 | | - |
| 49 | | - |
| 50 | | - |
| 51 | | - |
| 52 | | - |
| 53 | | - |
| 54 | | - |
| 55 | | - |
| 56 | | - |
| 57 | | - |
| 58 | | - |
| 59 | #include <sys/types.h> | - |
| 60 | | - |
| 61 | #include <stdio.h> | - |
| 62 | #include <string.h> | - |
| 63 | #include <time.h> | - |
| 64 | | - |
| 65 | #include <openssl/bn.h> | - |
| 66 | #include <openssl/buffer.h> | - |
| 67 | #include <openssl/err.h> | - |
| 68 | #include <openssl/evp.h> | - |
| 69 | #include <openssl/objects.h> | - |
| 70 | #include <openssl/x509.h> | - |
| 71 | | - |
| 72 | #include "asn1_locl.h" | - |
| 73 | | - |
| 74 | int | - |
| 75 | ASN1_item_verify(const ASN1_ITEM *it, X509_ALGOR *a, | - |
| 76 | ASN1_BIT_STRING *signature, void *asn, EVP_PKEY *pkey) | - |
| 77 | { | - |
| 78 | EVP_MD_CTX ctx; | - |
| 79 | unsigned char *buf_in = NULL; | - |
| 80 | int ret = -1, inl; | - |
| 81 | | - |
| 82 | int mdnid, pknid; | - |
| 83 | | - |
| 84 | if (!pkey) {| TRUE | never evaluated | | FALSE | evaluated 72 times by 2 tests |
| 0-72 |
| 85 | ASN1error(ERR_R_PASSED_NULL_PARAMETER); | - |
| 86 | return -1; never executed: return -1; | 0 |
| 87 | } | - |
| 88 | | - |
| 89 | if (signature->type == V_ASN1_BIT_STRING && signature->flags & 0x7)| TRUE | evaluated 72 times by 2 tests | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | evaluated 72 times by 2 tests |
| 0-72 |
| 90 | { | - |
| 91 | ASN1error(ASN1_R_INVALID_BIT_STRING_BITS_LEFT); | - |
| 92 | return -1; never executed: return -1; | 0 |
| 93 | } | - |
| 94 | | - |
| 95 | EVP_MD_CTX_init(&ctx); | - |
| 96 | | - |
| 97 | | - |
| 98 | if (!OBJ_find_sigid_algs(OBJ_obj2nid(a->algorithm), &mdnid, &pknid)) {| TRUE | never evaluated | | FALSE | evaluated 72 times by 2 tests |
| 0-72 |
| 99 | ASN1error(ASN1_R_UNKNOWN_SIGNATURE_ALGORITHM); | - |
| 100 | goto err; never executed: goto err; | 0 |
| 101 | } | - |
| 102 | if (mdnid == NID_undef) {| TRUE | never evaluated | | FALSE | evaluated 72 times by 2 tests |
| 0-72 |
| 103 | if (!pkey->ameth || !pkey->ameth->item_verify) {| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 104 | ASN1error(ASN1_R_UNKNOWN_SIGNATURE_ALGORITHM); | - |
| 105 | goto err; never executed: goto err; | 0 |
| 106 | } | - |
| 107 | ret = pkey->ameth->item_verify(&ctx, it, asn, a, | - |
| 108 | signature, pkey); | - |
| 109 | | - |
| 110 | | - |
| 111 | | - |
| 112 | | - |
| 113 | if (ret != 2)| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 114 | goto err; never executed: goto err; | 0 |
| 115 | ret = -1; | - |
| 116 | } else { never executed: end of block | 0 |
| 117 | const EVP_MD *type; | - |
| 118 | type = EVP_get_digestbynid(mdnid); | - |
| 119 | if (type == NULL) {| TRUE | never evaluated | | FALSE | evaluated 72 times by 2 tests |
| 0-72 |
| 120 | ASN1error(ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM); | - |
| 121 | goto err; never executed: goto err; | 0 |
| 122 | } | - |
| 123 | | - |
| 124 | | - |
| 125 | if (EVP_PKEY_type(pknid) != pkey->ameth->pkey_id) {| TRUE | never evaluated | | FALSE | evaluated 72 times by 2 tests |
| 0-72 |
| 126 | ASN1error(ASN1_R_WRONG_PUBLIC_KEY_TYPE); | - |
| 127 | goto err; never executed: goto err; | 0 |
| 128 | } | - |
| 129 | | - |
| 130 | if (!EVP_DigestVerifyInit(&ctx, NULL, type, NULL, pkey)) {| TRUE | never evaluated | | FALSE | evaluated 72 times by 2 tests |
| 0-72 |
| 131 | ASN1error(ERR_R_EVP_LIB); | - |
| 132 | ret = 0; | - |
| 133 | goto err; never executed: goto err; | 0 |
| 134 | } | - |
| 135 | | - |
| 136 | }executed 72 times by 2 tests: end of block | 72 |
| 137 | | - |
| 138 | inl = ASN1_item_i2d(asn, &buf_in, it); | - |
| 139 | | - |
| 140 | if (buf_in == NULL) {| TRUE | never evaluated | | FALSE | evaluated 72 times by 2 tests |
| 0-72 |
| 141 | ASN1error(ERR_R_MALLOC_FAILURE); | - |
| 142 | goto err; never executed: goto err; | 0 |
| 143 | } | - |
| 144 | | - |
| 145 | if (!EVP_DigestVerifyUpdate(&ctx, buf_in, inl)) {| TRUE | never evaluated | | FALSE | evaluated 72 times by 2 tests |
| 0-72 |
| 146 | ASN1error(ERR_R_EVP_LIB); | - |
| 147 | ret = 0; | - |
| 148 | goto err; never executed: goto err; | 0 |
| 149 | } | - |
| 150 | | - |
| 151 | freezero(buf_in, (unsigned int)inl); | - |
| 152 | | - |
| 153 | if (EVP_DigestVerifyFinal(&ctx, signature->data,| TRUE | never evaluated | | FALSE | evaluated 72 times by 2 tests |
| 0-72 |
| 154 | (size_t)signature->length) <= 0) {| TRUE | never evaluated | | FALSE | evaluated 72 times by 2 tests |
| 0-72 |
| 155 | ASN1error(ERR_R_EVP_LIB); | - |
| 156 | ret = 0; | - |
| 157 | goto err; never executed: goto err; | 0 |
| 158 | } | - |
| 159 | | - |
| 160 | | - |
| 161 | | - |
| 162 | ret = 1; | - |
| 163 | | - |
| 164 | err:code before this statement executed 72 times by 2 tests: err: | 72 |
| 165 | EVP_MD_CTX_cleanup(&ctx); | - |
| 166 | return (ret);executed 72 times by 2 tests: return (ret); | 72 |
| 167 | } | - |
| | |