| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/ct/ct_b64.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||
| 2 | - | |||||||||||||
| 3 | - | |||||||||||||
| 4 | - | |||||||||||||
| 5 | - | |||||||||||||
| 6 | - | |||||||||||||
| 7 | - | |||||||||||||
| 8 | - | |||||||||||||
| 9 | - | |||||||||||||
| 10 | static int ct_base64_decode(const char *in, unsigned char **out) | - | ||||||||||||
| 11 | { | - | ||||||||||||
| 12 | size_t inlen = strlen(in); | - | ||||||||||||
| 13 | int outlen, i; | - | ||||||||||||
| 14 | unsigned char *outbuf = | - | ||||||||||||
| 15 | ((void *)0) | - | ||||||||||||
| 16 | ; | - | ||||||||||||
| 17 | - | |||||||||||||
| 18 | if (inlen == 0
| 1-14701 | ||||||||||||
| 19 | *out = | - | ||||||||||||
| 20 | ((void *)0) | - | ||||||||||||
| 21 | ; | - | ||||||||||||
| 22 | return executed 1 time by 1 test: 0;return 0;Executed by:
executed 1 time by 1 test: return 0;Executed by:
| 1 | ||||||||||||
| 23 | } | - | ||||||||||||
| 24 | - | |||||||||||||
| 25 | outlen = (inlen / 4) * 3; | - | ||||||||||||
| 26 | outbuf = CRYPTO_malloc(outlen, __FILE__, 36); | - | ||||||||||||
| 27 | if (outbuf ==
| 0-14701 | ||||||||||||
| 28 | ((void *)0)
| 0-14701 | ||||||||||||
| 29 | ) { | - | ||||||||||||
| 30 | ERR_put_error(50,(124),((1|64)),__FILE__,38); | - | ||||||||||||
| 31 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||
| 32 | } | - | ||||||||||||
| 33 | - | |||||||||||||
| 34 | outlen = EVP_DecodeBlock(outbuf, (unsigned char *)in, inlen); | - | ||||||||||||
| 35 | if (outlen < 0
| 1-14700 | ||||||||||||
| 36 | ERR_put_error(50,(124),(108),__FILE__,44); | - | ||||||||||||
| 37 | goto executed 1 time by 1 test: err;goto err;Executed by:
executed 1 time by 1 test: goto err;Executed by:
| 1 | ||||||||||||
| 38 | } | - | ||||||||||||
| 39 | - | |||||||||||||
| 40 | - | |||||||||||||
| 41 | i = 0; | - | ||||||||||||
| 42 | while (in[--inlen] == '='
| 14699-26132 | ||||||||||||
| 43 | --outlen; | - | ||||||||||||
| 44 | if (++
| 1-26131 | ||||||||||||
| 45 | goto executed 1 time by 1 test: err;goto err;Executed by:
executed 1 time by 1 test: goto err;Executed by:
| 1 | ||||||||||||
| 46 | } executed 26131 times by 1 test: end of blockExecuted by:
| 26131 | ||||||||||||
| 47 | - | |||||||||||||
| 48 | *out = outbuf; | - | ||||||||||||
| 49 | return executed 14699 times by 1 test: outlen;return outlen;Executed by:
executed 14699 times by 1 test: return outlen;Executed by:
| 14699 | ||||||||||||
| 50 | err: | - | ||||||||||||
| 51 | CRYPTO_free(outbuf, __FILE__, 59); | - | ||||||||||||
| 52 | return executed 2 times by 1 test: -1;return -1;Executed by:
executed 2 times by 1 test: return -1;Executed by:
| 2 | ||||||||||||
| 53 | } | - | ||||||||||||
| 54 | - | |||||||||||||
| 55 | SCT *SCT_new_from_base64(unsigned char version, const char *logid_base64, | - | ||||||||||||
| 56 | ct_log_entry_type_t entry_type, uint64_t timestamp, | - | ||||||||||||
| 57 | const char *extensions_base64, | - | ||||||||||||
| 58 | const char *signature_base64) | - | ||||||||||||
| 59 | { | - | ||||||||||||
| 60 | SCT *sct = SCT_new(); | - | ||||||||||||
| 61 | unsigned char *dec = | - | ||||||||||||
| 62 | ((void *)0) | - | ||||||||||||
| 63 | ; | - | ||||||||||||
| 64 | const unsigned char* p = | - | ||||||||||||
| 65 | ((void *)0) | - | ||||||||||||
| 66 | ; | - | ||||||||||||
| 67 | int declen; | - | ||||||||||||
| 68 | - | |||||||||||||
| 69 | if (sct ==
| 0-1 | ||||||||||||
| 70 | ((void *)0)
| 0-1 | ||||||||||||
| 71 | ) { | - | ||||||||||||
| 72 | ERR_put_error(50,(127),((1|64)),__FILE__,74); | - | ||||||||||||
| 73 | return never executed: return ((void *)0) ;never executed: return ((void *)0) ; | 0 | ||||||||||||
| 74 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||
| 75 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||
| 76 | } | - | ||||||||||||
| 77 | - | |||||||||||||
| 78 | - | |||||||||||||
| 79 | - | |||||||||||||
| 80 | - | |||||||||||||
| 81 | - | |||||||||||||
| 82 | if (!SCT_set_version(sct, version)
| 0-1 | ||||||||||||
| 83 | ERR_put_error(50,(127),(115),__FILE__,83); | - | ||||||||||||
| 84 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||
| 85 | } | - | ||||||||||||
| 86 | - | |||||||||||||
| 87 | declen = ct_base64_decode(logid_base64, &dec); | - | ||||||||||||
| 88 | if (declen < 0
| 0-1 | ||||||||||||
| 89 | ERR_put_error(50,(127),(118),__FILE__,89); | - | ||||||||||||
| 90 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||
| 91 | } | - | ||||||||||||
| 92 | if (!SCT_set0_log_id(sct, dec, declen)
| 0-1 | ||||||||||||
| 93 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||
| 94 | dec = | - | ||||||||||||
| 95 | ((void *)0) | - | ||||||||||||
| 96 | ; | - | ||||||||||||
| 97 | - | |||||||||||||
| 98 | declen = ct_base64_decode(extensions_base64, &dec); | - | ||||||||||||
| 99 | if (declen < 0
| 0-1 | ||||||||||||
| 100 | ERR_put_error(50,(127),(118),__FILE__,98); | - | ||||||||||||
| 101 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||
| 102 | } | - | ||||||||||||
| 103 | SCT_set0_extensions(sct, dec, declen); | - | ||||||||||||
| 104 | dec = | - | ||||||||||||
| 105 | ((void *)0) | - | ||||||||||||
| 106 | ; | - | ||||||||||||
| 107 | - | |||||||||||||
| 108 | declen = ct_base64_decode(signature_base64, &dec); | - | ||||||||||||
| 109 | if (declen < 0
| 0-1 | ||||||||||||
| 110 | ERR_put_error(50,(127),(118),__FILE__,106); | - | ||||||||||||
| 111 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||
| 112 | } | - | ||||||||||||
| 113 | - | |||||||||||||
| 114 | p = dec; | - | ||||||||||||
| 115 | if (o2i_SCT_signature(sct, &p, declen) <= 0
| 0-1 | ||||||||||||
| 116 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||
| 117 | CRYPTO_free(dec, __FILE__, 113); | - | ||||||||||||
| 118 | dec = | - | ||||||||||||
| 119 | ((void *)0) | - | ||||||||||||
| 120 | ; | - | ||||||||||||
| 121 | - | |||||||||||||
| 122 | SCT_set_timestamp(sct, timestamp); | - | ||||||||||||
| 123 | - | |||||||||||||
| 124 | if (!SCT_set_log_entry_type(sct, entry_type)
| 0-1 | ||||||||||||
| 125 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||
| 126 | - | |||||||||||||
| 127 | return executed 1 time by 1 test: sct;return sct;Executed by:
executed 1 time by 1 test: return sct;Executed by:
| 1 | ||||||||||||
| 128 | - | |||||||||||||
| 129 | err: | - | ||||||||||||
| 130 | CRYPTO_free(dec, __FILE__, 124); | - | ||||||||||||
| 131 | SCT_free(sct); | - | ||||||||||||
| 132 | return never executed: return ((void *)0) ;never executed: return ((void *)0) ; | 0 | ||||||||||||
| 133 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||
| 134 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||
| 135 | } | - | ||||||||||||
| 136 | - | |||||||||||||
| 137 | - | |||||||||||||
| 138 | - | |||||||||||||
| 139 | - | |||||||||||||
| 140 | - | |||||||||||||
| 141 | - | |||||||||||||
| 142 | - | |||||||||||||
| 143 | int CTLOG_new_from_base64(CTLOG **ct_log, const char *pkey_base64, const char *name) | - | ||||||||||||
| 144 | { | - | ||||||||||||
| 145 | unsigned char *pkey_der = | - | ||||||||||||
| 146 | ((void *)0) | - | ||||||||||||
| 147 | ; | - | ||||||||||||
| 148 | int pkey_der_len; | - | ||||||||||||
| 149 | const unsigned char *p; | - | ||||||||||||
| 150 | EVP_PKEY *pkey = | - | ||||||||||||
| 151 | ((void *)0) | - | ||||||||||||
| 152 | ; | - | ||||||||||||
| 153 | - | |||||||||||||
| 154 | if (ct_log ==
| 0-14699 | ||||||||||||
| 155 | ((void *)0)
| 0-14699 | ||||||||||||
| 156 | ) { | - | ||||||||||||
| 157 | ERR_put_error(50,(118),((7)),__FILE__,143); | - | ||||||||||||
| 158 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 159 | } | - | ||||||||||||
| 160 | - | |||||||||||||
| 161 | pkey_der_len = ct_base64_decode(pkey_base64, &pkey_der); | - | ||||||||||||
| 162 | if (pkey_der_len < 0
| 2-14697 | ||||||||||||
| 163 | ERR_put_error(50,(118),(110),__FILE__,149); | - | ||||||||||||
| 164 | return executed 2 times by 1 test: 0;return 0;Executed by:
executed 2 times by 1 test: return 0;Executed by:
| 2 | ||||||||||||
| 165 | } | - | ||||||||||||
| 166 | - | |||||||||||||
| 167 | p = pkey_der; | - | ||||||||||||
| 168 | pkey = d2i_PUBKEY( | - | ||||||||||||
| 169 | ((void *)0) | - | ||||||||||||
| 170 | , &p, pkey_der_len); | - | ||||||||||||
| 171 | CRYPTO_free(pkey_der, __FILE__, 155); | - | ||||||||||||
| 172 | if (pkey ==
| 0-14697 | ||||||||||||
| 173 | ((void *)0)
| 0-14697 | ||||||||||||
| 174 | ) { | - | ||||||||||||
| 175 | ERR_put_error(50,(118),(110),__FILE__,157); | - | ||||||||||||
| 176 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 177 | } | - | ||||||||||||
| 178 | - | |||||||||||||
| 179 | *ct_log = CTLOG_new(pkey, name); | - | ||||||||||||
| 180 | if (*
| 0-14697 | ||||||||||||
| 181 | ((void *)0)
| 0-14697 | ||||||||||||
| 182 | ) { | - | ||||||||||||
| 183 | EVP_PKEY_free(pkey); | - | ||||||||||||
| 184 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 185 | } | - | ||||||||||||
| 186 | - | |||||||||||||
| 187 | return executed 14697 times by 1 test: 1;return 1;Executed by:
executed 14697 times by 1 test: return 1;Executed by:
| 14697 | ||||||||||||
| 188 | } | - | ||||||||||||
| Switch to Source code | Preprocessed file |