|
@@ -35,8 +35,9 @@ struct saferp_key {
|
|
|
|
|
|
#ifdef LTC_RIJNDAEL
|
|
#ifdef LTC_RIJNDAEL
|
|
struct rijndael_key {
|
|
struct rijndael_key {
|
|
- ulong32 eK[60] LTC_ALIGN(16);
|
|
|
|
- ulong32 dK[60] LTC_ALIGN(16);
|
|
|
|
|
|
+ unsigned char K[(60 + 60 + 4) * sizeof(ulong32)];
|
|
|
|
+ ulong32 *eK;
|
|
|
|
+ ulong32 *dK;
|
|
int Nr;
|
|
int Nr;
|
|
};
|
|
};
|
|
#endif
|
|
#endif
|
|
@@ -128,24 +129,24 @@ struct khazad_key {
|
|
|
|
|
|
#ifdef LTC_ANUBIS
|
|
#ifdef LTC_ANUBIS
|
|
struct anubis_key {
|
|
struct anubis_key {
|
|
- int keyBits;
|
|
|
|
- int R;
|
|
|
|
ulong32 roundKeyEnc[18 + 1][4];
|
|
ulong32 roundKeyEnc[18 + 1][4];
|
|
ulong32 roundKeyDec[18 + 1][4];
|
|
ulong32 roundKeyDec[18 + 1][4];
|
|
|
|
+ int keyBits;
|
|
|
|
+ int R;
|
|
};
|
|
};
|
|
#endif
|
|
#endif
|
|
|
|
|
|
#ifdef LTC_MULTI2
|
|
#ifdef LTC_MULTI2
|
|
struct multi2_key {
|
|
struct multi2_key {
|
|
- int N;
|
|
|
|
ulong32 uk[8];
|
|
ulong32 uk[8];
|
|
|
|
+ int N;
|
|
};
|
|
};
|
|
#endif
|
|
#endif
|
|
|
|
|
|
#ifdef LTC_CAMELLIA
|
|
#ifdef LTC_CAMELLIA
|
|
struct camellia_key {
|
|
struct camellia_key {
|
|
- int R;
|
|
|
|
ulong64 kw[4], k[24], kl[6];
|
|
ulong64 kw[4], k[24], kl[6];
|
|
|
|
+ int R;
|
|
};
|
|
};
|
|
#endif
|
|
#endif
|
|
|
|
|
|
@@ -246,60 +247,60 @@ typedef union Symmetric_key {
|
|
#ifdef LTC_ECB_MODE
|
|
#ifdef LTC_ECB_MODE
|
|
/** A block cipher ECB structure */
|
|
/** A block cipher ECB structure */
|
|
typedef struct {
|
|
typedef struct {
|
|
|
|
+ /** The scheduled key */
|
|
|
|
+ symmetric_key key;
|
|
/** The index of the cipher chosen */
|
|
/** The index of the cipher chosen */
|
|
int cipher,
|
|
int cipher,
|
|
/** The block size of the given cipher */
|
|
/** The block size of the given cipher */
|
|
blocklen;
|
|
blocklen;
|
|
- /** The scheduled key */
|
|
|
|
- symmetric_key key;
|
|
|
|
} symmetric_ECB;
|
|
} symmetric_ECB;
|
|
#endif
|
|
#endif
|
|
|
|
|
|
#ifdef LTC_CFB_MODE
|
|
#ifdef LTC_CFB_MODE
|
|
/** A block cipher CFB structure */
|
|
/** A block cipher CFB structure */
|
|
typedef struct {
|
|
typedef struct {
|
|
- /** The index of the cipher chosen */
|
|
|
|
- int cipher,
|
|
|
|
- /** The block size of the given cipher */
|
|
|
|
- blocklen,
|
|
|
|
- /** The padding offset */
|
|
|
|
- padlen;
|
|
|
|
/** The current IV */
|
|
/** The current IV */
|
|
unsigned char IV[MAXBLOCKSIZE],
|
|
unsigned char IV[MAXBLOCKSIZE],
|
|
/** The pad used to encrypt/decrypt */
|
|
/** The pad used to encrypt/decrypt */
|
|
pad[MAXBLOCKSIZE];
|
|
pad[MAXBLOCKSIZE];
|
|
/** The scheduled key */
|
|
/** The scheduled key */
|
|
symmetric_key key;
|
|
symmetric_key key;
|
|
|
|
+ /** The index of the cipher chosen */
|
|
|
|
+ int cipher,
|
|
|
|
+ /** The block size of the given cipher */
|
|
|
|
+ blocklen,
|
|
|
|
+ /** The padding offset */
|
|
|
|
+ padlen;
|
|
} symmetric_CFB;
|
|
} symmetric_CFB;
|
|
#endif
|
|
#endif
|
|
|
|
|
|
#ifdef LTC_OFB_MODE
|
|
#ifdef LTC_OFB_MODE
|
|
/** A block cipher OFB structure */
|
|
/** A block cipher OFB structure */
|
|
typedef struct {
|
|
typedef struct {
|
|
|
|
+ /** The current IV */
|
|
|
|
+ unsigned char IV[MAXBLOCKSIZE];
|
|
|
|
+ /** The scheduled key */
|
|
|
|
+ symmetric_key key;
|
|
/** The index of the cipher chosen */
|
|
/** The index of the cipher chosen */
|
|
int cipher,
|
|
int cipher,
|
|
/** The block size of the given cipher */
|
|
/** The block size of the given cipher */
|
|
blocklen,
|
|
blocklen,
|
|
/** The padding offset */
|
|
/** The padding offset */
|
|
padlen;
|
|
padlen;
|
|
- /** The current IV */
|
|
|
|
- unsigned char IV[MAXBLOCKSIZE];
|
|
|
|
- /** The scheduled key */
|
|
|
|
- symmetric_key key;
|
|
|
|
} symmetric_OFB;
|
|
} symmetric_OFB;
|
|
#endif
|
|
#endif
|
|
|
|
|
|
#ifdef LTC_CBC_MODE
|
|
#ifdef LTC_CBC_MODE
|
|
/** A block cipher CBC structure */
|
|
/** A block cipher CBC structure */
|
|
typedef struct {
|
|
typedef struct {
|
|
- /** The index of the cipher chosen */
|
|
|
|
- int cipher,
|
|
|
|
- /** The block size of the given cipher */
|
|
|
|
- blocklen;
|
|
|
|
/** The current IV */
|
|
/** The current IV */
|
|
unsigned char IV[MAXBLOCKSIZE];
|
|
unsigned char IV[MAXBLOCKSIZE];
|
|
/** The scheduled key */
|
|
/** The scheduled key */
|
|
symmetric_key key;
|
|
symmetric_key key;
|
|
|
|
+ /** The index of the cipher chosen */
|
|
|
|
+ int cipher,
|
|
|
|
+ /** The block size of the given cipher */
|
|
|
|
+ blocklen;
|
|
} symmetric_CBC;
|
|
} symmetric_CBC;
|
|
#endif
|
|
#endif
|
|
|
|
|
|
@@ -307,6 +308,13 @@ typedef struct {
|
|
#ifdef LTC_CTR_MODE
|
|
#ifdef LTC_CTR_MODE
|
|
/** A block cipher CTR structure */
|
|
/** A block cipher CTR structure */
|
|
typedef struct {
|
|
typedef struct {
|
|
|
|
+ /** The counter */
|
|
|
|
+ unsigned char ctr[MAXBLOCKSIZE];
|
|
|
|
+ /** The pad used to encrypt/decrypt */
|
|
|
|
+ unsigned char pad[MAXBLOCKSIZE];
|
|
|
|
+ /** The scheduled key */
|
|
|
|
+ symmetric_key key;
|
|
|
|
+
|
|
/** The index of the cipher chosen */
|
|
/** The index of the cipher chosen */
|
|
int cipher,
|
|
int cipher,
|
|
/** The block size of the given cipher */
|
|
/** The block size of the given cipher */
|
|
@@ -317,13 +325,6 @@ typedef struct {
|
|
mode,
|
|
mode,
|
|
/** counter width */
|
|
/** counter width */
|
|
ctrlen;
|
|
ctrlen;
|
|
-
|
|
|
|
- /** The counter */
|
|
|
|
- unsigned char ctr[MAXBLOCKSIZE];
|
|
|
|
- /** The pad used to encrypt/decrypt */
|
|
|
|
- unsigned char pad[MAXBLOCKSIZE] LTC_ALIGN(16);
|
|
|
|
- /** The scheduled key */
|
|
|
|
- symmetric_key key;
|
|
|
|
} symmetric_CTR;
|
|
} symmetric_CTR;
|
|
#endif
|
|
#endif
|
|
|
|
|
|
@@ -331,9 +332,6 @@ typedef struct {
|
|
#ifdef LTC_LRW_MODE
|
|
#ifdef LTC_LRW_MODE
|
|
/** A LRW structure */
|
|
/** A LRW structure */
|
|
typedef struct {
|
|
typedef struct {
|
|
- /** The index of the cipher chosen (must be a 128-bit block cipher) */
|
|
|
|
- int cipher;
|
|
|
|
-
|
|
|
|
/** The current IV */
|
|
/** The current IV */
|
|
unsigned char IV[16],
|
|
unsigned char IV[16],
|
|
|
|
|
|
@@ -350,25 +348,28 @@ typedef struct {
|
|
/** The pre-computed multiplication table */
|
|
/** The pre-computed multiplication table */
|
|
unsigned char PC[16][256][16];
|
|
unsigned char PC[16][256][16];
|
|
#endif
|
|
#endif
|
|
|
|
+
|
|
|
|
+ /** The index of the cipher chosen (must be a 128-bit block cipher) */
|
|
|
|
+ int cipher;
|
|
} symmetric_LRW;
|
|
} symmetric_LRW;
|
|
#endif
|
|
#endif
|
|
|
|
|
|
#ifdef LTC_F8_MODE
|
|
#ifdef LTC_F8_MODE
|
|
/** A block cipher F8 structure */
|
|
/** A block cipher F8 structure */
|
|
typedef struct {
|
|
typedef struct {
|
|
|
|
+ /** The current IV */
|
|
|
|
+ unsigned char IV[MAXBLOCKSIZE],
|
|
|
|
+ MIV[MAXBLOCKSIZE];
|
|
|
|
+ /** The scheduled key */
|
|
|
|
+ symmetric_key key;
|
|
/** The index of the cipher chosen */
|
|
/** The index of the cipher chosen */
|
|
int cipher,
|
|
int cipher,
|
|
/** The block size of the given cipher */
|
|
/** The block size of the given cipher */
|
|
blocklen,
|
|
blocklen,
|
|
/** The padding offset */
|
|
/** The padding offset */
|
|
padlen;
|
|
padlen;
|
|
- /** The current IV */
|
|
|
|
- unsigned char IV[MAXBLOCKSIZE],
|
|
|
|
- MIV[MAXBLOCKSIZE];
|
|
|
|
/** Current block count */
|
|
/** Current block count */
|
|
ulong32 blockcnt;
|
|
ulong32 blockcnt;
|
|
- /** The scheduled key */
|
|
|
|
- symmetric_key key;
|
|
|
|
} symmetric_F8;
|
|
} symmetric_F8;
|
|
#endif
|
|
#endif
|
|
|
|
|