comparison libtomcrypt/src/ciphers/safer/saferp.c @ 1435:f849a5ca2efc

update to libtomcrypt 1.17 (with Dropbear changes)
author Matt Johnston <matt@ucc.asn.au>
date Sat, 24 Jun 2017 17:50:50 +0800
parents 0cbe8f6dbf9e
children 6dba84798cd5
comparison
equal deleted inserted replaced
1434:27b9ddb06b09 1435:f849a5ca2efc
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 saferp.c 13 @file saferp.c
14 SAFER+ Implementation by Tom St Denis 14 LTC_SAFER+ Implementation by Tom St Denis
15 */ 15 */
16 #include "tomcrypt.h" 16 #include "tomcrypt.h"
17 17
18 #ifdef SAFERP 18 #ifdef LTC_SAFERP
19 19
20 const struct ltc_cipher_descriptor saferp_desc = 20 const struct ltc_cipher_descriptor saferp_desc =
21 { 21 {
22 "safer+", 22 "safer+",
23 4, 23 4,
35 * 35 *
36 * This is one forward key application. Note the basic form is 36 * This is one forward key application. Note the basic form is
37 * key addition, substitution, key addition. The safer_ebox and safer_lbox 37 * key addition, substitution, key addition. The safer_ebox and safer_lbox
38 * are the exponentiation box and logarithm boxes respectively. 38 * are the exponentiation box and logarithm boxes respectively.
39 * The value of 'i' is the current round number which allows this 39 * The value of 'i' is the current round number which allows this
40 * function to be unrolled massively. Most of SAFER+'s speed 40 * function to be unrolled massively. Most of LTC_SAFER+'s speed
41 * comes from not having to compute indirect accesses into the 41 * comes from not having to compute indirect accesses into the
42 * array of 16 bytes b[0..15] which is the block of data 42 * array of 16 bytes b[0..15] which is the block of data
43 */ 43 */
44 44
45 extern const unsigned char safer_ebox[], safer_lbox[]; 45 extern const unsigned char safer_ebox[], safer_lbox[];
204 { 8, 103, 9, 148, 235, 38, 168, 107, 189, 24, 52, 27, 187, 191, 114, 247}, 204 { 8, 103, 9, 148, 235, 38, 168, 107, 189, 24, 52, 27, 187, 191, 114, 247},
205 { 53, 72, 156, 81, 47, 59, 85, 227, 192, 159, 216, 211, 243, 141, 177, 255}, 205 { 53, 72, 156, 81, 47, 59, 85, 227, 192, 159, 216, 211, 243, 141, 177, 255},
206 { 62, 220, 134, 119, 215, 166, 17, 251, 244, 186, 146, 145, 100, 131, 241, 51}}; 206 { 62, 220, 134, 119, 215, 166, 17, 251, 244, 186, 146, 145, 100, 131, 241, 51}};
207 207
208 /** 208 /**
209 Initialize the SAFER+ block cipher 209 Initialize the LTC_SAFER+ block cipher
210 @param key The symmetric key you wish to pass 210 @param key The symmetric key you wish to pass
211 @param keylen The key length in bytes 211 @param keylen The key length in bytes
212 @param num_rounds The number of rounds desired (0 for default) 212 @param num_rounds The number of rounds desired (0 for default)
213 @param skey The key in as scheduled by this function. 213 @param skey The key in as scheduled by this function.
214 @return CRYPT_OK if successful 214 @return CRYPT_OK if successful
323 #endif 323 #endif
324 return CRYPT_OK; 324 return CRYPT_OK;
325 } 325 }
326 326
327 /** 327 /**
328 Encrypts a block of text with SAFER+ 328 Encrypts a block of text with LTC_SAFER+
329 @param pt The input plaintext (16 bytes) 329 @param pt The input plaintext (16 bytes)
330 @param ct The output ciphertext (16 bytes) 330 @param ct The output ciphertext (16 bytes)
331 @param skey The key as scheduled 331 @param skey The key as scheduled
332 @return CRYPT_OK if successful 332 @return CRYPT_OK if successful
333 */ 333 */
387 #endif 387 #endif
388 return CRYPT_OK; 388 return CRYPT_OK;
389 } 389 }
390 390
391 /** 391 /**
392 Decrypts a block of text with SAFER+ 392 Decrypts a block of text with LTC_SAFER+
393 @param ct The input ciphertext (16 bytes) 393 @param ct The input ciphertext (16 bytes)
394 @param pt The output plaintext (16 bytes) 394 @param pt The output plaintext (16 bytes)
395 @param skey The key as scheduled 395 @param skey The key as scheduled
396 @return CRYPT_OK if successful 396 @return CRYPT_OK if successful
397 */ 397 */
451 #endif 451 #endif
452 return CRYPT_OK; 452 return CRYPT_OK;
453 } 453 }
454 454
455 /** 455 /**
456 Performs a self-test of the SAFER+ block cipher 456 Performs a self-test of the LTC_SAFER+ block cipher
457 @return CRYPT_OK if functional, CRYPT_NOP if self-test has been disabled 457 @return CRYPT_OK if functional, CRYPT_NOP if self-test has been disabled
458 */ 458 */
459 int saferp_test(void) 459 int saferp_test(void)
460 { 460 {
461 #ifndef LTC_TEST 461 #ifndef LTC_TEST
552 552
553 #endif 553 #endif
554 554
555 555
556 556
557 /* $Source: /cvs/libtom/libtomcrypt/src/ciphers/safer/saferp.c,v $ */ 557 /* $Source$ */
558 /* $Revision: 1.12 $ */ 558 /* $Revision$ */
559 /* $Date: 2006/11/08 23:01:06 $ */ 559 /* $Date$ */