@@ -257,94 +257,70 @@ typedef struct {
257
257
#ifdef LTC_CFB_MODE
258
258
/** A block cipher CFB structure */
259
259
typedef struct {
260
- /** The index of the cipher chosen */
261
- int cipher ,
262
- /** The block size of the given cipher */
263
- blocklen ,
260
+ /** The ECB context of the cipher */
261
+ symmetric_ECB ecb ;
264
262
/** The padding offset */
265
- padlen ;
263
+ int padlen ;
266
264
/** The current IV */
267
265
unsigned char IV [MAXBLOCKSIZE ],
268
266
/** The pad used to encrypt/decrypt */
269
267
pad [MAXBLOCKSIZE ];
270
- /** The scheduled key */
271
- symmetric_key key ;
272
268
} symmetric_CFB ;
273
269
#endif
274
270
275
271
#ifdef LTC_OFB_MODE
276
272
/** A block cipher OFB structure */
277
273
typedef struct {
278
- /** The index of the cipher chosen */
279
- int cipher ,
280
- /** The block size of the given cipher */
281
- blocklen ,
274
+ /** The ECB context of the cipher */
275
+ symmetric_ECB ecb ;
282
276
/** The padding offset */
283
- padlen ;
277
+ int padlen ;
284
278
/** The current IV */
285
279
unsigned char IV [MAXBLOCKSIZE ];
286
- /** The scheduled key */
287
- symmetric_key key ;
288
280
} symmetric_OFB ;
289
281
#endif
290
282
291
283
#ifdef LTC_CBC_MODE
292
284
/** A block cipher CBC structure */
293
285
typedef struct {
294
- /** The index of the cipher chosen */
295
- int cipher ,
296
- /** The block size of the given cipher */
297
- blocklen ;
286
+ /** The ECB context of the cipher */
287
+ symmetric_ECB ecb ;
298
288
/** The current IV */
299
289
unsigned char IV [MAXBLOCKSIZE ];
300
- /** The scheduled key */
301
- symmetric_key key ;
302
290
} symmetric_CBC ;
303
291
#endif
304
292
305
293
306
294
#ifdef LTC_CTR_MODE
307
295
/** A block cipher CTR structure */
308
296
typedef struct {
309
- /** The index of the cipher chosen */
310
- int cipher ,
311
- /** The block size of the given cipher */
312
- blocklen ,
297
+ /** The ECB context of the cipher */
298
+ symmetric_ECB ecb ;
313
299
/** The padding offset */
314
- padlen ,
300
+ int padlen ,
315
301
/** The mode (endianess) of the CTR, 0==little, 1==big */
316
302
mode ,
317
303
/** counter width */
318
304
ctrlen ;
319
-
320
305
/** The counter */
321
306
unsigned char ctr [MAXBLOCKSIZE ],
322
307
/** The pad used to encrypt/decrypt */
323
308
pad [MAXBLOCKSIZE ];
324
- /** The scheduled key */
325
- symmetric_key key ;
326
309
} symmetric_CTR ;
327
310
#endif
328
311
329
312
330
313
#ifdef LTC_LRW_MODE
331
314
/** A LRW structure */
332
315
typedef struct {
333
- /** The index of the cipher chosen (must be a 128-bit block cipher) */
334
- int cipher ;
335
-
316
+ /** The ECB context of the cipher */
317
+ symmetric_ECB ecb ;
336
318
/** The current IV */
337
319
unsigned char IV [16 ],
338
-
339
320
/** the tweak key */
340
321
tweak [16 ],
341
-
342
322
/** The current pad, it's the product of the first 15 bytes against the tweak key */
343
323
pad [16 ];
344
-
345
- /** The scheduled symmetric key */
346
- symmetric_key key ;
347
-
348
324
#ifdef LTC_LRW_TABLES
349
325
/** The pre-computed multiplication table */
350
326
unsigned char PC [16 ][256 ][16 ];
@@ -355,19 +331,15 @@ typedef struct {
355
331
#ifdef LTC_F8_MODE
356
332
/** A block cipher F8 structure */
357
333
typedef struct {
358
- /** The index of the cipher chosen */
359
- int cipher ,
360
- /** The block size of the given cipher */
361
- blocklen ,
334
+ /** The ECB context of the cipher */
335
+ symmetric_ECB ecb ;
362
336
/** The padding offset */
363
- padlen ;
337
+ int padlen ;
364
338
/** The current IV */
365
339
unsigned char IV [MAXBLOCKSIZE ],
366
340
MIV [MAXBLOCKSIZE ];
367
341
/** Current block count */
368
342
ulong32 blockcnt ;
369
- /** The scheduled key */
370
- symmetric_key key ;
371
343
} symmetric_F8 ;
372
344
#endif
373
345
@@ -432,7 +404,7 @@ extern struct ltc_cipher_descriptor {
432
404
@param skey The scheduled key context
433
405
@return CRYPT_OK if successful
434
406
*/
435
- int (* accel_ecb_encrypt )(const unsigned char * pt , unsigned char * ct , unsigned long blocks , symmetric_key * skey );
407
+ int (* accel_ecb_encrypt )(const unsigned char * pt , unsigned char * ct , unsigned long blocks , const symmetric_key * skey );
436
408
437
409
/** Accelerated ECB decryption
438
410
@param pt Plaintext
@@ -441,7 +413,7 @@ extern struct ltc_cipher_descriptor {
441
413
@param skey The scheduled key context
442
414
@return CRYPT_OK if successful
443
415
*/
444
- int (* accel_ecb_decrypt )(const unsigned char * ct , unsigned char * pt , unsigned long blocks , symmetric_key * skey );
416
+ int (* accel_ecb_decrypt )(const unsigned char * ct , unsigned char * pt , unsigned long blocks , const symmetric_key * skey );
445
417
446
418
/** Accelerated CBC encryption
447
419
@param pt Plaintext
@@ -451,7 +423,7 @@ extern struct ltc_cipher_descriptor {
451
423
@param skey The scheduled key context
452
424
@return CRYPT_OK if successful
453
425
*/
454
- int (* accel_cbc_encrypt )(const unsigned char * pt , unsigned char * ct , unsigned long blocks , unsigned char * IV , symmetric_key * skey );
426
+ int (* accel_cbc_encrypt )(const unsigned char * pt , unsigned char * ct , unsigned long blocks , unsigned char * IV , const symmetric_key * skey );
455
427
456
428
/** Accelerated CBC decryption
457
429
@param pt Plaintext
@@ -461,7 +433,7 @@ extern struct ltc_cipher_descriptor {
461
433
@param skey The scheduled key context
462
434
@return CRYPT_OK if successful
463
435
*/
464
- int (* accel_cbc_decrypt )(const unsigned char * ct , unsigned char * pt , unsigned long blocks , unsigned char * IV , symmetric_key * skey );
436
+ int (* accel_cbc_decrypt )(const unsigned char * ct , unsigned char * pt , unsigned long blocks , unsigned char * IV , const symmetric_key * skey );
465
437
466
438
/** Accelerated CTR encryption
467
439
@param pt Plaintext
@@ -472,7 +444,7 @@ extern struct ltc_cipher_descriptor {
472
444
@param skey The scheduled key context
473
445
@return CRYPT_OK if successful
474
446
*/
475
- int (* accel_ctr_encrypt )(const unsigned char * pt , unsigned char * ct , unsigned long blocks , unsigned char * IV , int mode , symmetric_key * skey );
447
+ int (* accel_ctr_encrypt )(const unsigned char * pt , unsigned char * ct , unsigned long blocks , unsigned char * IV , int mode , const symmetric_key * skey );
476
448
477
449
/** Accelerated LRW
478
450
@param pt Plaintext
@@ -483,7 +455,7 @@ extern struct ltc_cipher_descriptor {
483
455
@param skey The scheduled key context
484
456
@return CRYPT_OK if successful
485
457
*/
486
- int (* accel_lrw_encrypt )(const unsigned char * pt , unsigned char * ct , unsigned long blocks , unsigned char * IV , const unsigned char * tweak , symmetric_key * skey );
458
+ int (* accel_lrw_encrypt )(const unsigned char * pt , unsigned char * ct , unsigned long blocks , unsigned char * IV , const unsigned char * tweak , const symmetric_key * skey );
487
459
488
460
/** Accelerated LRW
489
461
@param ct Ciphertext
@@ -494,7 +466,7 @@ extern struct ltc_cipher_descriptor {
494
466
@param skey The scheduled key context
495
467
@return CRYPT_OK if successful
496
468
*/
497
- int (* accel_lrw_decrypt )(const unsigned char * ct , unsigned char * pt , unsigned long blocks , unsigned char * IV , const unsigned char * tweak , symmetric_key * skey );
469
+ int (* accel_lrw_decrypt )(const unsigned char * ct , unsigned char * pt , unsigned long blocks , unsigned char * IV , const unsigned char * tweak , const symmetric_key * skey );
498
470
499
471
/** Accelerated CCM packet (one-shot)
500
472
@param key The secret key to use
@@ -514,7 +486,7 @@ extern struct ltc_cipher_descriptor {
514
486
*/
515
487
int (* accel_ccm_memory )(
516
488
const unsigned char * key , unsigned long keylen ,
517
- symmetric_key * uskey ,
489
+ const symmetric_key * uskey ,
518
490
const unsigned char * nonce , unsigned long noncelen ,
519
491
const unsigned char * header , unsigned long headerlen ,
520
492
unsigned char * pt , unsigned long ptlen ,
@@ -875,8 +847,8 @@ extern const struct ltc_cipher_descriptor tea_desc;
875
847
#ifdef LTC_ECB_MODE
876
848
int ecb_start (int cipher , const unsigned char * key ,
877
849
int keylen , int num_rounds , symmetric_ECB * ecb );
878
- int ecb_encrypt (const unsigned char * pt , unsigned char * ct , unsigned long len , symmetric_ECB * ecb );
879
- int ecb_decrypt (const unsigned char * ct , unsigned char * pt , unsigned long len , symmetric_ECB * ecb );
850
+ int ecb_encrypt (const unsigned char * pt , unsigned char * ct , unsigned long len , const symmetric_ECB * ecb );
851
+ int ecb_decrypt (const unsigned char * ct , unsigned char * pt , unsigned long len , const symmetric_ECB * ecb );
880
852
int ecb_done (symmetric_ECB * ecb );
881
853
#endif
882
854
@@ -966,7 +938,7 @@ int f8_test_mode(void);
966
938
967
939
#ifdef LTC_XTS_MODE
968
940
typedef struct {
969
- symmetric_key key1 , key2 ;
941
+ symmetric_ECB key1 , key2 ;
970
942
int cipher ;
971
943
} symmetric_xts ;
972
944
0 commit comments