OpenCoverage

e_gost2814789.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/libressl/src/crypto/evp/e_gost2814789.c
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5typedef struct {-
6 GOST2814789_KEY ks;-
7 int param_nid;-
8} EVP_GOST2814789_CTX;-
9-
10static int-
11gost2814789_ctl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr)-
12{-
13 EVP_GOST2814789_CTX *c = ctx->cipher_data;-
14-
15 switch (type) {-
16 case
never executed: case 0x7:
0x7:
never executed: case 0x7:
0
17 if (ptr !=
ptr != ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
18 ((void *)0)
ptr != ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
19 ) {-
20 *((int *)ptr) = 810;-
21 return
never executed: return 1;
1;
never executed: return 1;
0
22 } else {-
23 return
never executed: return 0;
0;
never executed: return 0;
0
24 }-
25 case
executed 12 times by 1 test: case 0x0:
Executed by:
  • gost2814789t
0x0:
executed 12 times by 1 test: case 0x0:
Executed by:
  • gost2814789t
12
26-
27 c->param_nid = 824;-
28 return
executed 12 times by 1 test: return Gost2814789_set_sbox(&c->ks, c->param_nid);
Executed by:
  • gost2814789t
Gost2814789_set_sbox(&c->ks, c->param_nid);
executed 12 times by 1 test: return Gost2814789_set_sbox(&c->ks, c->param_nid);
Executed by:
  • gost2814789t
12
29 case
executed 12 times by 1 test: case 0x19:
Executed by:
  • gost2814789t
0x19:
executed 12 times by 1 test: case 0x19:
Executed by:
  • gost2814789t
12
30 return
executed 12 times by 1 test: return Gost2814789_set_sbox(&c->ks, arg);
Executed by:
  • gost2814789t
Gost2814789_set_sbox(&c->ks, arg);
executed 12 times by 1 test: return Gost2814789_set_sbox(&c->ks, arg);
Executed by:
  • gost2814789t
12
31 default
never executed: default:
:
never executed: default:
0
32 return
never executed: return -1;
-1;
never executed: return -1;
0
33 }-
34}-
35-
36static int-
37gost2814789_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,-
38 const unsigned char *iv, int enc)-
39{-
40 EVP_GOST2814789_CTX *c = ctx->cipher_data;-
41-
42 return
executed 12 times by 1 test: return Gost2814789_set_key(&c->ks, key, ctx->key_len * 8);
Executed by:
  • gost2814789t
Gost2814789_set_key(&c->ks, key, ctx->key_len * 8);
executed 12 times by 1 test: return Gost2814789_set_key(&c->ks, key, ctx->key_len * 8);
Executed by:
  • gost2814789t
12
43}-
44-
45int-
46gost2814789_set_asn1_params(EVP_CIPHER_CTX *ctx, ASN1_TYPE *params)-
47{-
48 int len = 0;-
49 unsigned char *buf = -
50 ((void *)0)-
51 ;-
52 unsigned char *p = -
53 ((void *)0)-
54 ;-
55 EVP_GOST2814789_CTX *c = ctx->cipher_data;-
56 ASN1_OCTET_STRING *os = -
57 ((void *)0)-
58 ;-
59 GOST_CIPHER_PARAMS *gcp = GOST_CIPHER_PARAMS_new();-
60-
61 if (gcp ==
gcp == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
62 ((void *)0)
gcp == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
63 ) {-
64 ERR_put_error(50,(0xfff),((1|64)),__FILE__,110);-
65 return
never executed: return 0;
0;
never executed: return 0;
0
66 }-
67 if (ASN1_OCTET_STRING_set(gcp->iv, ctx->iv, ctx->cipher->iv_len) == 0
ASN1_OCTET_STR...->iv_len) == 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
68 GOST_CIPHER_PARAMS_free(gcp);-
69 ERR_put_error(50,(0xfff),(13),__FILE__,115);-
70 return
never executed: return 0;
0;
never executed: return 0;
0
71 }-
72 ASN1_OBJECT_free(gcp->enc_param_set);-
73 gcp->enc_param_set = OBJ_nid2obj(c->param_nid);-
74-
75 len = i2d_GOST_CIPHER_PARAMS(gcp, -
76 ((void *)0)-
77 );-
78 p = buf = malloc(len);-
79 if (buf ==
buf == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
80 ((void *)0)
buf == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
81 ) {-
82 GOST_CIPHER_PARAMS_free(gcp);-
83 ERR_put_error(50,(0xfff),((1|64)),__FILE__,125);-
84 return
never executed: return 0;
0;
never executed: return 0;
0
85 }-
86 i2d_GOST_CIPHER_PARAMS(gcp, &p);-
87 GOST_CIPHER_PARAMS_free(gcp);-
88-
89 os = ASN1_OCTET_STRING_new();-
90 if (os ==
os == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
91 ((void *)0)
os == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
92 ) {-
93 free(buf);-
94 ERR_put_error(50,(0xfff),((1|64)),__FILE__,134);-
95 return
never executed: return 0;
0;
never executed: return 0;
0
96 }-
97 if (ASN1_OCTET_STRING_set(os, buf, len) == 0
ASN1_OCTET_STR...buf, len) == 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
98 ASN1_OCTET_STRING_free(os);-
99 free(buf);-
100 ERR_put_error(50,(0xfff),(13),__FILE__,140);-
101 return
never executed: return 0;
0;
never executed: return 0;
0
102 }-
103 free(buf);-
104-
105 ASN1_TYPE_set(params, 16, os);-
106 return
never executed: return 1;
1;
never executed: return 1;
0
107}-
108-
109int-
110gost2814789_get_asn1_params(EVP_CIPHER_CTX *ctx, ASN1_TYPE *params)-
111{-
112 int ret = -1;-
113 int len;-
114 GOST_CIPHER_PARAMS *gcp = -
115 ((void *)0)-
116 ;-
117 EVP_GOST2814789_CTX *c = ctx->cipher_data;-
118 unsigned char *p;-
119-
120 if (ASN1_TYPE_get(params) != 16
ASN1_TYPE_get(params) != 16Description
TRUEnever evaluated
FALSEnever evaluated
)
0
121 return
never executed: return ret;
ret;
never executed: return ret;
0
122-
123 p = params->value.sequence->data;-
124-
125 gcp = d2i_GOST_CIPHER_PARAMS(-
126 ((void *)0)-
127 , (const unsigned char **)&p,-
128 params->value.sequence->length);-
129-
130 len = gcp->iv->length;-
131 if (len != ctx->cipher->iv_len
len != ctx->cipher->iv_lenDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
132 GOST_CIPHER_PARAMS_free(gcp);-
133 ERR_put_error(50,(0xfff),(103),__FILE__,169);-
134 return
never executed: return -1;
-1;
never executed: return -1;
0
135 }-
136-
137 if (!Gost2814789_set_sbox(&c->ks, OBJ_obj2nid(gcp->enc_param_set))
!Gost2814789_s...nc_param_set))Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
138 GOST_CIPHER_PARAMS_free(gcp);-
139 return
never executed: return -1;
-1;
never executed: return -1;
0
140 }-
141 c->param_nid = OBJ_obj2nid(gcp->enc_param_set);-
142-
143 memcpy(ctx->oiv, gcp->iv->data, len);-
144 memcpy(ctx->iv, gcp->iv->data, len);-
145-
146 GOST_CIPHER_PARAMS_free(gcp);-
147-
148 return
never executed: return 1;
1;
never executed: return 1;
0
149}-
150-
151static int gost2814789_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) { size_t i, bl; bl = ctx->cipher->block_size; if(inl < bl
inl < blDescription
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • gost2814789t
) return
never executed: return 1;
1;
never executed: return 1;
inl -= bl; for(i=0; i <= inl
i <= inlDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • gost2814789t
FALSEevaluated 4 times by 1 test
Evaluated by:
  • gost2814789t
; i+=bl) Gost2814789_ecb_encrypt(in + i, out + i, &((EVP_GOST2814789_CTX *)ctx->cipher_data)->ks, ctx->encrypt);
executed 5 times by 1 test: Gost2814789_ecb_encrypt(in + i, out + i, &((EVP_GOST2814789_CTX *)ctx->cipher_data)->ks, ctx->encrypt);
Executed by:
  • gost2814789t
return
executed 4 times by 1 test: return 1;
Executed by:
  • gost2814789t
1;
executed 4 times by 1 test: return 1;
Executed by:
  • gost2814789t
}
0-5
152static int gost2814789_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
64==1Description
TRUEnever evaluated
FALSEevaluated 5 times by 1 test
Evaluated by:
  • gost2814789t
) chunk>>=3;
never executed: chunk>>=3;
if (inl<chunk
inl<chunkDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • gost2814789t
FALSEnever evaluated
) chunk=inl;
executed 5 times by 1 test: chunk=inl;
Executed by:
  • gost2814789t
