@@ -103,7 +103,7 @@ static struct GRASSHOPPER_CIPHER_PARAMS gost_cipher_params[5] = {
103
103
};
104
104
105
105
/* Set 256 bit key into context */
106
- static GRASSHOPPER_INLINE void gost_grasshopper_cipher_key (gost_grasshopper_cipher_ctx * c , const uint8_t * k ) {
106
+ GRASSHOPPER_INLINE void gost_grasshopper_cipher_key (gost_grasshopper_cipher_ctx * c , const uint8_t * k ) {
107
107
int i ;
108
108
for (i = 0 ; i < 2 ; i ++ ) {
109
109
grasshopper_copy128 (& c -> key .k .k [i ], (const grasshopper_w128_t * ) (k + i * 16 ));
@@ -113,7 +113,7 @@ static GRASSHOPPER_INLINE void gost_grasshopper_cipher_key(gost_grasshopper_ciph
113
113
}
114
114
115
115
/* Cleans up key from context */
116
- static GRASSHOPPER_INLINE void gost_grasshopper_cipher_destroy (gost_grasshopper_cipher_ctx * c ) {
116
+ GRASSHOPPER_INLINE void gost_grasshopper_cipher_destroy (gost_grasshopper_cipher_ctx * c ) {
117
117
int i ;
118
118
for (i = 0 ; i < 2 ; i ++ ) {
119
119
grasshopper_zero128 (& c -> key .k .k [i ]);
@@ -142,7 +142,7 @@ static GRASSHOPPER_INLINE void gost_grasshopper_cipher_destroy_ctr(gost_grasshop
142
142
ctx -> counter = 0 ;
143
143
}
144
144
145
- static int gost_grasshopper_cipher_init (EVP_CIPHER_CTX * ctx , const unsigned char * key ,
145
+ int gost_grasshopper_cipher_init (EVP_CIPHER_CTX * ctx , const unsigned char * key ,
146
146
const unsigned char * iv , int enc ) {
147
147
gost_grasshopper_cipher_ctx * c = EVP_CIPHER_CTX_get_cipher_data (ctx );
148
148
@@ -168,23 +168,23 @@ static int gost_grasshopper_cipher_init(EVP_CIPHER_CTX* ctx, const unsigned char
168
168
return 1 ;
169
169
}
170
170
171
- static GRASSHOPPER_INLINE int gost_grasshopper_cipher_init_ecb (EVP_CIPHER_CTX * ctx , const unsigned char * key ,
171
+ GRASSHOPPER_INLINE int gost_grasshopper_cipher_init_ecb (EVP_CIPHER_CTX * ctx , const unsigned char * key ,
172
172
const unsigned char * iv ,
173
173
int enc ) {
174
174
gost_grasshopper_cipher_ctx * c = EVP_CIPHER_CTX_get_cipher_data (ctx );
175
175
c -> type = GRASSHOPPER_CIPHER_ECB ;
176
176
return gost_grasshopper_cipher_init (ctx , key , iv , enc );
177
177
}
178
178
179
- static GRASSHOPPER_INLINE int gost_grasshopper_cipher_init_cbc (EVP_CIPHER_CTX * ctx , const unsigned char * key ,
179
+ GRASSHOPPER_INLINE int gost_grasshopper_cipher_init_cbc (EVP_CIPHER_CTX * ctx , const unsigned char * key ,
180
180
const unsigned char * iv ,
181
181
int enc ) {
182
182
gost_grasshopper_cipher_ctx * c = EVP_CIPHER_CTX_get_cipher_data (ctx );
183
183
c -> type = GRASSHOPPER_CIPHER_CBC ;
184
184
return gost_grasshopper_cipher_init (ctx , key , iv , enc );
185
185
}
186
186
187
- static GRASSHOPPER_INLINE int gost_grasshopper_cipher_init_ofb (EVP_CIPHER_CTX * ctx , const unsigned char * key ,
187
+ GRASSHOPPER_INLINE int gost_grasshopper_cipher_init_ofb (EVP_CIPHER_CTX * ctx , const unsigned char * key ,
188
188
const unsigned char * iv ,
189
189
int enc ) {
190
190
gost_grasshopper_cipher_ctx_ofb * c = EVP_CIPHER_CTX_get_cipher_data (ctx );
@@ -196,15 +196,15 @@ static GRASSHOPPER_INLINE int gost_grasshopper_cipher_init_ofb(EVP_CIPHER_CTX* c
196
196
return gost_grasshopper_cipher_init (ctx , key , iv , enc );
197
197
}
198
198
199
- static GRASSHOPPER_INLINE int gost_grasshopper_cipher_init_cfb (EVP_CIPHER_CTX * ctx , const unsigned char * key ,
199
+ GRASSHOPPER_INLINE int gost_grasshopper_cipher_init_cfb (EVP_CIPHER_CTX * ctx , const unsigned char * key ,
200
200
const unsigned char * iv ,
201
201
int enc ) {
202
202
gost_grasshopper_cipher_ctx * c = EVP_CIPHER_CTX_get_cipher_data (ctx );
203
203
c -> type = GRASSHOPPER_CIPHER_CFB ;
204
204
return gost_grasshopper_cipher_init (ctx , key , iv , enc );
205
205
}
206
206
207
- static GRASSHOPPER_INLINE int gost_grasshopper_cipher_init_ctr (EVP_CIPHER_CTX * ctx , const unsigned char * key ,
207
+ GRASSHOPPER_INLINE int gost_grasshopper_cipher_init_ctr (EVP_CIPHER_CTX * ctx , const unsigned char * key ,
208
208
const unsigned char * iv ,
209
209
int enc ) {
210
210
gost_grasshopper_cipher_ctx_ctr * c = EVP_CIPHER_CTX_get_cipher_data (ctx );
@@ -219,15 +219,15 @@ static GRASSHOPPER_INLINE int gost_grasshopper_cipher_init_ctr(EVP_CIPHER_CTX* c
219
219
return gost_grasshopper_cipher_init (ctx , key , iv , enc );
220
220
}
221
221
222
- static GRASSHOPPER_INLINE int gost_grasshopper_cipher_do (EVP_CIPHER_CTX * ctx , unsigned char * out ,
222
+ GRASSHOPPER_INLINE int gost_grasshopper_cipher_do (EVP_CIPHER_CTX * ctx , unsigned char * out ,
223
223
const unsigned char * in , size_t inl ) {
224
224
gost_grasshopper_cipher_ctx * c = (gost_grasshopper_cipher_ctx * ) EVP_CIPHER_CTX_get_cipher_data (ctx );
225
225
struct GRASSHOPPER_CIPHER_PARAMS * params = & gost_cipher_params [c -> type ];
226
226
227
227
return params -> do_cipher (ctx , out , in , inl );
228
228
}
229
229
230
- static int gost_grasshopper_cipher_do_ecb (EVP_CIPHER_CTX * ctx , unsigned char * out ,
230
+ int gost_grasshopper_cipher_do_ecb (EVP_CIPHER_CTX * ctx , unsigned char * out ,
231
231
const unsigned char * in , size_t inl ) {
232
232
gost_grasshopper_cipher_ctx * c = (gost_grasshopper_cipher_ctx * ) EVP_CIPHER_CTX_get_cipher_data (ctx );
233
233
bool encrypting = (bool ) EVP_CIPHER_CTX_encrypting (ctx );
@@ -251,7 +251,7 @@ static int gost_grasshopper_cipher_do_ecb(EVP_CIPHER_CTX* ctx, unsigned char* ou
251
251
return 1 ;
252
252
}
253
253
254
- static int gost_grasshopper_cipher_do_cbc (EVP_CIPHER_CTX * ctx , unsigned char * out ,
254
+ int gost_grasshopper_cipher_do_cbc (EVP_CIPHER_CTX * ctx , unsigned char * out ,
255
255
const unsigned char * in , size_t inl ) {
256
256
gost_grasshopper_cipher_ctx * c = (gost_grasshopper_cipher_ctx * ) EVP_CIPHER_CTX_get_cipher_data (ctx );
257
257
unsigned char * iv = EVP_CIPHER_CTX_iv_noconst (ctx );
@@ -283,7 +283,7 @@ static int gost_grasshopper_cipher_do_cbc(EVP_CIPHER_CTX* ctx, unsigned char* ou
283
283
return 1 ;
284
284
}
285
285
286
- static int gost_grasshopper_cipher_do_ctr (EVP_CIPHER_CTX * ctx , unsigned char * out ,
286
+ int gost_grasshopper_cipher_do_ctr (EVP_CIPHER_CTX * ctx , unsigned char * out ,
287
287
const unsigned char * in , size_t inl ) {
288
288
gost_grasshopper_cipher_ctx_ctr * c = (gost_grasshopper_cipher_ctx_ctr * ) EVP_CIPHER_CTX_get_cipher_data (ctx );
289
289
unsigned char * iv = EVP_CIPHER_CTX_iv_noconst (ctx );
@@ -372,7 +372,7 @@ static void gost_grasshopper_cnt_next(gost_grasshopper_cipher_ctx_ofb* ctx, gras
372
372
grasshopper_encrypt_block (& ctx -> c .encrypt_round_keys , & ctx -> buffer1 , buf , & ctx -> c .buffer );
373
373
}
374
374
375
- static int gost_grasshopper_cipher_do_ofb (EVP_CIPHER_CTX * ctx , unsigned char * out ,
375
+ int gost_grasshopper_cipher_do_ofb (EVP_CIPHER_CTX * ctx , unsigned char * out ,
376
376
const unsigned char * in , size_t inl ) {
377
377
gost_grasshopper_cipher_ctx_ofb * c = (gost_grasshopper_cipher_ctx_ofb * ) EVP_CIPHER_CTX_get_cipher_data (ctx );
378
378
const unsigned char * in_ptr = in ;
@@ -430,7 +430,7 @@ static int gost_grasshopper_cipher_do_ofb(EVP_CIPHER_CTX* ctx, unsigned char* ou
430
430
return 1 ;
431
431
}
432
432
433
- static int gost_grasshopper_cipher_do_cfb (EVP_CIPHER_CTX * ctx , unsigned char * out ,
433
+ int gost_grasshopper_cipher_do_cfb (EVP_CIPHER_CTX * ctx , unsigned char * out ,
434
434
const unsigned char * in , size_t inl ) {
435
435
gost_grasshopper_cipher_ctx * c = (gost_grasshopper_cipher_ctx * ) EVP_CIPHER_CTX_get_cipher_data (ctx );
436
436
const unsigned char * in_ptr = in ;
@@ -509,7 +509,7 @@ static int gost_grasshopper_cipher_do_cfb(EVP_CIPHER_CTX* ctx, unsigned char* ou
509
509
return 1 ;
510
510
}
511
511
512
- static int gost_grasshopper_cipher_cleanup (EVP_CIPHER_CTX * ctx ) {
512
+ int gost_grasshopper_cipher_cleanup (EVP_CIPHER_CTX * ctx ) {
513
513
gost_grasshopper_cipher_ctx * c = (gost_grasshopper_cipher_ctx * ) EVP_CIPHER_CTX_get_cipher_data (ctx );
514
514
struct GRASSHOPPER_CIPHER_PARAMS * params = & gost_cipher_params [c -> type ];
515
515
@@ -523,7 +523,7 @@ static int gost_grasshopper_cipher_cleanup(EVP_CIPHER_CTX* ctx) {
523
523
return 1 ;
524
524
}
525
525
526
- static int gost_grasshopper_set_asn1_parameters (EVP_CIPHER_CTX * ctx , ASN1_TYPE * params ) {
526
+ int gost_grasshopper_set_asn1_parameters (EVP_CIPHER_CTX * ctx , ASN1_TYPE * params ) {
527
527
int len = 0 ;
528
528
unsigned char * buf = NULL ;
529
529
unsigned char * p = NULL ;
@@ -542,7 +542,7 @@ static int gost_grasshopper_set_asn1_parameters(EVP_CIPHER_CTX* ctx, ASN1_TYPE*
542
542
return 1 ;
543
543
}
544
544
545
- static GRASSHOPPER_INLINE int gost_grasshopper_get_asn1_parameters (EVP_CIPHER_CTX * ctx , ASN1_TYPE * params ) {
545
+ GRASSHOPPER_INLINE int gost_grasshopper_get_asn1_parameters (EVP_CIPHER_CTX * ctx , ASN1_TYPE * params ) {
546
546
int ret = -1 ;
547
547
548
548
if (ASN1_TYPE_get (params ) != V_ASN1_SEQUENCE ) {
@@ -552,7 +552,7 @@ static GRASSHOPPER_INLINE int gost_grasshopper_get_asn1_parameters(EVP_CIPHER_CT
552
552
return 1 ;
553
553
}
554
554
555
- static int gost_grasshopper_cipher_ctl (EVP_CIPHER_CTX * ctx , int type , int arg , void * ptr ) {
555
+ int gost_grasshopper_cipher_ctl (EVP_CIPHER_CTX * ctx , int type , int arg , void * ptr ) {
556
556
switch (type ) {
557
557
case EVP_CTRL_RAND_KEY : {
558
558
if (RAND_bytes ((unsigned char * ) ptr , EVP_CIPHER_CTX_key_length (ctx )) <= 0 ) {
@@ -568,7 +568,7 @@ static int gost_grasshopper_cipher_ctl(EVP_CIPHER_CTX* ctx, int type, int arg, v
568
568
return 1 ;
569
569
}
570
570
571
- static GRASSHOPPER_INLINE EVP_CIPHER * cipher_gost_grasshopper_create (int cipher_type , int block_size ) {
571
+ GRASSHOPPER_INLINE EVP_CIPHER * cipher_gost_grasshopper_create (int cipher_type , int block_size ) {
572
572
return EVP_CIPHER_meth_new (cipher_type ,
573
573
block_size /* block_size */ ,
574
574
GRASSHOPPER_KEY_SIZE /* key_size */ );
@@ -590,7 +590,7 @@ const int cipher_gost_grasshopper_setup(EVP_CIPHER* cipher, uint8_t mode, int iv
590
590
EVP_CIPHER_meth_set_do_cipher (cipher , gost_grasshopper_cipher_do );
591
591
}
592
592
593
- static const GRASSHOPPER_INLINE EVP_CIPHER * cipher_gost_grasshopper (uint8_t mode , uint8_t num ) {
593
+ const GRASSHOPPER_INLINE EVP_CIPHER * cipher_gost_grasshopper (uint8_t mode , uint8_t num ) {
594
594
EVP_CIPHER * * cipher ;
595
595
struct GRASSHOPPER_CIPHER_PARAMS * params ;
596
596
0 commit comments