Mercurial > dropbear
comparison libtomcrypt/src/ciphers/cast5.c @ 1439:8d24733026c5 coverity
merge
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sat, 24 Jun 2017 23:33:16 +0800 |
parents | f849a5ca2efc |
children | 6dba84798cd5 |
comparison
equal
deleted
inserted
replaced
1400:238a439670f5 | 1439:8d24733026c5 |
---|---|
4 * algorithms in a highly modular and flexible manner. | 4 * algorithms in a highly modular and flexible manner. |
5 * | 5 * |
6 * The library is free for all purposes without any express | 6 * The library is free for all purposes without any express |
7 * guarantee it works. | 7 * guarantee it works. |
8 * | 8 * |
9 * Tom St Denis, [email protected], http://libtomcrypt.com | 9 * Tom St Denis, [email protected], http://libtom.org |
10 */ | 10 */ |
11 | 11 |
12 /** | 12 /** |
13 @file cast5.c | 13 @file cast5.c |
14 Implementation of CAST5 (RFC 2144) by Tom St Denis | 14 Implementation of LTC_CAST5 (RFC 2144) by Tom St Denis |
15 */ | 15 */ |
16 #include "tomcrypt.h" | 16 #include "tomcrypt.h" |
17 | 17 |
18 #ifdef CAST5 | 18 #ifdef LTC_CAST5 |
19 | 19 |
20 const struct ltc_cipher_descriptor cast5_desc = { | 20 const struct ltc_cipher_descriptor cast5_desc = { |
21 "cast5", | 21 "cast5", |
22 15, | 22 15, |
23 5, 16, 8, 16, | 23 5, 16, 8, 16, |
396 #else | 396 #else |
397 #define GB(x, i) (((x[(15-i)>>2])>>(unsigned)(8*((15-i)&3)))&255) | 397 #define GB(x, i) (((x[(15-i)>>2])>>(unsigned)(8*((15-i)&3)))&255) |
398 #endif | 398 #endif |
399 | 399 |
400 /** | 400 /** |
401 Initialize the CAST5 block cipher | 401 Initialize the LTC_CAST5 block cipher |
402 @param key The symmetric key you wish to pass | 402 @param key The symmetric key you wish to pass |
403 @param keylen The key length in bytes | 403 @param keylen The key length in bytes |
404 @param num_rounds The number of rounds desired (0 for default) | 404 @param num_rounds The number of rounds desired (0 for default) |
405 @param skey The key in as scheduled by this function. | 405 @param skey The key in as scheduled by this function. |
406 @return CRYPT_OK if successful | 406 @return CRYPT_OK if successful |
528 I = ROL(I, Kr); | 528 I = ROL(I, Kr); |
529 return ((S1[byte(I, 3)] + S2[byte(I,2)]) ^ S3[byte(I,1)]) - S4[byte(I,0)]; | 529 return ((S1[byte(I, 3)] + S2[byte(I,2)]) ^ S3[byte(I,1)]) - S4[byte(I,0)]; |
530 } | 530 } |
531 | 531 |
532 /** | 532 /** |
533 Encrypts a block of text with CAST5 | 533 Encrypts a block of text with LTC_CAST5 |
534 @param pt The input plaintext (8 bytes) | 534 @param pt The input plaintext (8 bytes) |
535 @param ct The output ciphertext (8 bytes) | 535 @param ct The output ciphertext (8 bytes) |
536 @param skey The key as scheduled | 536 @param skey The key as scheduled |
537 */ | 537 */ |
538 #ifdef LTC_CLEAN_STACK | 538 #ifdef LTC_CLEAN_STACK |
581 return err; | 581 return err; |
582 } | 582 } |
583 #endif | 583 #endif |
584 | 584 |
585 /** | 585 /** |
586 Decrypts a block of text with CAST5 | 586 Decrypts a block of text with LTC_CAST5 |
587 @param ct The input ciphertext (8 bytes) | 587 @param ct The input ciphertext (8 bytes) |
588 @param pt The output plaintext (8 bytes) | 588 @param pt The output plaintext (8 bytes) |
589 @param skey The key as scheduled | 589 @param skey The key as scheduled |
590 */ | 590 */ |
591 #ifdef LTC_CLEAN_STACK | 591 #ifdef LTC_CLEAN_STACK |
634 return err; | 634 return err; |
635 } | 635 } |
636 #endif | 636 #endif |
637 | 637 |
638 /** | 638 /** |
639 Performs a self-test of the CAST5 block cipher | 639 Performs a self-test of the LTC_CAST5 block cipher |
640 @return CRYPT_OK if functional, CRYPT_NOP if self-test has been disabled | 640 @return CRYPT_OK if functional, CRYPT_NOP if self-test has been disabled |
641 */ | 641 */ |
642 int cast5_test(void) | 642 int cast5_test(void) |
643 { | 643 { |
644 #ifndef LTC_TEST | 644 #ifndef LTC_TEST |
713 return CRYPT_OK; | 713 return CRYPT_OK; |
714 } | 714 } |
715 | 715 |
716 #endif | 716 #endif |
717 | 717 |
718 /* $Source: /cvs/libtom/libtomcrypt/src/ciphers/cast5.c,v $ */ | 718 /* $Source$ */ |
719 /* $Revision: 1.12 $ */ | 719 /* $Revision$ */ |
720 /* $Date: 2006/11/08 23:01:06 $ */ | 720 /* $Date$ */ |