| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssh/src/openbsd-compat/bcrypt_pbkdf.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||
| 2 | - | |||||||||||||||||||
| 3 | - | |||||||||||||||||||
| 4 | - | |||||||||||||||||||
| 5 | - | |||||||||||||||||||
| 6 | static void | - | ||||||||||||||||||
| 7 | bcrypt_hash(u_int8_t *sha2pass, u_int8_t *sha2salt, u_int8_t *out) | - | ||||||||||||||||||
| 8 | { | - | ||||||||||||||||||
| 9 | blf_ctx state; | - | ||||||||||||||||||
| 10 | u_int8_t ciphertext[(8 * 4)] = | - | ||||||||||||||||||
| 11 | "OxychromaticBlowfishSwatDynamite"; | - | ||||||||||||||||||
| 12 | uint32_t cdata[8]; | - | ||||||||||||||||||
| 13 | int i; | - | ||||||||||||||||||
| 14 | uint16_t j; | - | ||||||||||||||||||
| 15 | size_t shalen = 64U; | - | ||||||||||||||||||
| 16 | - | |||||||||||||||||||
| 17 | - | |||||||||||||||||||
| 18 | Blowfish_initstate(&state); | - | ||||||||||||||||||
| 19 | Blowfish_expandstate(&state, sha2salt, shalen, sha2pass, shalen); | - | ||||||||||||||||||
| 20 | for (i = 0; i < 64
| 128-8192 | ||||||||||||||||||
| 21 | Blowfish_expand0state(&state, sha2salt, shalen); | - | ||||||||||||||||||
| 22 | Blowfish_expand0state(&state, sha2pass, shalen); | - | ||||||||||||||||||
| 23 | } executed 8192 times by 1 test: end of blockExecuted by:
| 8192 | ||||||||||||||||||
| 24 | - | |||||||||||||||||||
| 25 | - | |||||||||||||||||||
| 26 | j = 0; | - | ||||||||||||||||||
| 27 | for (i = 0; i < 8
| 128-1024 | ||||||||||||||||||
| 28 | cdata[i] = Blowfish_stream2word(ciphertext, sizeof(ciphertext), executed 1024 times by 1 test: cdata[i] = Blowfish_stream2word(ciphertext, sizeof(ciphertext), &j);Executed by:
| 1024 | ||||||||||||||||||
| 29 | &j); executed 1024 times by 1 test: cdata[i] = Blowfish_stream2word(ciphertext, sizeof(ciphertext), &j);Executed by:
| 1024 | ||||||||||||||||||
| 30 | for (i = 0; i < 64
| 128-8192 | ||||||||||||||||||
| 31 | blf_enc(&state, cdata, sizeof(cdata) / sizeof(uint64_t)); executed 8192 times by 1 test: blf_enc(&state, cdata, sizeof(cdata) / sizeof(uint64_t));Executed by:
| 8192 | ||||||||||||||||||
| 32 | - | |||||||||||||||||||
| 33 | - | |||||||||||||||||||
| 34 | for (i = 0; i < 8
| 128-1024 | ||||||||||||||||||
| 35 | out[4 * i + 3] = (cdata[i] >> 24) & 0xff; | - | ||||||||||||||||||
| 36 | out[4 * i + 2] = (cdata[i] >> 16) & 0xff; | - | ||||||||||||||||||
| 37 | out[4 * i + 1] = (cdata[i] >> 8) & 0xff; | - | ||||||||||||||||||
| 38 | out[4 * i + 0] = cdata[i] & 0xff; | - | ||||||||||||||||||
| 39 | } executed 1024 times by 1 test: end of blockExecuted by:
| 1024 | ||||||||||||||||||
| 40 | - | |||||||||||||||||||
| 41 | - | |||||||||||||||||||
| 42 | explicit_bzero(ciphertext, sizeof(ciphertext)); | - | ||||||||||||||||||
| 43 | explicit_bzero(cdata, sizeof(cdata)); | - | ||||||||||||||||||
| 44 | explicit_bzero(&state, sizeof(state)); | - | ||||||||||||||||||
| 45 | } executed 128 times by 1 test: end of blockExecuted by:
| 128 | ||||||||||||||||||
| 46 | - | |||||||||||||||||||
| 47 | int | - | ||||||||||||||||||
| 48 | bcrypt_pbkdf(const char *pass, size_t passlen, const u_int8_t *salt, size_t saltlen, | - | ||||||||||||||||||
| 49 | u_int8_t *key, size_t keylen, unsigned int rounds) | - | ||||||||||||||||||
| 50 | { | - | ||||||||||||||||||
| 51 | u_int8_t sha2pass[64U]; | - | ||||||||||||||||||
| 52 | u_int8_t sha2salt[64U]; | - | ||||||||||||||||||
| 53 | u_int8_t out[(8 * 4)]; | - | ||||||||||||||||||
| 54 | u_int8_t tmpout[(8 * 4)]; | - | ||||||||||||||||||
| 55 | u_int8_t *countsalt; | - | ||||||||||||||||||
| 56 | size_t i, j, amt, stride; | - | ||||||||||||||||||
| 57 | uint32_t count; | - | ||||||||||||||||||
| 58 | size_t origkeylen = keylen; | - | ||||||||||||||||||
| 59 | - | |||||||||||||||||||
| 60 | - | |||||||||||||||||||
| 61 | if (rounds < 1
| 0-4 | ||||||||||||||||||
| 62 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||
| 63 | if (passlen == 0
| 0-4 | ||||||||||||||||||
| 64 | keylen > sizeof(out) * sizeof(out)
| 0-4 | ||||||||||||||||||
| 65 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||
| 66 | if ((
| 0-4 | ||||||||||||||||||
| 67 | ((void *)0)
| 0-4 | ||||||||||||||||||
| 68 | ) | - | ||||||||||||||||||
| 69 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||
| 70 | stride = (keylen + sizeof(out) - 1) / sizeof(out); | - | ||||||||||||||||||
| 71 | amt = (keylen + stride - 1) / stride; | - | ||||||||||||||||||
| 72 | - | |||||||||||||||||||
| 73 | memcpy(countsalt, salt, saltlen); | - | ||||||||||||||||||
| 74 | - | |||||||||||||||||||
| 75 | - | |||||||||||||||||||
| 76 | crypto_hash_sha512(sha2pass, pass, passlen); | - | ||||||||||||||||||
| 77 | - | |||||||||||||||||||
| 78 | - | |||||||||||||||||||
| 79 | for (count = 1; keylen > 0
| 4-8 | ||||||||||||||||||
| 80 | countsalt[saltlen + 0] = (count >> 24) & 0xff; | - | ||||||||||||||||||
| 81 | countsalt[saltlen + 1] = (count >> 16) & 0xff; | - | ||||||||||||||||||
| 82 | countsalt[saltlen + 2] = (count >> 8) & 0xff; | - | ||||||||||||||||||
| 83 | countsalt[saltlen + 3] = count & 0xff; | - | ||||||||||||||||||
| 84 | - | |||||||||||||||||||
| 85 | - | |||||||||||||||||||
| 86 | crypto_hash_sha512(sha2salt, countsalt, saltlen + 4); | - | ||||||||||||||||||
| 87 | - | |||||||||||||||||||
| 88 | bcrypt_hash(sha2pass, sha2salt, tmpout); | - | ||||||||||||||||||
| 89 | memcpy(out, tmpout, sizeof(out)); | - | ||||||||||||||||||
| 90 | - | |||||||||||||||||||
| 91 | for (i = 1; i < rounds
| 8-120 | ||||||||||||||||||
| 92 | - | |||||||||||||||||||
| 93 | crypto_hash_sha512(sha2salt, tmpout, sizeof(tmpout)); | - | ||||||||||||||||||
| 94 | bcrypt_hash(sha2pass, sha2salt, tmpout); | - | ||||||||||||||||||
| 95 | for (j = 0; j < sizeof(out)
| 120-3840 | ||||||||||||||||||
| 96 | out[j] ^= tmpout[j]; executed 3840 times by 1 test: out[j] ^= tmpout[j];Executed by:
| 3840 | ||||||||||||||||||
| 97 | } executed 120 times by 1 test: end of blockExecuted by:
| 120 | ||||||||||||||||||
| 98 | - | |||||||||||||||||||
| 99 | - | |||||||||||||||||||
| 100 | - | |||||||||||||||||||
| 101 | - | |||||||||||||||||||
| 102 | amt = (((
| 4 | ||||||||||||||||||
| 103 | for (i = 0; i < amt
| 8-192 | ||||||||||||||||||
| 104 | size_t dest = i * stride + (count - 1); | - | ||||||||||||||||||
| 105 | if (dest >= origkeylen
| 0-192 | ||||||||||||||||||
| 106 | break; never executed: break; | 0 | ||||||||||||||||||
| 107 | key[dest] = out[i]; | - | ||||||||||||||||||
| 108 | } executed 192 times by 1 test: end of blockExecuted by:
| 192 | ||||||||||||||||||
| 109 | keylen -= i; | - | ||||||||||||||||||
| 110 | } executed 8 times by 1 test: end of blockExecuted by:
| 8 | ||||||||||||||||||
| 111 | - | |||||||||||||||||||
| 112 | - | |||||||||||||||||||
| 113 | explicit_bzero(out, sizeof(out)); | - | ||||||||||||||||||
| 114 | free(countsalt); | - | ||||||||||||||||||
| 115 | - | |||||||||||||||||||
| 116 | return executed 4 times by 1 test: 0;return 0;Executed by:
executed 4 times by 1 test: return 0;Executed by:
| 4 | ||||||||||||||||||
| 117 | } | - | ||||||||||||||||||
| Switch to Source code | Preprocessed file |