OpenCoverage

aes_wrap.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/libressl/src/crypto/aes/aes_wrap.c
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3static const unsigned char default_iv[] = {-
4 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6,-
5};-
6-
7int-
8AES_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 ((
(inlen & 0x7)Description
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • aes_wrap
inlen & 0x7)
(inlen & 0x7)Description
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • aes_wrap
|| (
(inlen < 8)Description
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • aes_wrap
inlen < 8)
(inlen < 8)Description
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • aes_wrap
)
0-6
14 return
never executed: return -1;
-1;
never executed: return -1;
0
15 A = B;-
16 t = 1;-
17 memcpy(out + 8, in, inlen);-
18 if (!iv
!ivDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • aes_wrap
FALSEnever evaluated
)
0-6
19 iv = default_iv;
executed 6 times by 1 test: iv = default_iv;
Executed by:
  • aes_wrap
6
20-
21 memcpy(A, iv, 8);-
22-
23 for (j = 0; j < 6
j < 6Description
TRUEevaluated 36 times by 1 test
Evaluated by:
  • aes_wrap
FALSEevaluated 6 times by 1 test
Evaluated by:
  • aes_wrap
; j++) {
6-36
24 R = out + 8;-
25 for (i = 0; i < inlen
i < inlenDescription
TRUEevaluated 96 times by 1 test
Evaluated by:
  • aes_wrap
FALSEevaluated 36 times by 1 test
Evaluated by:
  • aes_wrap
; i += 8, t++, R += 8) {
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
t > 0xffDescription
TRUEnever evaluated
FALSEevaluated 96 times by 1 test
Evaluated by:
  • aes_wrap
) {
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 block
Executed by:
  • aes_wrap
96
36 }
executed 36 times by 1 test: end of block
Executed by:
  • aes_wrap
36
37 memcpy(out, A, 8);-
38 return
executed 6 times by 1 test: return inlen + 8;
Executed by:
  • aes_wrap
inlen + 8;
executed 6 times by 1 test: return inlen + 8;
Executed by:
  • aes_wrap
6
39}-
40-
41int-
42AES_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
inlen & 0x7Description
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • aes_wrap
)
0-6
49 return
never executed: return -1;
-1;
never executed: return -1;
0
50 if (inlen < 8
inlen < 8Description
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • aes_wrap
)
0-6
51 return
never executed: return -1;
-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
j < 6Description
TRUEevaluated 36 times by 1 test
Evaluated by:
  • aes_wrap
FALSEevaluated 6 times by 1 test
Evaluated by:
  • aes_wrap
; j++) {
6-36
57 R = out + inlen - 8;-
58 for (i = 0; i < inlen
i < inlenDescription
TRUEevaluated 96 times by 1 test
Evaluated by:
  • aes_wrap
FALSEevaluated 36 times by 1 test
Evaluated by:
  • aes_wrap
; i += 8, t--, R -= 8) {
36-96
59 A[7] ^= (unsigned char)(t & 0xff);-
60 if (t > 0xff
t > 0xffDescription
TRUEnever evaluated
FALSEevaluated 96 times by 1 test
Evaluated by:
  • aes_wrap
) {
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 block
Executed by:
  • aes_wrap
96
69 }
executed 36 times by 1 test: end of block
Executed by:
  • aes_wrap
36
70 if (!iv
!ivDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • aes_wrap
FALSEnever evaluated
)
0-6
71 iv = default_iv;
executed 6 times by 1 test: iv = default_iv;
Executed by:
  • aes_wrap
6
72 if (memcmp(A, iv, 8)
memcmp(A, iv, 8)Description
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • aes_wrap
) {
0-6
73 explicit_bzero(out, inlen);-
74 return
never executed: return 0;
0;
never executed: return 0;
0
75 }-
76 return
executed 6 times by 1 test: return inlen;
Executed by:
  • aes_wrap
inlen;
executed 6 times by 1 test: return inlen;
Executed by:
  • aes_wrap
6
77}-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.2