| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/libressl/src/crypto/aes/aes_wrap.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||||||||
| 2 | - | |||||||||||||||||||||||||
| 3 | static const unsigned char default_iv[] = { | - | ||||||||||||||||||||||||
| 4 | 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, | - | ||||||||||||||||||||||||
| 5 | }; | - | ||||||||||||||||||||||||
| 6 | - | |||||||||||||||||||||||||
| 7 | int | - | ||||||||||||||||||||||||
| 8 | AES_wrap_key(AES_KEY *key, const unsigned char *iv, unsigned char *out, | - | ||||||||||||||||||||||||
| 9 | const unsigned char *in, unsigned int inlen) | - | ||||||||||||||||||||||||
| 10 | { | - | ||||||||||||||||||||||||
| 11 | unsigned char *A, B[16], *R; | - | ||||||||||||||||||||||||
| 12 | unsigned int i, j, t; | - | ||||||||||||||||||||||||
| 13 | if ((
| 0-6 | ||||||||||||||||||||||||
| 14 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||
| 15 | A = B; | - | ||||||||||||||||||||||||
| 16 | t = 1; | - | ||||||||||||||||||||||||
| 17 | memcpy(out + 8, in, inlen); | - | ||||||||||||||||||||||||
| 18 | if (!iv
| 0-6 | ||||||||||||||||||||||||
| 19 | iv = default_iv; executed 6 times by 1 test: iv = default_iv;Executed by:
| 6 | ||||||||||||||||||||||||
| 20 | - | |||||||||||||||||||||||||
| 21 | memcpy(A, iv, 8); | - | ||||||||||||||||||||||||
| 22 | - | |||||||||||||||||||||||||
| 23 | for (j = 0; j < 6
| 6-36 | ||||||||||||||||||||||||
| 24 | R = out + 8; | - | ||||||||||||||||||||||||
| 25 | for (i = 0; i < inlen
| 36-96 | ||||||||||||||||||||||||
| 26 | memcpy(B + 8, R, 8); | - | ||||||||||||||||||||||||
| 27 | AES_encrypt(B, B, key); | - | ||||||||||||||||||||||||
| 28 | A[7] ^= (unsigned char)(t & 0xff); | - | ||||||||||||||||||||||||
| 29 | if (t > 0xff
| 0-96 | ||||||||||||||||||||||||
| 30 | A[6] ^= (unsigned char)((t >> 8) & 0xff); | - | ||||||||||||||||||||||||
| 31 | A[5] ^= (unsigned char)((t >> 16) & 0xff); | - | ||||||||||||||||||||||||
| 32 | A[4] ^= (unsigned char)((t >> 24) & 0xff); | - | ||||||||||||||||||||||||
| 33 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 34 | memcpy(R, B + 8, 8); | - | ||||||||||||||||||||||||
| 35 | } executed 96 times by 1 test: end of blockExecuted by:
| 96 | ||||||||||||||||||||||||
| 36 | } executed 36 times by 1 test: end of blockExecuted by:
| 36 | ||||||||||||||||||||||||
| 37 | memcpy(out, A, 8); | - | ||||||||||||||||||||||||
| 38 | return executed 6 times by 1 test: inlen + 8;return inlen + 8;Executed by:
executed 6 times by 1 test: return inlen + 8;Executed by:
| 6 | ||||||||||||||||||||||||
| 39 | } | - | ||||||||||||||||||||||||
| 40 | - | |||||||||||||||||||||||||
| 41 | int | - | ||||||||||||||||||||||||
| 42 | AES_unwrap_key(AES_KEY *key, const unsigned char *iv, unsigned char *out, | - | ||||||||||||||||||||||||
| 43 | const unsigned char *in, unsigned int inlen) | - | ||||||||||||||||||||||||
| 44 | { | - | ||||||||||||||||||||||||
| 45 | unsigned char *A, B[16], *R; | - | ||||||||||||||||||||||||
| 46 | unsigned int i, j, t; | - | ||||||||||||||||||||||||
| 47 | inlen -= 8; | - | ||||||||||||||||||||||||
| 48 | if (inlen & 0x7
| 0-6 | ||||||||||||||||||||||||
| 49 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||
| 50 | if (inlen < 8
| 0-6 | ||||||||||||||||||||||||
| 51 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||
| 52 | A = B; | - | ||||||||||||||||||||||||
| 53 | t = 6 * (inlen >> 3); | - | ||||||||||||||||||||||||
| 54 | memcpy(A, in, 8); | - | ||||||||||||||||||||||||
| 55 | memcpy(out, in + 8, inlen); | - | ||||||||||||||||||||||||
| 56 | for (j = 0; j < 6
| 6-36 | ||||||||||||||||||||||||
| 57 | R = out + inlen - 8; | - | ||||||||||||||||||||||||
| 58 | for (i = 0; i < inlen
| 36-96 | ||||||||||||||||||||||||
| 59 | A[7] ^= (unsigned char)(t & 0xff); | - | ||||||||||||||||||||||||
| 60 | if (t > 0xff
| 0-96 | ||||||||||||||||||||||||
| 61 | A[6] ^= (unsigned char)((t >> 8) & 0xff); | - | ||||||||||||||||||||||||
| 62 | A[5] ^= (unsigned char)((t >> 16) & 0xff); | - | ||||||||||||||||||||||||
| 63 | A[4] ^= (unsigned char)((t >> 24) & 0xff); | - | ||||||||||||||||||||||||
| 64 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 65 | memcpy(B + 8, R, 8); | - | ||||||||||||||||||||||||
| 66 | AES_decrypt(B, B, key); | - | ||||||||||||||||||||||||
| 67 | memcpy(R, B + 8, 8); | - | ||||||||||||||||||||||||
| 68 | } executed 96 times by 1 test: end of blockExecuted by:
| 96 | ||||||||||||||||||||||||
| 69 | } executed 36 times by 1 test: end of blockExecuted by:
| 36 | ||||||||||||||||||||||||
| 70 | if (!iv
| 0-6 | ||||||||||||||||||||||||
| 71 | iv = default_iv; executed 6 times by 1 test: iv = default_iv;Executed by:
| 6 | ||||||||||||||||||||||||
| 72 | if (memcmp(A, iv, 8)
| 0-6 | ||||||||||||||||||||||||
| 73 | explicit_bzero(out, inlen); | - | ||||||||||||||||||||||||
| 74 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 75 | } | - | ||||||||||||||||||||||||
| 76 | return executed 6 times by 1 test: inlen;return inlen;Executed by:
executed 6 times by 1 test: return inlen;Executed by:
| 6 | ||||||||||||||||||||||||
| 77 | } | - | ||||||||||||||||||||||||
| Switch to Source code | Preprocessed file |