| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/pkcs12/p12_key.c | 
| Switch to Source code | Preprocessed file | 
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | int PKCS12_key_gen_asc(const char *pass, int passlen, unsigned char *salt, | - | ||||||||||||
| 2 | int saltlen, int id, int iter, int n, | - | ||||||||||||
| 3 | unsigned char *out, const EVP_MD *md_type) | - | ||||||||||||
| 4 | { | - | ||||||||||||
| 5 | int ret; | - | ||||||||||||
| 6 | unsigned char *unipass; | - | ||||||||||||
| 7 | int uniplen; | - | ||||||||||||
| 8 | - | |||||||||||||
| 9 |     if (!pass
  | 0 | ||||||||||||
| 10 | unipass = | - | ||||||||||||
| 11 | ((void *)0) | - | ||||||||||||
| 12 | ; | - | ||||||||||||
| 13 | uniplen = 0; | - | ||||||||||||
| 14 |     } never executed:   else if (!OPENSSL_asc2uni(pass, passlen, &unipass, &uniplen)end of block
  | 0 | ||||||||||||
| 15 | ERR_put_error(35,(110),((1|64)),__FILE__,42); | - | ||||||||||||
| 16 |         return never executed:   0;return 0;never executed:  return 0; | 0 | ||||||||||||
| 17 | } | - | ||||||||||||
| 18 | ret = PKCS12_key_gen_uni(unipass, uniplen, salt, saltlen, | - | ||||||||||||
| 19 | id, iter, n, out, md_type); | - | ||||||||||||
| 20 |     if (ret <= 0
  | 0 | ||||||||||||
| 21 |         return never executed:   0;return 0;never executed:  return 0; | 0 | ||||||||||||
| 22 | CRYPTO_clear_free(unipass, uniplen, __FILE__, 49); | - | ||||||||||||
| 23 |     return never executed:   ret;return ret;never executed:  return ret; | 0 | ||||||||||||
| 24 | } | - | ||||||||||||
| 25 | - | |||||||||||||
| 26 | int PKCS12_key_gen_utf8(const char *pass, int passlen, unsigned char *salt, | - | ||||||||||||
| 27 | int saltlen, int id, int iter, int n, | - | ||||||||||||
| 28 | unsigned char *out, const EVP_MD *md_type) | - | ||||||||||||
| 29 | { | - | ||||||||||||
| 30 | int ret; | - | ||||||||||||
| 31 | unsigned char *unipass; | - | ||||||||||||
| 32 | int uniplen; | - | ||||||||||||
| 33 | - | |||||||||||||
| 34 |     if (!pass
  | 0-1 | ||||||||||||
| 35 | unipass = | - | ||||||||||||
| 36 | ((void *)0) | - | ||||||||||||
| 37 | ; | - | ||||||||||||
| 38 | uniplen = 0; | - | ||||||||||||
| 39 |     } never executed:   else if (!OPENSSL_utf82uni(pass, passlen, &unipass, &uniplen)end of block
  | 0-1 | ||||||||||||
| 40 | ERR_put_error(35,(116),((1|64)),__FILE__,65); | - | ||||||||||||
| 41 |         return never executed:   0;return 0;never executed:  return 0; | 0 | ||||||||||||
| 42 | } | - | ||||||||||||
| 43 | ret = PKCS12_key_gen_uni(unipass, uniplen, salt, saltlen, | - | ||||||||||||
| 44 | id, iter, n, out, md_type); | - | ||||||||||||
| 45 |     if (ret <= 0
  | 0-1 | ||||||||||||
| 46 |         return never executed:   0;return 0;never executed:  return 0; | 0 | ||||||||||||
| 47 | CRYPTO_clear_free(unipass, uniplen, __FILE__, 72); | - | ||||||||||||
| 48 |     return executed 1 time by 1 test:   ret;return ret;Executed by: 
 executed 1 time by 1 test:  return ret;Executed by: 
  | 1 | ||||||||||||
| 49 | } | - | ||||||||||||
| 50 | - | |||||||||||||
| 51 | int PKCS12_key_gen_uni(unsigned char *pass, int passlen, unsigned char *salt, | - | ||||||||||||
| 52 | int saltlen, int id, int iter, int n, | - | ||||||||||||
| 53 | unsigned char *out, const EVP_MD *md_type) | - | ||||||||||||
| 54 | { | - | ||||||||||||
| 55 | unsigned char *B = | - | ||||||||||||
| 56 | ((void *)0) | - | ||||||||||||
| 57 | , *D = | - | ||||||||||||
| 58 | ((void *)0) | - | ||||||||||||
| 59 | , *I = | - | ||||||||||||
| 60 | ((void *)0) | - | ||||||||||||
| 61 | , *p = | - | ||||||||||||
| 62 | ((void *)0) | - | ||||||||||||
| 63 | , *Ai = | - | ||||||||||||
| 64 | ((void *)0) | - | ||||||||||||
| 65 | ; | - | ||||||||||||
| 66 | int Slen, Plen, Ilen; | - | ||||||||||||
| 67 | int i, j, u, v; | - | ||||||||||||
| 68 | int ret = 0; | - | ||||||||||||
| 69 | EVP_MD_CTX *ctx = | - | ||||||||||||
| 70 | ((void *)0) | - | ||||||||||||
| 71 | ; | - | ||||||||||||
| 72 | - | |||||||||||||
| 73 | - | |||||||||||||
| 74 | - | |||||||||||||
| 75 | - | |||||||||||||
| 76 | - | |||||||||||||
| 77 | ctx = EVP_MD_CTX_new(); | - | ||||||||||||
| 78 |     if (ctx == 
  | 0-7 | ||||||||||||
| 79 |               ((void *)0)
  | 0-7 | ||||||||||||
| 80 | ) | - | ||||||||||||
| 81 |         goto never executed:   err;goto err;never executed:  goto err; | 0 | ||||||||||||
| 82 | v = EVP_MD_block_size(md_type); | - | ||||||||||||
| 83 | u = EVP_MD_size(md_type); | - | ||||||||||||
| 84 |     if (u < 0
 
  | 0-7 | ||||||||||||
| 85 |         goto never executed:   err;goto err;never executed:  goto err; | 0 | ||||||||||||
| 86 | D = CRYPTO_malloc(v, __FILE__, 106); | - | ||||||||||||
| 87 | Ai = CRYPTO_malloc(u, __FILE__, 107); | - | ||||||||||||
| 88 | B = CRYPTO_malloc(v + 1, __FILE__, 108); | - | ||||||||||||
| 89 | Slen = v * ((saltlen + v - 1) / v); | - | ||||||||||||
| 90 |     if (passlen
  | 0-7 | ||||||||||||
| 91 |         Plen = v * ((passlen + v - 1) / v); executed 7 times by 1 test:  Plen = v * ((passlen + v - 1) / v);Executed by: 
  | 7 | ||||||||||||
| 92 | else | - | ||||||||||||
| 93 |         Plen = 0; never executed:  Plen = 0; | 0 | ||||||||||||
| 94 | Ilen = Slen + Plen; | - | ||||||||||||
| 95 | I = CRYPTO_malloc(Ilen, __FILE__, 115); | - | ||||||||||||
| 96 |     if (D == 
  | 0-7 | ||||||||||||
| 97 |             ((void *)0)
  | 0-7 | ||||||||||||
| 98 |                  || Ai == 
  | 0-7 | ||||||||||||
| 99 |                           ((void *)0)
  | 0-7 | ||||||||||||
| 100 |                                || B == 
  | 0-7 | ||||||||||||
| 101 |                                        ((void *)0)
  | 0-7 | ||||||||||||
| 102 |                                             || I == 
  | 0-7 | ||||||||||||
| 103 |                                                     ((void *)0)
  | 0-7 | ||||||||||||
| 104 | ) | - | ||||||||||||
| 105 |         goto never executed:   err;goto err;never executed:  goto err; | 0 | ||||||||||||
| 106 |     for (i = 0; i < v
  | 7-448 | ||||||||||||
| 107 |         D[i] = id; executed 448 times by 1 test:  D[i] = id;Executed by: 
  | 448 | ||||||||||||
| 108 | p = I; | - | ||||||||||||
| 109 |     for (i = 0; i < Slen
  | 7-448 | ||||||||||||
| 110 |         * executed 448 times by 1 test:  p++ = salt[i % saltlen];*p++ = salt[i % saltlen];Executed by: 
 executed 448 times by 1 test:  *p++ = salt[i % saltlen];Executed by: 
  | 448 | ||||||||||||
| 111 |     for (i = 0; i < Plen
  | 7-448 | ||||||||||||
| 112 |         * executed 448 times by 1 test:  p++ = pass[i % passlen];*p++ = pass[i % passlen];Executed by: 
 executed 448 times by 1 test:  *p++ = pass[i % passlen];Executed by: 
  | 448 | ||||||||||||
| 113 | for (;;) { | - | ||||||||||||
| 114 |         if (!EVP_DigestInit_ex(ctx, md_type, 
  | 0-9 | ||||||||||||
| 115 |                                             ((void *)0)
  | 0-9 | ||||||||||||
| 116 |                                                 )
  | 0-9 | ||||||||||||
| 117 |             || !EVP_DigestUpdate(ctx, D, v)
  | 0-9 | ||||||||||||
| 118 |             || !EVP_DigestUpdate(ctx, I, Ilen)
  | 0-9 | ||||||||||||
| 119 |             || !EVP_DigestFinal_ex(ctx, Ai, 
  | 0-9 | ||||||||||||
| 120 |                                            ((void *)0)
  | 0-9 | ||||||||||||
| 121 |                                                )
  | 0-9 | ||||||||||||
| 122 |             goto never executed:   err;goto err;never executed:  goto err; | 0 | ||||||||||||
| 123 |         for (j = 1; j < iter
  | 9-5995 | ||||||||||||
| 124 |             if (!EVP_DigestInit_ex(ctx, md_type, 
  | 0-5995 | ||||||||||||
| 125 |                                                 ((void *)0)
  | 0-5995 | ||||||||||||
| 126 |                                                     )
  | 0-5995 | ||||||||||||
| 127 |                 || !EVP_DigestUpdate(ctx, Ai, u)
  | 0-5995 | ||||||||||||
| 128 |                 || !EVP_DigestFinal_ex(ctx, Ai, 
  | 0-5995 | ||||||||||||
| 129 |                                                ((void *)0)
  | 0-5995 | ||||||||||||
| 130 |                                                    )
  | 0-5995 | ||||||||||||
| 131 |                 goto never executed:   err;goto err;never executed:  goto err; | 0 | ||||||||||||
| 132 |         } executed 5995 times by 1 test:  end of blockExecuted by: 
  | 5995 | ||||||||||||
| 133 | memcpy(out, Ai, ((n) < (u) ? (n) : (u))); | - | ||||||||||||
| 134 |         if (u >= n
  | 2-7 | ||||||||||||
| 135 | - | |||||||||||||
| 136 | - | |||||||||||||
| 137 | - | |||||||||||||
| 138 | - | |||||||||||||
| 139 | ret = 1; | - | ||||||||||||
| 140 |             goto executed 7 times by 1 test:   end;goto end;Executed by: 
 executed 7 times by 1 test:  goto end;Executed by: 
  | 7 | ||||||||||||
| 141 | } | - | ||||||||||||
| 142 | n -= u; | - | ||||||||||||
| 143 | out += u; | - | ||||||||||||
| 144 |         for (j = 0; j < v
  | 2-128 | ||||||||||||
| 145 |             B[j] = Ai[j % u]; executed 128 times by 1 test:  B[j] = Ai[j % u];Executed by: 
  | 128 | ||||||||||||
| 146 |         for (j = 0; j < Ilen
  | 2-4 | ||||||||||||
| 147 | int k; | - | ||||||||||||
| 148 | unsigned char *Ij = I + j; | - | ||||||||||||
| 149 | uint16_t c = 1; | - | ||||||||||||
| 150 | - | |||||||||||||
| 151 | - | |||||||||||||
| 152 |             for (k = v - 1; k >= 0
  | 4-256 | ||||||||||||
| 153 | c += Ij[k] + B[k]; | - | ||||||||||||
| 154 | Ij[k] = (unsigned char)c; | - | ||||||||||||
| 155 | c >>= 8; | - | ||||||||||||
| 156 |             } executed 256 times by 1 test:  end of blockExecuted by: 
  | 256 | ||||||||||||
| 157 |         } executed 4 times by 1 test:  end of blockExecuted by: 
  | 4 | ||||||||||||
| 158 |     } executed 2 times by 1 test:  end of blockExecuted by: 
  | 2 | ||||||||||||
| 159 | - | |||||||||||||
| 160 |  err: code before this statement never executed:  err: | 0 | ||||||||||||
| 161 | ERR_put_error(35,(111),((1|64)),__FILE__,165); | - | ||||||||||||
| 162 | - | |||||||||||||
| 163 |  end: code before this statement never executed:  end: | 0 | ||||||||||||
| 164 | CRYPTO_free(Ai, __FILE__, 168); | - | ||||||||||||
| 165 | CRYPTO_free(B, __FILE__, 169); | - | ||||||||||||
| 166 | CRYPTO_free(D, __FILE__, 170); | - | ||||||||||||
| 167 | CRYPTO_free(I, __FILE__, 171); | - | ||||||||||||
| 168 | EVP_MD_CTX_free(ctx); | - | ||||||||||||
| 169 |     return executed 7 times by 1 test:   ret;return ret;Executed by: 
 executed 7 times by 1 test:  return ret;Executed by: 
  | 7 | ||||||||||||
| 170 | } | - | ||||||||||||
| Switch to Source code | Preprocessed file |