Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/libressl/src/crypto/evp/e_idea.c |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||||||||||||||
2 | - | |||||||||||||||||||||||||||||||
3 | - | |||||||||||||||||||||||||||||||
4 | - | |||||||||||||||||||||||||||||||
5 | - | |||||||||||||||||||||||||||||||
6 | - | |||||||||||||||||||||||||||||||
7 | - | |||||||||||||||||||||||||||||||
8 | static int idea_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, | - | ||||||||||||||||||||||||||||||
9 | const unsigned char *iv, int enc); | - | ||||||||||||||||||||||||||||||
10 | - | |||||||||||||||||||||||||||||||
11 | - | |||||||||||||||||||||||||||||||
12 | - | |||||||||||||||||||||||||||||||
13 | - | |||||||||||||||||||||||||||||||
14 | - | |||||||||||||||||||||||||||||||
15 | static int | - | ||||||||||||||||||||||||||||||
16 | idea_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | - | ||||||||||||||||||||||||||||||
17 | const unsigned char *in, size_t inl) | - | ||||||||||||||||||||||||||||||
18 | { | - | ||||||||||||||||||||||||||||||
19 | size_t i, bl; bl = ctx->cipher->block_size; if(inl < bl
never executed: 1;return 1; never executed: inl -= bl; for(i=0; i <= inlreturn 1;
| 0 | ||||||||||||||||||||||||||||||
20 | idea_ecb_encrypt(in + i, out + i, ctx->cipher_data); never executed: idea_ecb_encrypt(in + i, out + i, ctx->cipher_data); | 0 | ||||||||||||||||||||||||||||||
21 | return never executed: 1;return 1; never executed: return 1; | 0 | ||||||||||||||||||||||||||||||
22 | } | - | ||||||||||||||||||||||||||||||
23 | - | |||||||||||||||||||||||||||||||
24 | - | |||||||||||||||||||||||||||||||
25 | - | |||||||||||||||||||||||||||||||
26 | typedef struct { | - | ||||||||||||||||||||||||||||||
27 | IDEA_KEY_SCHEDULE ks; | - | ||||||||||||||||||||||||||||||
28 | } EVP_IDEA_KEY; | - | ||||||||||||||||||||||||||||||
29 | - | |||||||||||||||||||||||||||||||
30 | static int idea_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) { while(inl>=((size_t)1<<(sizeof(long)*8-2))
never executed: if (inlend of block
never executed: returnidea_cbc_encrypt(in, out, (long)inl, &((EVP_IDEA_KEY *)ctx->cipher_data)->ks, ctx->iv, ctx->encrypt); never executed: 1;return 1; never executed: }return 1; | 0 | ||||||||||||||||||||||||||||||
31 | static int idea_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) { while(inl>=((size_t)1<<(sizeof(long)*8-2))
never executed: if (inlend of block
never executed: returnidea_ofb64_encrypt(in, out, (long)inl, &((EVP_IDEA_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num); never executed: 1;return 1; never executed: }return 1; | 0 | ||||||||||||||||||||||||||||||
32 | static int idea_cfb64_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) { size_t chunk=((size_t)1<<(sizeof(long)*8-2)); if (64==1
never executed: if (inl<chunkchunk>>=3;
never executed: while(inlchunk=inl;
never executed: }chunk=inl; never executed: returnend of block never executed: 1;return 1; never executed: }return 1; | 0 | ||||||||||||||||||||||||||||||
33 | - | |||||||||||||||||||||||||||||||
34 | static const EVP_CIPHER idea_cbc = { 34, 8, 16, 8, 0 | 0x2, idea_init_key, idea_cbc_cipher, | - | ||||||||||||||||||||||||||||||
35 | ((void *)0) | - | ||||||||||||||||||||||||||||||
36 | , sizeof(IDEA_KEY_SCHEDULE), EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv, | - | ||||||||||||||||||||||||||||||
37 | ((void *)0) | - | ||||||||||||||||||||||||||||||
38 | , | - | ||||||||||||||||||||||||||||||
39 | ((void *)0) | - | ||||||||||||||||||||||||||||||
40 | }; const EVP_CIPHER *EVP_idea_cbc(void) { return executed 292 times by 33 tests: &idea_cbc;return &idea_cbc; Executed by:
executed 292 times by 33 tests: } static const EVP_CIPHER idea_cfb64 = { 35, 1, 16, 8, 0 | 0x3, idea_init_key, idea_cfb64_cipher, return &idea_cbc; Executed by:
| 292 | ||||||||||||||||||||||||||||||
41 | ((void *)0) | - | ||||||||||||||||||||||||||||||
42 | , sizeof(IDEA_KEY_SCHEDULE), EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv, | - | ||||||||||||||||||||||||||||||
43 | ((void *)0) | - | ||||||||||||||||||||||||||||||
44 | , | - | ||||||||||||||||||||||||||||||
45 | ((void *)0) | - | ||||||||||||||||||||||||||||||
46 | }; const EVP_CIPHER *EVP_idea_cfb64(void) { return executed 292 times by 33 tests: &idea_cfb64;return &idea_cfb64; Executed by:
executed 292 times by 33 tests: } static const EVP_CIPHER idea_ofb = { 46, 1, 16, 8, 0 | 0x4, idea_init_key, idea_ofb_cipher, return &idea_cfb64; Executed by:
| 292 | ||||||||||||||||||||||||||||||
47 | ((void *)0) | - | ||||||||||||||||||||||||||||||
48 | , sizeof(IDEA_KEY_SCHEDULE), EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv, | - | ||||||||||||||||||||||||||||||
49 | ((void *)0) | - | ||||||||||||||||||||||||||||||
50 | , | - | ||||||||||||||||||||||||||||||
51 | ((void *)0) | - | ||||||||||||||||||||||||||||||
52 | }; const EVP_CIPHER *EVP_idea_ofb(void) { return executed 292 times by 33 tests: &idea_ofb;return &idea_ofb; Executed by:
executed 292 times by 33 tests: } static const EVP_CIPHER idea_ecb = { 36, 8, 16, 0, 0 | 0x1, idea_init_key, idea_ecb_cipher, return &idea_ofb; Executed by:
| 292 | ||||||||||||||||||||||||||||||
53 | ((void *)0) | - | ||||||||||||||||||||||||||||||
54 | , sizeof(IDEA_KEY_SCHEDULE), EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv, | - | ||||||||||||||||||||||||||||||
55 | ((void *)0) | - | ||||||||||||||||||||||||||||||
56 | , | - | ||||||||||||||||||||||||||||||
57 | ((void *)0) | - | ||||||||||||||||||||||||||||||
58 | }; const EVP_CIPHER *EVP_idea_ecb(void) { return executed 292 times by 33 tests: &idea_ecb;return &idea_ecb; Executed by:
executed 292 times by 33 tests: }return &idea_ecb; Executed by:
| 292 | ||||||||||||||||||||||||||||||
59 | - | |||||||||||||||||||||||||||||||
60 | - | |||||||||||||||||||||||||||||||
61 | - | |||||||||||||||||||||||||||||||
62 | static int | - | ||||||||||||||||||||||||||||||
63 | idea_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, | - | ||||||||||||||||||||||||||||||
64 | const unsigned char *iv, int enc) | - | ||||||||||||||||||||||||||||||
65 | { | - | ||||||||||||||||||||||||||||||
66 | if (!enc
| 0 | ||||||||||||||||||||||||||||||
67 | if ((
| 0 | ||||||||||||||||||||||||||||||
68 | enc = 1; never executed: enc = 1; | 0 | ||||||||||||||||||||||||||||||
69 | else if ((
| 0 | ||||||||||||||||||||||||||||||
70 | enc = 1; never executed: enc = 1; | 0 | ||||||||||||||||||||||||||||||
71 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
72 | if (enc
| 0 | ||||||||||||||||||||||||||||||
73 | idea_set_encrypt_key(key, ctx->cipher_data); never executed: idea_set_encrypt_key(key, ctx->cipher_data); | 0 | ||||||||||||||||||||||||||||||
74 | else { | - | ||||||||||||||||||||||||||||||
75 | IDEA_KEY_SCHEDULE tmp; | - | ||||||||||||||||||||||||||||||
76 | - | |||||||||||||||||||||||||||||||
77 | idea_set_encrypt_key(key, &tmp); | - | ||||||||||||||||||||||||||||||
78 | idea_set_decrypt_key(&tmp, ctx->cipher_data); | - | ||||||||||||||||||||||||||||||
79 | explicit_bzero((unsigned char *)&tmp, | - | ||||||||||||||||||||||||||||||
80 | sizeof(IDEA_KEY_SCHEDULE)); | - | ||||||||||||||||||||||||||||||
81 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
82 | return never executed: 1;return 1; never executed: return 1; | 0 | ||||||||||||||||||||||||||||||
83 | } | - | ||||||||||||||||||||||||||||||
Switch to Source code | Preprocessed file |