Crypt-SEED

 view release on metacpan or  search on metacpan

SEED_KISA.c  view on Meta::CPAN

* DESCRIPTION: Core routines for the enhanced SEED
* 
*******************************************************************************/

/******************************* Include files ********************************/

#include "SEED_KISA.h"
#include "SEED_KISA.tab"


/******************** Macros for Encryption and Decryption ********************/

#define GetB0(A)  ( (BYTE)((A)    ) )
#define GetB1(A)  ( (BYTE)((A)>> 8) )
#define GetB2(A)  ( (BYTE)((A)>>16) )
#define GetB3(A)  ( (BYTE)((A)>>24) )

/* Round function F and adding output of F to L. */
/* L0, L1 : left input values at each round      */
/* R0, R1 : right input values at each round     */
/* K : round keys at each round                  */

SEED_KISA.c  view on Meta::CPAN

#define KC8     0x3779b99eUL
#define KC9     0x6ef3733cUL
#define KC10    0xdde6e678UL
#define KC11    0xbbcdccf1UL
#define KC12    0x779b99e3UL
#define KC13    0xef3733c6UL
#define KC14    0xde6e678dUL
#define KC15    0xbcdccf1bUL


/************************** Macros for Key schedule ***************************/

#define RoundKeyUpdate0(K, A, B, C, D, KC) {	\
    T0 = A + C - KC;                            \
    T1 = B + KC - D;                            \
    (K)[0] = SS0[GetB0(T0)] ^ SS1[GetB1(T0)] ^  \
             SS2[GetB2(T0)] ^ SS3[GetB3(T0)];   \
    (K)[1] = SS0[GetB0(T1)] ^ SS1[GetB1(T1)] ^  \
             SS2[GetB2(T1)] ^ SS3[GetB3(T1)];   \
    T0 = A;                                     \
    A = (A>>8) ^ (B<<24);                       \

SEED_KISA.h  view on Meta::CPAN

*/

/**************************** Constant Definitions ****************************/

#define NoRounds         16				/* the number of rounds     */
#define NoRoundKeys      (NoRounds*2)			/* the number of round-keys */
#define SeedBlockSize    16    				/* block length in bytes    */
#define SeedBlockLen     128   				/* block length in bits     */


/******************************** Common Macros *******************************/

/* macroses for left or right rotations */
#if defined(_MSC_VER)
    #define ROTL(x, n)     (_lrotl((x), (n)))		/* left rotation  */
    #define ROTR(x, n)     (_lrotr((x), (n)))		/* right rotation */
#else
    #define ROTL(x, n)     (((x) << (n)) | ((x) >> (32-(n))))		/* left rotation  */
    #define ROTR(x, n)     (((x) >> (n)) | ((x) << (32-(n))))		/* right rotation */
#endif



( run in 0.584 second using v1.01-cache-2.11-cpan-49f99fa48dc )