while(inl
inlDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • gost2814789t
FALSEevaluated 5 times by 1 test
Evaluated by:
  • gost2814789t
&& inl>=chunk
inl>=chunkDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • gost2814789t
FALSEnever evaluated
) { Gost2814789_cfb64_encrypt(in, out, (long)((64==1) && !(ctx->flags & 0x2000) ?inl*8:inl), &((EVP_GOST2814789_CTX *)ctx->cipher_data)->ks, ctx->iv, &ctx->num, ctx->encrypt); inl-=chunk; in +=chunk; out+=chunk; if(inl<chunk
inl<chunkDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • gost2814789t
FALSEnever evaluated
) chunk=inl;
executed 5 times by 1 test: chunk=inl;
Executed by:
  • gost2814789t
}
executed 5 times by 1 test: end of block
Executed by:
  • gost2814789t
return
executed 5 times by 1 test: return 1;
Executed by:
  • gost2814789t
1;
executed 5 times by 1 test: return 1;
Executed by:
  • gost2814789t
}
0-5
153-
154static int-
155gost2814789_cnt_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,-
156 const unsigned char *in, size_t inl)-
157{-
158 EVP_GOST2814789_CTX *c = ctx->cipher_data;-
159-
160 while (inl >= ((size_t)1<<(sizeof(long)*8-2))
inl >= ((size_...of(long)*8-2))Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • gost2814789t
) {
0-3
161 Gost2814789_cnt_encrypt(in, out, (long)((size_t)1<<(sizeof(long)*8-2)), &c->ks,-
162 ctx->iv, ctx->buf, &ctx->num);-
163 inl -= ((size_t)1<<(sizeof(long)*8-2));-
164 in += ((size_t)1<<(sizeof(long)*8-2));-
165 out += ((size_t)1<<(sizeof(long)*8-2));-
166 }
never executed: end of block
0
167-
168 if (inl
inlDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • gost2814789t
FALSEnever evaluated
)
0-3
169 Gost2814789_cnt_encrypt(in, out, inl, &c->ks, ctx->iv, ctx->buf,
executed 3 times by 1 test: Gost2814789_cnt_encrypt(in, out, inl, &c->ks, ctx->iv, ctx->buf, &ctx->num);
Executed by:
  • gost2814789t
3
170 &ctx->num);
executed 3 times by 1 test: Gost2814789_cnt_encrypt(in, out, inl, &c->ks, ctx->iv, ctx->buf, &ctx->num);
Executed by:
  • gost2814789t
3
171 return
executed 3 times by 1 test: return 1;
Executed by:
  • gost2814789t
1;
executed 3 times by 1 test: return 1;
Executed by:
  • gost2814789t
3
172}-
173-
174-
175-
176-
177static const EVP_CIPHER gost2814789_ecb = { 938, 8, 32, 0, 0x100 | 0x40 | 0x1, gost2814789_init_key, gost2814789_ecb_cipher, -
178((void *)0)-
179, sizeof(EVP_GOST2814789_CTX), gost2814789_set_asn1_params, gost2814789_get_asn1_params, gost2814789_ctl, -
180((void *)0) -
181}; const EVP_CIPHER *EVP_gost2814789_ecb(void) { return
executed 292 times by 33 tests: return &gost2814789_ecb;
Executed by:
  • asn1test
  • base64test
  • bnaddsub
  • bntest
  • cipher_list
  • cipherstest
  • clienttest
  • configtest
  • dhtest
  • dsatest
  • ecdhtest
  • ecdsatest
  • ectest
  • enginetest
  • evptest
  • exptest
  • gost2814789t
  • hkdftest
  • keypairtest
  • libcrypto.so.44.0.1
  • mont
  • pbkdf2
  • pkcs7test
  • rc4test
  • rsa_test
  • ...
&gost2814789_ecb;
executed 292 times by 33 tests: return &gost2814789_ecb;
Executed by:
  • asn1test
  • base64test
  • bnaddsub
  • bntest
  • cipher_list
  • cipherstest
  • clienttest
  • configtest
  • dhtest
  • dsatest
  • ecdhtest
  • ecdsatest
  • ectest
  • enginetest
  • evptest
  • exptest
  • gost2814789t
  • hkdftest
  • keypairtest
  • libcrypto.so.44.0.1
  • mont
  • pbkdf2
  • pkcs7test
  • rc4test
  • rsa_test
  • ...
}
292
182-
183-
184-
185static const EVP_CIPHER gost2814789_cfb64 = { 813, 1, 32, 8, 0x100 | 0x40 | 0x3, gost2814789_init_key, gost2814789_cfb64_cipher, -
186((void *)0)-
187, sizeof(EVP_GOST2814789_CTX), gost2814789_set_asn1_params, gost2814789_get_asn1_params, gost2814789_ctl, -
188((void *)0) -
189}; const EVP_CIPHER *EVP_gost2814789_cfb64(void) { return
executed 625 times by 33 tests: return &gost2814789_cfb64;
Executed by:
  • asn1test
  • base64test
  • bnaddsub
  • bntest
  • cipher_list
  • cipherstest
  • clienttest
  • configtest
  • dhtest
  • dsatest
  • ecdhtest
  • ecdsatest
  • ectest
  • enginetest
  • evptest
  • exptest
  • gost2814789t
  • hkdftest
  • keypairtest
  • libcrypto.so.44.0.1
  • mont
  • pbkdf2
  • pkcs7test
  • rc4test
  • rsa_test
  • ...
&gost2814789_cfb64;
executed 625 times by 33 tests: return &gost2814789_cfb64;
Executed by:
  • asn1test
  • base64test
  • bnaddsub
  • bntest
  • cipher_list
  • cipherstest
  • clienttest
  • configtest
  • dhtest
  • dsatest
  • ecdhtest
  • ecdsatest
  • ectest
  • enginetest
  • evptest
  • exptest
  • gost2814789t
  • hkdftest
  • keypairtest
  • libcrypto.so.44.0.1
  • mont
  • pbkdf2
  • pkcs7test
  • rc4test
  • rsa_test
  • ...
}
625
190-
191-
192-
193static const EVP_CIPHER gost2814789_cnt = { 814, 1, 32, 8, 0x100 | 0x40 | 0x4, gost2814789_init_key, gost2814789_cnt_cipher, -
194((void *)0)-
195, sizeof(EVP_GOST2814789_CTX), gost2814789_set_asn1_params, gost2814789_get_asn1_params, gost2814789_ctl, -
196((void *)0) -
197}; const EVP_CIPHER *EVP_gost2814789_cnt(void) { return
executed 625 times by 33 tests: return &gost2814789_cnt;
Executed by:
  • asn1test
  • base64test
  • bnaddsub
  • bntest
  • cipher_list
  • cipherstest
  • clienttest
  • configtest
  • dhtest
  • dsatest
  • ecdhtest
  • ecdsatest
  • ectest
  • enginetest
  • evptest
  • exptest
  • gost2814789t
  • hkdftest
  • keypairtest
  • libcrypto.so.44.0.1
  • mont
  • pbkdf2
  • pkcs7test
  • rc4test
  • rsa_test
  • ...
&gost2814789_cnt;
executed 625 times by 33 tests: return &gost2814789_cnt;
Executed by:
  • asn1test
  • base64test
  • bnaddsub
  • bntest
  • cipher_list
  • cipherstest
  • clienttest
  • configtest
  • dhtest
  • dsatest
  • ecdhtest
  • ecdsatest
  • ectest
  • enginetest
  • evptest
  • exptest
  • gost2814789t
  • hkdftest
  • keypairtest
  • libcrypto.so.44.0.1
  • mont
  • pbkdf2
  • pkcs7test
  • rc4test
  • rsa_test
  • ...
}
625
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.2