trim trailing spaces in header files
This commit is contained in:
parent
2526d5df8f
commit
bfcf1eb200
@ -22,7 +22,7 @@ void crypt_argchk(char *v, char *s, int d);
|
|||||||
|
|
||||||
#elif ARGTYPE == 3
|
#elif ARGTYPE == 3
|
||||||
|
|
||||||
#define LTC_ARGCHK(x)
|
#define LTC_ARGCHK(x)
|
||||||
#define LTC_ARGCHKVD(x) LTC_ARGCHK(x)
|
#define LTC_ARGCHKVD(x) LTC_ARGCHK(x)
|
||||||
|
|
||||||
#elif ARGTYPE == 4
|
#elif ARGTYPE == 4
|
||||||
|
@ -48,8 +48,8 @@ LTC_EXPORT int LTC_CALL XSTRCMP(const char *s1, const char *s2);
|
|||||||
#define ARGTYPE 0
|
#define ARGTYPE 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Controls endianess and size of registers. Leave uncommented to get platform neutral [slower] code
|
/* Controls endianess and size of registers. Leave uncommented to get platform neutral [slower] code
|
||||||
*
|
*
|
||||||
* Note: in order to use the optimized macros your platform must support unaligned 32 and 64 bit read/writes.
|
* Note: in order to use the optimized macros your platform must support unaligned 32 and 64 bit read/writes.
|
||||||
* The x86 platforms allow this but some others [ARM for instance] do not. On those platforms you **MUST**
|
* The x86 platforms allow this but some others [ARM for instance] do not. On those platforms you **MUST**
|
||||||
* use the portable [slower] macros.
|
* use the portable [slower] macros.
|
||||||
@ -83,7 +83,7 @@ LTC_EXPORT int LTC_CALL XSTRCMP(const char *s1, const char *s2);
|
|||||||
#define ENDIAN_32BITWORD
|
#define ENDIAN_32BITWORD
|
||||||
#define LTC_FAST
|
#define LTC_FAST
|
||||||
#define LTC_FAST_TYPE unsigned long
|
#define LTC_FAST_TYPE unsigned long
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* detect sparc and sparc64 */
|
/* detect sparc and sparc64 */
|
||||||
#if defined(__sparc__)
|
#if defined(__sparc__)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/* ---- SYMMETRIC KEY STUFF -----
|
/* ---- SYMMETRIC KEY STUFF -----
|
||||||
*
|
*
|
||||||
* We put each of the ciphers scheduled keys in their own structs then we put all of
|
* We put each of the ciphers scheduled keys in their own structs then we put all of
|
||||||
* the key formats in one union. This makes the function prototypes easier to use.
|
* the key formats in one union. This makes the function prototypes easier to use.
|
||||||
*/
|
*/
|
||||||
#ifdef LTC_BLOWFISH
|
#ifdef LTC_BLOWFISH
|
||||||
@ -109,7 +109,7 @@ struct noekeon_key {
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef LTC_SKIPJACK
|
#ifdef LTC_SKIPJACK
|
||||||
struct skipjack_key {
|
struct skipjack_key {
|
||||||
unsigned char key[10];
|
unsigned char key[10];
|
||||||
};
|
};
|
||||||
@ -117,18 +117,18 @@ struct skipjack_key {
|
|||||||
|
|
||||||
#ifdef LTC_KHAZAD
|
#ifdef LTC_KHAZAD
|
||||||
struct khazad_key {
|
struct khazad_key {
|
||||||
ulong64 roundKeyEnc[8 + 1];
|
ulong64 roundKeyEnc[8 + 1];
|
||||||
ulong64 roundKeyDec[8 + 1];
|
ulong64 roundKeyDec[8 + 1];
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef LTC_ANUBIS
|
#ifdef LTC_ANUBIS
|
||||||
struct anubis_key {
|
struct anubis_key {
|
||||||
int keyBits;
|
int keyBits;
|
||||||
int R;
|
int R;
|
||||||
ulong32 roundKeyEnc[18 + 1][4];
|
ulong32 roundKeyEnc[18 + 1][4];
|
||||||
ulong32 roundKeyDec[18 + 1][4];
|
ulong32 roundKeyDec[18 + 1][4];
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef LTC_MULTI2
|
#ifdef LTC_MULTI2
|
||||||
@ -182,7 +182,7 @@ typedef union Symmetric_key {
|
|||||||
#endif
|
#endif
|
||||||
#ifdef LTC_NOEKEON
|
#ifdef LTC_NOEKEON
|
||||||
struct noekeon_key noekeon;
|
struct noekeon_key noekeon;
|
||||||
#endif
|
#endif
|
||||||
#ifdef LTC_SKIPJACK
|
#ifdef LTC_SKIPJACK
|
||||||
struct skipjack_key skipjack;
|
struct skipjack_key skipjack;
|
||||||
#endif
|
#endif
|
||||||
@ -197,7 +197,7 @@ typedef union Symmetric_key {
|
|||||||
#endif
|
#endif
|
||||||
#ifdef LTC_KASUMI
|
#ifdef LTC_KASUMI
|
||||||
struct kasumi_key kasumi;
|
struct kasumi_key kasumi;
|
||||||
#endif
|
#endif
|
||||||
#ifdef LTC_MULTI2
|
#ifdef LTC_MULTI2
|
||||||
struct multi2_key multi2;
|
struct multi2_key multi2;
|
||||||
#endif
|
#endif
|
||||||
@ -211,10 +211,10 @@ typedef union Symmetric_key {
|
|||||||
/** A block cipher ECB structure */
|
/** A block cipher ECB structure */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/** 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 */
|
/** The scheduled key */
|
||||||
symmetric_key key;
|
symmetric_key key;
|
||||||
} symmetric_ECB;
|
} symmetric_ECB;
|
||||||
#endif
|
#endif
|
||||||
@ -223,14 +223,14 @@ typedef struct {
|
|||||||
/** A block cipher CFB structure */
|
/** A block cipher CFB structure */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/** 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 */
|
/** 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;
|
||||||
@ -241,9 +241,9 @@ typedef struct {
|
|||||||
/** A block cipher OFB structure */
|
/** A block cipher OFB structure */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/** 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 */
|
/** The current IV */
|
||||||
@ -257,8 +257,8 @@ typedef struct {
|
|||||||
/** A block cipher CBC structure */
|
/** A block cipher CBC structure */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/** 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 current IV */
|
/** The current IV */
|
||||||
unsigned char IV[MAXBLOCKSIZE];
|
unsigned char IV[MAXBLOCKSIZE];
|
||||||
@ -273,18 +273,18 @@ typedef struct {
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
/** 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 mode (endianess) of the CTR, 0==little, 1==big */
|
/** The mode (endianess) of the CTR, 0==little, 1==big */
|
||||||
mode,
|
mode,
|
||||||
/** counter width */
|
/** counter width */
|
||||||
ctrlen;
|
ctrlen;
|
||||||
|
|
||||||
/** The counter */
|
/** The counter */
|
||||||
unsigned char ctr[MAXBLOCKSIZE],
|
unsigned char ctr[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;
|
||||||
@ -300,7 +300,7 @@ typedef struct {
|
|||||||
|
|
||||||
/** The current IV */
|
/** The current IV */
|
||||||
unsigned char IV[16],
|
unsigned char IV[16],
|
||||||
|
|
||||||
/** the tweak key */
|
/** the tweak key */
|
||||||
tweak[16],
|
tweak[16],
|
||||||
|
|
||||||
@ -321,9 +321,9 @@ typedef struct {
|
|||||||
/** A block cipher F8 structure */
|
/** A block cipher F8 structure */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/** 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 */
|
/** The current IV */
|
||||||
@ -344,14 +344,14 @@ extern struct ltc_cipher_descriptor {
|
|||||||
/** internal ID */
|
/** internal ID */
|
||||||
unsigned char ID;
|
unsigned char ID;
|
||||||
/** min keysize (octets) */
|
/** min keysize (octets) */
|
||||||
int min_key_length,
|
int min_key_length,
|
||||||
/** max keysize (octets) */
|
/** max keysize (octets) */
|
||||||
max_key_length,
|
max_key_length,
|
||||||
/** block size (octets) */
|
/** block size (octets) */
|
||||||
block_length,
|
block_length,
|
||||||
/** default number of rounds */
|
/** default number of rounds */
|
||||||
default_rounds;
|
default_rounds;
|
||||||
/** Setup the cipher
|
/** Setup the cipher
|
||||||
@param key The input symmetric key
|
@param key The input symmetric key
|
||||||
@param keylen The length of the input key (octets)
|
@param keylen The length of the input key (octets)
|
||||||
@param num_rounds The requested number of rounds (0==default)
|
@param num_rounds The requested number of rounds (0==default)
|
||||||
@ -378,10 +378,10 @@ extern struct ltc_cipher_descriptor {
|
|||||||
*/
|
*/
|
||||||
int (*test)(void);
|
int (*test)(void);
|
||||||
|
|
||||||
/** Terminate the context
|
/** Terminate the context
|
||||||
@param skey The scheduled key
|
@param skey The scheduled key
|
||||||
*/
|
*/
|
||||||
void (*done)(symmetric_key *skey);
|
void (*done)(symmetric_key *skey);
|
||||||
|
|
||||||
/** Determine a key size
|
/** Determine a key size
|
||||||
@param keysize [in/out] The size of the key desired and the suggested size
|
@param keysize [in/out] The size of the key desired and the suggested size
|
||||||
@ -390,7 +390,7 @@ extern struct ltc_cipher_descriptor {
|
|||||||
int (*keysize)(int *keysize);
|
int (*keysize)(int *keysize);
|
||||||
|
|
||||||
/** Accelerators **/
|
/** Accelerators **/
|
||||||
/** Accelerated ECB encryption
|
/** Accelerated ECB encryption
|
||||||
@param pt Plaintext
|
@param pt Plaintext
|
||||||
@param ct Ciphertext
|
@param ct Ciphertext
|
||||||
@param blocks The number of complete blocks to process
|
@param blocks The number of complete blocks to process
|
||||||
@ -399,7 +399,7 @@ extern struct ltc_cipher_descriptor {
|
|||||||
*/
|
*/
|
||||||
int (*accel_ecb_encrypt)(const unsigned char *pt, unsigned char *ct, unsigned long blocks, symmetric_key *skey);
|
int (*accel_ecb_encrypt)(const unsigned char *pt, unsigned char *ct, unsigned long blocks, symmetric_key *skey);
|
||||||
|
|
||||||
/** Accelerated ECB decryption
|
/** Accelerated ECB decryption
|
||||||
@param pt Plaintext
|
@param pt Plaintext
|
||||||
@param ct Ciphertext
|
@param ct Ciphertext
|
||||||
@param blocks The number of complete blocks to process
|
@param blocks The number of complete blocks to process
|
||||||
@ -408,7 +408,7 @@ extern struct ltc_cipher_descriptor {
|
|||||||
*/
|
*/
|
||||||
int (*accel_ecb_decrypt)(const unsigned char *ct, unsigned char *pt, unsigned long blocks, symmetric_key *skey);
|
int (*accel_ecb_decrypt)(const unsigned char *ct, unsigned char *pt, unsigned long blocks, symmetric_key *skey);
|
||||||
|
|
||||||
/** Accelerated CBC encryption
|
/** Accelerated CBC encryption
|
||||||
@param pt Plaintext
|
@param pt Plaintext
|
||||||
@param ct Ciphertext
|
@param ct Ciphertext
|
||||||
@param blocks The number of complete blocks to process
|
@param blocks The number of complete blocks to process
|
||||||
@ -418,7 +418,7 @@ extern struct ltc_cipher_descriptor {
|
|||||||
*/
|
*/
|
||||||
int (*accel_cbc_encrypt)(const unsigned char *pt, unsigned char *ct, unsigned long blocks, unsigned char *IV, symmetric_key *skey);
|
int (*accel_cbc_encrypt)(const unsigned char *pt, unsigned char *ct, unsigned long blocks, unsigned char *IV, symmetric_key *skey);
|
||||||
|
|
||||||
/** Accelerated CBC decryption
|
/** Accelerated CBC decryption
|
||||||
@param pt Plaintext
|
@param pt Plaintext
|
||||||
@param ct Ciphertext
|
@param ct Ciphertext
|
||||||
@param blocks The number of complete blocks to process
|
@param blocks The number of complete blocks to process
|
||||||
@ -428,7 +428,7 @@ extern struct ltc_cipher_descriptor {
|
|||||||
*/
|
*/
|
||||||
int (*accel_cbc_decrypt)(const unsigned char *ct, unsigned char *pt, unsigned long blocks, unsigned char *IV, symmetric_key *skey);
|
int (*accel_cbc_decrypt)(const unsigned char *ct, unsigned char *pt, unsigned long blocks, unsigned char *IV, symmetric_key *skey);
|
||||||
|
|
||||||
/** Accelerated CTR encryption
|
/** Accelerated CTR encryption
|
||||||
@param pt Plaintext
|
@param pt Plaintext
|
||||||
@param ct Ciphertext
|
@param ct Ciphertext
|
||||||
@param blocks The number of complete blocks to process
|
@param blocks The number of complete blocks to process
|
||||||
@ -439,7 +439,7 @@ extern struct ltc_cipher_descriptor {
|
|||||||
*/
|
*/
|
||||||
int (*accel_ctr_encrypt)(const unsigned char *pt, unsigned char *ct, unsigned long blocks, unsigned char *IV, int mode, symmetric_key *skey);
|
int (*accel_ctr_encrypt)(const unsigned char *pt, unsigned char *ct, unsigned long blocks, unsigned char *IV, int mode, symmetric_key *skey);
|
||||||
|
|
||||||
/** Accelerated LRW
|
/** Accelerated LRW
|
||||||
@param pt Plaintext
|
@param pt Plaintext
|
||||||
@param ct Ciphertext
|
@param ct Ciphertext
|
||||||
@param blocks The number of complete blocks to process
|
@param blocks The number of complete blocks to process
|
||||||
@ -450,7 +450,7 @@ extern struct ltc_cipher_descriptor {
|
|||||||
*/
|
*/
|
||||||
int (*accel_lrw_encrypt)(const unsigned char *pt, unsigned char *ct, unsigned long blocks, unsigned char *IV, const unsigned char *tweak, symmetric_key *skey);
|
int (*accel_lrw_encrypt)(const unsigned char *pt, unsigned char *ct, unsigned long blocks, unsigned char *IV, const unsigned char *tweak, symmetric_key *skey);
|
||||||
|
|
||||||
/** Accelerated LRW
|
/** Accelerated LRW
|
||||||
@param ct Ciphertext
|
@param ct Ciphertext
|
||||||
@param pt Plaintext
|
@param pt Plaintext
|
||||||
@param blocks The number of complete blocks to process
|
@param blocks The number of complete blocks to process
|
||||||
@ -490,7 +490,7 @@ extern struct ltc_cipher_descriptor {
|
|||||||
/** Accelerated GCM packet (one shot)
|
/** Accelerated GCM packet (one shot)
|
||||||
@param key The secret key
|
@param key The secret key
|
||||||
@param keylen The length of the secret key
|
@param keylen The length of the secret key
|
||||||
@param IV The initial vector
|
@param IV The initial vector
|
||||||
@param IVlen The length of the initial vector
|
@param IVlen The length of the initial vector
|
||||||
@param adata The additional authentication data (header)
|
@param adata The additional authentication data (header)
|
||||||
@param adatalen The length of the adata
|
@param adatalen The length of the adata
|
||||||
@ -507,14 +507,14 @@ extern struct ltc_cipher_descriptor {
|
|||||||
const unsigned char *IV, unsigned long IVlen,
|
const unsigned char *IV, unsigned long IVlen,
|
||||||
const unsigned char *adata, unsigned long adatalen,
|
const unsigned char *adata, unsigned long adatalen,
|
||||||
unsigned char *pt, unsigned long ptlen,
|
unsigned char *pt, unsigned long ptlen,
|
||||||
unsigned char *ct,
|
unsigned char *ct,
|
||||||
unsigned char *tag, unsigned long *taglen,
|
unsigned char *tag, unsigned long *taglen,
|
||||||
int direction);
|
int direction);
|
||||||
|
|
||||||
/** Accelerated one shot LTC_OMAC
|
/** Accelerated one shot LTC_OMAC
|
||||||
@param key The secret key
|
@param key The secret key
|
||||||
@param keylen The key length (octets)
|
@param keylen The key length (octets)
|
||||||
@param in The message
|
@param in The message
|
||||||
@param inlen Length of message (octets)
|
@param inlen Length of message (octets)
|
||||||
@param out [out] Destination for tag
|
@param out [out] Destination for tag
|
||||||
@param outlen [in/out] Initial and final size of out
|
@param outlen [in/out] Initial and final size of out
|
||||||
@ -525,10 +525,10 @@ extern struct ltc_cipher_descriptor {
|
|||||||
const unsigned char *in, unsigned long inlen,
|
const unsigned char *in, unsigned long inlen,
|
||||||
unsigned char *out, unsigned long *outlen);
|
unsigned char *out, unsigned long *outlen);
|
||||||
|
|
||||||
/** Accelerated one shot XCBC
|
/** Accelerated one shot XCBC
|
||||||
@param key The secret key
|
@param key The secret key
|
||||||
@param keylen The key length (octets)
|
@param keylen The key length (octets)
|
||||||
@param in The message
|
@param in The message
|
||||||
@param inlen Length of message (octets)
|
@param inlen Length of message (octets)
|
||||||
@param out [out] Destination for tag
|
@param out [out] Destination for tag
|
||||||
@param outlen [in/out] Initial and final size of out
|
@param outlen [in/out] Initial and final size of out
|
||||||
@ -539,10 +539,10 @@ extern struct ltc_cipher_descriptor {
|
|||||||
const unsigned char *in, unsigned long inlen,
|
const unsigned char *in, unsigned long inlen,
|
||||||
unsigned char *out, unsigned long *outlen);
|
unsigned char *out, unsigned long *outlen);
|
||||||
|
|
||||||
/** Accelerated one shot F9
|
/** Accelerated one shot F9
|
||||||
@param key The secret key
|
@param key The secret key
|
||||||
@param keylen The key length (octets)
|
@param keylen The key length (octets)
|
||||||
@param in The message
|
@param in The message
|
||||||
@param inlen Length of message (octets)
|
@param inlen Length of message (octets)
|
||||||
@param out [out] Destination for tag
|
@param out [out] Destination for tag
|
||||||
@param outlen [in/out] Initial and final size of out
|
@param outlen [in/out] Initial and final size of out
|
||||||
@ -777,7 +777,7 @@ extern const struct ltc_cipher_descriptor camellia_desc;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef LTC_ECB_MODE
|
#ifdef LTC_ECB_MODE
|
||||||
int ecb_start(int cipher, const unsigned char *key,
|
int ecb_start(int cipher, const unsigned char *key,
|
||||||
int keylen, int num_rounds, symmetric_ECB *ecb);
|
int keylen, int num_rounds, symmetric_ECB *ecb);
|
||||||
int ecb_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, symmetric_ECB *ecb);
|
int ecb_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, symmetric_ECB *ecb);
|
||||||
int ecb_decrypt(const unsigned char *ct, unsigned char *pt, unsigned long len, symmetric_ECB *ecb);
|
int ecb_decrypt(const unsigned char *ct, unsigned char *pt, unsigned long len, symmetric_ECB *ecb);
|
||||||
@ -785,7 +785,7 @@ int ecb_done(symmetric_ECB *ecb);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef LTC_CFB_MODE
|
#ifdef LTC_CFB_MODE
|
||||||
int cfb_start(int cipher, const unsigned char *IV, const unsigned char *key,
|
int cfb_start(int cipher, const unsigned char *IV, const unsigned char *key,
|
||||||
int keylen, int num_rounds, symmetric_CFB *cfb);
|
int keylen, int num_rounds, symmetric_CFB *cfb);
|
||||||
int cfb_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, symmetric_CFB *cfb);
|
int cfb_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, symmetric_CFB *cfb);
|
||||||
int cfb_decrypt(const unsigned char *ct, unsigned char *pt, unsigned long len, symmetric_CFB *cfb);
|
int cfb_decrypt(const unsigned char *ct, unsigned char *pt, unsigned long len, symmetric_CFB *cfb);
|
||||||
@ -795,7 +795,7 @@ int cfb_done(symmetric_CFB *cfb);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef LTC_OFB_MODE
|
#ifdef LTC_OFB_MODE
|
||||||
int ofb_start(int cipher, const unsigned char *IV, const unsigned char *key,
|
int ofb_start(int cipher, const unsigned char *IV, const unsigned char *key,
|
||||||
int keylen, int num_rounds, symmetric_OFB *ofb);
|
int keylen, int num_rounds, symmetric_OFB *ofb);
|
||||||
int ofb_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, symmetric_OFB *ofb);
|
int ofb_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, symmetric_OFB *ofb);
|
||||||
int ofb_decrypt(const unsigned char *ct, unsigned char *pt, unsigned long len, symmetric_OFB *ofb);
|
int ofb_decrypt(const unsigned char *ct, unsigned char *pt, unsigned long len, symmetric_OFB *ofb);
|
||||||
@ -842,7 +842,7 @@ int lrw_start( int cipher,
|
|||||||
const unsigned char *IV,
|
const unsigned char *IV,
|
||||||
const unsigned char *key, int keylen,
|
const unsigned char *key, int keylen,
|
||||||
const unsigned char *tweak,
|
const unsigned char *tweak,
|
||||||
int num_rounds,
|
int num_rounds,
|
||||||
symmetric_LRW *lrw);
|
symmetric_LRW *lrw);
|
||||||
int lrw_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, symmetric_LRW *lrw);
|
int lrw_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, symmetric_LRW *lrw);
|
||||||
int lrw_decrypt(const unsigned char *ct, unsigned char *pt, unsigned long len, symmetric_LRW *lrw);
|
int lrw_decrypt(const unsigned char *ct, unsigned char *pt, unsigned long len, symmetric_LRW *lrw);
|
||||||
@ -853,11 +853,11 @@ int lrw_test(void);
|
|||||||
|
|
||||||
/* don't call */
|
/* don't call */
|
||||||
int lrw_process(const unsigned char *pt, unsigned char *ct, unsigned long len, int mode, symmetric_LRW *lrw);
|
int lrw_process(const unsigned char *pt, unsigned char *ct, unsigned long len, int mode, symmetric_LRW *lrw);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef LTC_F8_MODE
|
#ifdef LTC_F8_MODE
|
||||||
int f8_start( int cipher, const unsigned char *IV,
|
int f8_start( int cipher, const unsigned char *IV,
|
||||||
const unsigned char *key, int keylen,
|
const unsigned char *key, int keylen,
|
||||||
const unsigned char *salt_key, int skeylen,
|
const unsigned char *salt_key, int skeylen,
|
||||||
int num_rounds, symmetric_F8 *f8);
|
int num_rounds, symmetric_F8 *f8);
|
||||||
int f8_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, symmetric_F8 *f8);
|
int f8_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, symmetric_F8 *f8);
|
||||||
@ -875,10 +875,10 @@ typedef struct {
|
|||||||
} symmetric_xts;
|
} symmetric_xts;
|
||||||
|
|
||||||
int xts_start( int cipher,
|
int xts_start( int cipher,
|
||||||
const unsigned char *key1,
|
const unsigned char *key1,
|
||||||
const unsigned char *key2,
|
const unsigned char *key2,
|
||||||
unsigned long keylen,
|
unsigned long keylen,
|
||||||
int num_rounds,
|
int num_rounds,
|
||||||
symmetric_xts *xts);
|
symmetric_xts *xts);
|
||||||
|
|
||||||
int xts_encrypt(
|
int xts_encrypt(
|
||||||
|
@ -3,19 +3,19 @@
|
|||||||
|
|
||||||
/* macros for various libc functions you can change for embedded targets */
|
/* macros for various libc functions you can change for embedded targets */
|
||||||
#ifndef XMALLOC
|
#ifndef XMALLOC
|
||||||
#ifdef malloc
|
#ifdef malloc
|
||||||
#define LTC_NO_PROTOTYPES
|
#define LTC_NO_PROTOTYPES
|
||||||
#endif
|
#endif
|
||||||
#define XMALLOC malloc
|
#define XMALLOC malloc
|
||||||
#endif
|
#endif
|
||||||
#ifndef XREALLOC
|
#ifndef XREALLOC
|
||||||
#ifdef realloc
|
#ifdef realloc
|
||||||
#define LTC_NO_PROTOTYPES
|
#define LTC_NO_PROTOTYPES
|
||||||
#endif
|
#endif
|
||||||
#define XREALLOC realloc
|
#define XREALLOC realloc
|
||||||
#endif
|
#endif
|
||||||
#ifndef XCALLOC
|
#ifndef XCALLOC
|
||||||
#ifdef calloc
|
#ifdef calloc
|
||||||
#define LTC_NO_PROTOTYPES
|
#define LTC_NO_PROTOTYPES
|
||||||
#endif
|
#endif
|
||||||
#define XCALLOC calloc
|
#define XCALLOC calloc
|
||||||
@ -40,7 +40,7 @@
|
|||||||
#define XMEMCPY memcpy
|
#define XMEMCPY memcpy
|
||||||
#endif
|
#endif
|
||||||
#ifndef XMEMCMP
|
#ifndef XMEMCMP
|
||||||
#ifdef memcmp
|
#ifdef memcmp
|
||||||
#define LTC_NO_PROTOTYPES
|
#define LTC_NO_PROTOTYPES
|
||||||
#endif
|
#endif
|
||||||
#define XMEMCMP memcmp
|
#define XMEMCMP memcmp
|
||||||
@ -73,19 +73,19 @@
|
|||||||
#define LTC_BLOWFISH
|
#define LTC_BLOWFISH
|
||||||
#define LTC_DES
|
#define LTC_DES
|
||||||
#define LTC_CAST5
|
#define LTC_CAST5
|
||||||
|
|
||||||
#define LTC_NO_MODES
|
#define LTC_NO_MODES
|
||||||
#define LTC_ECB_MODE
|
#define LTC_ECB_MODE
|
||||||
#define LTC_CBC_MODE
|
#define LTC_CBC_MODE
|
||||||
#define LTC_CTR_MODE
|
#define LTC_CTR_MODE
|
||||||
|
|
||||||
#define LTC_NO_HASHES
|
#define LTC_NO_HASHES
|
||||||
#define LTC_SHA1
|
#define LTC_SHA1
|
||||||
#define LTC_SHA512
|
#define LTC_SHA512
|
||||||
#define LTC_SHA384
|
#define LTC_SHA384
|
||||||
#define LTC_SHA256
|
#define LTC_SHA256
|
||||||
#define LTC_SHA224
|
#define LTC_SHA224
|
||||||
|
|
||||||
#define LTC_NO_MACS
|
#define LTC_NO_MACS
|
||||||
#define LTC_HMAC
|
#define LTC_HMAC
|
||||||
#define LTC_OMAC
|
#define LTC_OMAC
|
||||||
@ -96,11 +96,11 @@
|
|||||||
#define LTC_YARROW
|
#define LTC_YARROW
|
||||||
#define LTC_DEVRANDOM
|
#define LTC_DEVRANDOM
|
||||||
#define TRY_URANDOM_FIRST
|
#define TRY_URANDOM_FIRST
|
||||||
|
|
||||||
#define LTC_NO_PK
|
#define LTC_NO_PK
|
||||||
#define LTC_MRSA
|
#define LTC_MRSA
|
||||||
#define LTC_MECC
|
#define LTC_MECC
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Use small code where possible */
|
/* Use small code where possible */
|
||||||
/* #define LTC_SMALL_CODE */
|
/* #define LTC_SMALL_CODE */
|
||||||
@ -178,7 +178,7 @@
|
|||||||
#define LTC_LRW_MODE
|
#define LTC_LRW_MODE
|
||||||
#ifndef LTC_NO_TABLES
|
#ifndef LTC_NO_TABLES
|
||||||
/* like GCM mode this will enable 16 8x128 tables [64KB] that make
|
/* like GCM mode this will enable 16 8x128 tables [64KB] that make
|
||||||
* seeking very fast.
|
* seeking very fast.
|
||||||
*/
|
*/
|
||||||
#define LRW_TABLES
|
#define LRW_TABLES
|
||||||
#endif
|
#endif
|
||||||
@ -189,7 +189,7 @@
|
|||||||
#endif /* LTC_NO_MODES */
|
#endif /* LTC_NO_MODES */
|
||||||
|
|
||||||
/* ---> One-Way Hash Functions <--- */
|
/* ---> One-Way Hash Functions <--- */
|
||||||
#ifndef LTC_NO_HASHES
|
#ifndef LTC_NO_HASHES
|
||||||
|
|
||||||
#define LTC_CHC_HASH
|
#define LTC_CHC_HASH
|
||||||
#define LTC_WHIRLPOOL
|
#define LTC_WHIRLPOOL
|
||||||
@ -237,7 +237,7 @@
|
|||||||
|
|
||||||
/* Use 64KiB tables */
|
/* Use 64KiB tables */
|
||||||
#ifndef LTC_NO_TABLES
|
#ifndef LTC_NO_TABLES
|
||||||
#define LTC_GCM_TABLES
|
#define LTC_GCM_TABLES
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* USE SSE2? requires GCC works on x86_32 and x86_64*/
|
/* USE SSE2? requires GCC works on x86_32 and x86_64*/
|
||||||
@ -331,7 +331,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Include Katja (a Rabin variant like RSA) */
|
/* Include Katja (a Rabin variant like RSA) */
|
||||||
/* #define MKAT */
|
/* #define MKAT */
|
||||||
|
|
||||||
/* Digital Signature Algorithm */
|
/* Digital Signature Algorithm */
|
||||||
#define LTC_MDSA
|
#define LTC_MDSA
|
||||||
@ -344,7 +344,7 @@
|
|||||||
|
|
||||||
#if defined(TFM_LTC_DESC) && defined(LTC_MECC)
|
#if defined(TFM_LTC_DESC) && defined(LTC_MECC)
|
||||||
#define LTC_MECC_ACCEL
|
#define LTC_MECC_ACCEL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* do we want fixed point ECC */
|
/* do we want fixed point ECC */
|
||||||
/* #define LTC_MECC_FP */
|
/* #define LTC_MECC_FP */
|
||||||
@ -395,14 +395,14 @@
|
|||||||
|
|
||||||
#ifdef LTC_MRSA
|
#ifdef LTC_MRSA
|
||||||
#define LTC_PKCS_1
|
#define LTC_PKCS_1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(TFM_DESC) && defined(LTC_RSA_BLINDING)
|
#if defined(TFM_DESC) && defined(LTC_RSA_BLINDING)
|
||||||
#warning RSA blinding currently not supported in combination with TFM
|
#warning RSA blinding currently not supported in combination with TFM
|
||||||
#undef LTC_RSA_BLINDING
|
#undef LTC_RSA_BLINDING
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(LTC_DER) && !defined(MPI)
|
#if defined(LTC_DER) && !defined(MPI)
|
||||||
#error ASN.1 DER requires MPI functionality
|
#error ASN.1 DER requires MPI functionality
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -166,7 +166,7 @@ extern struct ltc_hash_descriptor {
|
|||||||
@return CRYPT_OK if successful
|
@return CRYPT_OK if successful
|
||||||
*/
|
*/
|
||||||
int (*init)(hash_state *hash);
|
int (*init)(hash_state *hash);
|
||||||
/** Process a block of data
|
/** Process a block of data
|
||||||
@param hash The hash state
|
@param hash The hash state
|
||||||
@param in The data to hash
|
@param in The data to hash
|
||||||
@param inlen The length of the data (octets)
|
@param inlen The length of the data (octets)
|
||||||
@ -186,7 +186,7 @@ extern struct ltc_hash_descriptor {
|
|||||||
|
|
||||||
/* accelerated hmac callback: if you need to-do multiple packets just use the generic hmac_memory and provide a hash callback */
|
/* accelerated hmac callback: if you need to-do multiple packets just use the generic hmac_memory and provide a hash callback */
|
||||||
int (*hmac_block)(const unsigned char *key, unsigned long keylen,
|
int (*hmac_block)(const unsigned char *key, unsigned long keylen,
|
||||||
const unsigned char *in, unsigned long inlen,
|
const unsigned char *in, unsigned long inlen,
|
||||||
unsigned char *out, unsigned long *outlen);
|
unsigned char *out, unsigned long *outlen);
|
||||||
|
|
||||||
} hash_descriptor[];
|
} hash_descriptor[];
|
||||||
@ -329,8 +329,8 @@ int hash_is_valid(int idx);
|
|||||||
|
|
||||||
LTC_MUTEX_PROTO(ltc_hash_mutex)
|
LTC_MUTEX_PROTO(ltc_hash_mutex)
|
||||||
|
|
||||||
int hash_memory(int hash,
|
int hash_memory(int hash,
|
||||||
const unsigned char *in, unsigned long inlen,
|
const unsigned char *in, unsigned long inlen,
|
||||||
unsigned char *out, unsigned long *outlen);
|
unsigned char *out, unsigned long *outlen);
|
||||||
int hash_memory_multi(int hash, unsigned char *out, unsigned long *outlen,
|
int hash_memory_multi(int hash, unsigned char *out, unsigned long *outlen,
|
||||||
const unsigned char *in, unsigned long inlen, ...);
|
const unsigned char *in, unsigned long inlen, ...);
|
||||||
|
@ -10,23 +10,23 @@ int hmac_init(hmac_state *hmac, int hash, const unsigned char *key, unsigned lon
|
|||||||
int hmac_process(hmac_state *hmac, const unsigned char *in, unsigned long inlen);
|
int hmac_process(hmac_state *hmac, const unsigned char *in, unsigned long inlen);
|
||||||
int hmac_done(hmac_state *hmac, unsigned char *out, unsigned long *outlen);
|
int hmac_done(hmac_state *hmac, unsigned char *out, unsigned long *outlen);
|
||||||
int hmac_test(void);
|
int hmac_test(void);
|
||||||
int hmac_memory(int hash,
|
int hmac_memory(int hash,
|
||||||
const unsigned char *key, unsigned long keylen,
|
const unsigned char *key, unsigned long keylen,
|
||||||
const unsigned char *in, unsigned long inlen,
|
const unsigned char *in, unsigned long inlen,
|
||||||
unsigned char *out, unsigned long *outlen);
|
unsigned char *out, unsigned long *outlen);
|
||||||
int hmac_memory_multi(int hash,
|
int hmac_memory_multi(int hash,
|
||||||
const unsigned char *key, unsigned long keylen,
|
const unsigned char *key, unsigned long keylen,
|
||||||
unsigned char *out, unsigned long *outlen,
|
unsigned char *out, unsigned long *outlen,
|
||||||
const unsigned char *in, unsigned long inlen, ...);
|
const unsigned char *in, unsigned long inlen, ...);
|
||||||
int hmac_file(int hash, const char *fname, const unsigned char *key,
|
int hmac_file(int hash, const char *fname, const unsigned char *key,
|
||||||
unsigned long keylen,
|
unsigned long keylen,
|
||||||
unsigned char *dst, unsigned long *dstlen);
|
unsigned char *dst, unsigned long *dstlen);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef LTC_OMAC
|
#ifdef LTC_OMAC
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int cipher_idx,
|
int cipher_idx,
|
||||||
buflen,
|
buflen,
|
||||||
blklen;
|
blklen;
|
||||||
unsigned char block[MAXBLOCKSIZE],
|
unsigned char block[MAXBLOCKSIZE],
|
||||||
@ -38,17 +38,17 @@ typedef struct {
|
|||||||
int omac_init(omac_state *omac, int cipher, const unsigned char *key, unsigned long keylen);
|
int omac_init(omac_state *omac, int cipher, const unsigned char *key, unsigned long keylen);
|
||||||
int omac_process(omac_state *omac, const unsigned char *in, unsigned long inlen);
|
int omac_process(omac_state *omac, const unsigned char *in, unsigned long inlen);
|
||||||
int omac_done(omac_state *omac, unsigned char *out, unsigned long *outlen);
|
int omac_done(omac_state *omac, unsigned char *out, unsigned long *outlen);
|
||||||
int omac_memory(int cipher,
|
int omac_memory(int cipher,
|
||||||
const unsigned char *key, unsigned long keylen,
|
const unsigned char *key, unsigned long keylen,
|
||||||
const unsigned char *in, unsigned long inlen,
|
const unsigned char *in, unsigned long inlen,
|
||||||
unsigned char *out, unsigned long *outlen);
|
unsigned char *out, unsigned long *outlen);
|
||||||
int omac_memory_multi(int cipher,
|
int omac_memory_multi(int cipher,
|
||||||
const unsigned char *key, unsigned long keylen,
|
const unsigned char *key, unsigned long keylen,
|
||||||
unsigned char *out, unsigned long *outlen,
|
unsigned char *out, unsigned long *outlen,
|
||||||
const unsigned char *in, unsigned long inlen, ...);
|
const unsigned char *in, unsigned long inlen, ...);
|
||||||
int omac_file(int cipher,
|
int omac_file(int cipher,
|
||||||
const unsigned char *key, unsigned long keylen,
|
const unsigned char *key, unsigned long keylen,
|
||||||
const char *filename,
|
const char *filename,
|
||||||
unsigned char *out, unsigned long *outlen);
|
unsigned char *out, unsigned long *outlen);
|
||||||
int omac_test(void);
|
int omac_test(void);
|
||||||
#endif /* LTC_OMAC */
|
#endif /* LTC_OMAC */
|
||||||
@ -73,19 +73,19 @@ int pmac_init(pmac_state *pmac, int cipher, const unsigned char *key, unsigned l
|
|||||||
int pmac_process(pmac_state *pmac, const unsigned char *in, unsigned long inlen);
|
int pmac_process(pmac_state *pmac, const unsigned char *in, unsigned long inlen);
|
||||||
int pmac_done(pmac_state *pmac, unsigned char *out, unsigned long *outlen);
|
int pmac_done(pmac_state *pmac, unsigned char *out, unsigned long *outlen);
|
||||||
|
|
||||||
int pmac_memory(int cipher,
|
int pmac_memory(int cipher,
|
||||||
const unsigned char *key, unsigned long keylen,
|
const unsigned char *key, unsigned long keylen,
|
||||||
const unsigned char *msg, unsigned long msglen,
|
const unsigned char *msg, unsigned long msglen,
|
||||||
unsigned char *out, unsigned long *outlen);
|
unsigned char *out, unsigned long *outlen);
|
||||||
|
|
||||||
int pmac_memory_multi(int cipher,
|
int pmac_memory_multi(int cipher,
|
||||||
const unsigned char *key, unsigned long keylen,
|
const unsigned char *key, unsigned long keylen,
|
||||||
unsigned char *out, unsigned long *outlen,
|
unsigned char *out, unsigned long *outlen,
|
||||||
const unsigned char *in, unsigned long inlen, ...);
|
const unsigned char *in, unsigned long inlen, ...);
|
||||||
|
|
||||||
int pmac_file(int cipher,
|
int pmac_file(int cipher,
|
||||||
const unsigned char *key, unsigned long keylen,
|
const unsigned char *key, unsigned long keylen,
|
||||||
const char *filename,
|
const char *filename,
|
||||||
unsigned char *out, unsigned long *outlen);
|
unsigned char *out, unsigned long *outlen);
|
||||||
|
|
||||||
int pmac_test(void);
|
int pmac_test(void);
|
||||||
@ -152,32 +152,32 @@ typedef struct {
|
|||||||
block_len; /* length of block */
|
block_len; /* length of block */
|
||||||
} ocb_state;
|
} ocb_state;
|
||||||
|
|
||||||
int ocb_init(ocb_state *ocb, int cipher,
|
int ocb_init(ocb_state *ocb, int cipher,
|
||||||
const unsigned char *key, unsigned long keylen, const unsigned char *nonce);
|
const unsigned char *key, unsigned long keylen, const unsigned char *nonce);
|
||||||
|
|
||||||
int ocb_encrypt(ocb_state *ocb, const unsigned char *pt, unsigned char *ct);
|
int ocb_encrypt(ocb_state *ocb, const unsigned char *pt, unsigned char *ct);
|
||||||
int ocb_decrypt(ocb_state *ocb, const unsigned char *ct, unsigned char *pt);
|
int ocb_decrypt(ocb_state *ocb, const unsigned char *ct, unsigned char *pt);
|
||||||
|
|
||||||
int ocb_done_encrypt(ocb_state *ocb,
|
int ocb_done_encrypt(ocb_state *ocb,
|
||||||
const unsigned char *pt, unsigned long ptlen,
|
const unsigned char *pt, unsigned long ptlen,
|
||||||
unsigned char *ct,
|
unsigned char *ct,
|
||||||
unsigned char *tag, unsigned long *taglen);
|
unsigned char *tag, unsigned long *taglen);
|
||||||
|
|
||||||
int ocb_done_decrypt(ocb_state *ocb,
|
int ocb_done_decrypt(ocb_state *ocb,
|
||||||
const unsigned char *ct, unsigned long ctlen,
|
const unsigned char *ct, unsigned long ctlen,
|
||||||
unsigned char *pt,
|
unsigned char *pt,
|
||||||
const unsigned char *tag, unsigned long taglen, int *stat);
|
const unsigned char *tag, unsigned long taglen, int *stat);
|
||||||
|
|
||||||
int ocb_encrypt_authenticate_memory(int cipher,
|
int ocb_encrypt_authenticate_memory(int cipher,
|
||||||
const unsigned char *key, unsigned long keylen,
|
const unsigned char *key, unsigned long keylen,
|
||||||
const unsigned char *nonce,
|
const unsigned char *nonce,
|
||||||
const unsigned char *pt, unsigned long ptlen,
|
const unsigned char *pt, unsigned long ptlen,
|
||||||
unsigned char *ct,
|
unsigned char *ct,
|
||||||
unsigned char *tag, unsigned long *taglen);
|
unsigned char *tag, unsigned long *taglen);
|
||||||
|
|
||||||
int ocb_decrypt_verify_memory(int cipher,
|
int ocb_decrypt_verify_memory(int cipher,
|
||||||
const unsigned char *key, unsigned long keylen,
|
const unsigned char *key, unsigned long keylen,
|
||||||
const unsigned char *nonce,
|
const unsigned char *nonce,
|
||||||
const unsigned char *ct, unsigned long ctlen,
|
const unsigned char *ct, unsigned long ctlen,
|
||||||
unsigned char *pt,
|
unsigned char *pt,
|
||||||
const unsigned char *tag, unsigned long taglen,
|
const unsigned char *tag, unsigned long taglen,
|
||||||
@ -305,7 +305,7 @@ extern const unsigned char gcm_shift_table[];
|
|||||||
#define LTC_GCM_MODE_AAD 1
|
#define LTC_GCM_MODE_AAD 1
|
||||||
#define LTC_GCM_MODE_TEXT 2
|
#define LTC_GCM_MODE_TEXT 2
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
symmetric_key K;
|
symmetric_key K;
|
||||||
unsigned char H[16], /* multiplier */
|
unsigned char H[16], /* multiplier */
|
||||||
X[16], /* accumulator */
|
X[16], /* accumulator */
|
||||||
@ -327,7 +327,7 @@ typedef struct {
|
|||||||
__attribute__ ((aligned (16)))
|
__attribute__ ((aligned (16)))
|
||||||
#endif
|
#endif
|
||||||
;
|
;
|
||||||
#endif
|
#endif
|
||||||
} gcm_state;
|
} gcm_state;
|
||||||
|
|
||||||
void gcm_mult_h(gcm_state *gcm, unsigned char *I);
|
void gcm_mult_h(gcm_state *gcm, unsigned char *I);
|
||||||
@ -337,7 +337,7 @@ int gcm_init(gcm_state *gcm, int cipher,
|
|||||||
|
|
||||||
int gcm_reset(gcm_state *gcm);
|
int gcm_reset(gcm_state *gcm);
|
||||||
|
|
||||||
int gcm_add_iv(gcm_state *gcm,
|
int gcm_add_iv(gcm_state *gcm,
|
||||||
const unsigned char *IV, unsigned long IVlen);
|
const unsigned char *IV, unsigned long IVlen);
|
||||||
|
|
||||||
int gcm_add_aad(gcm_state *gcm,
|
int gcm_add_aad(gcm_state *gcm,
|
||||||
@ -348,7 +348,7 @@ int gcm_process(gcm_state *gcm,
|
|||||||
unsigned char *ct,
|
unsigned char *ct,
|
||||||
int direction);
|
int direction);
|
||||||
|
|
||||||
int gcm_done(gcm_state *gcm,
|
int gcm_done(gcm_state *gcm,
|
||||||
unsigned char *tag, unsigned long *taglen);
|
unsigned char *tag, unsigned long *taglen);
|
||||||
|
|
||||||
int gcm_memory( int cipher,
|
int gcm_memory( int cipher,
|
||||||
@ -356,7 +356,7 @@ int gcm_memory( int cipher,
|
|||||||
const unsigned char *IV, unsigned long IVlen,
|
const unsigned char *IV, unsigned long IVlen,
|
||||||
const unsigned char *adata, unsigned long adatalen,
|
const unsigned char *adata, unsigned long adatalen,
|
||||||
unsigned char *pt, unsigned long ptlen,
|
unsigned char *pt, unsigned long ptlen,
|
||||||
unsigned char *ct,
|
unsigned char *ct,
|
||||||
unsigned char *tag, unsigned long *taglen,
|
unsigned char *tag, unsigned long *taglen,
|
||||||
int direction);
|
int direction);
|
||||||
int gcm_test(void);
|
int gcm_test(void);
|
||||||
@ -402,17 +402,17 @@ typedef struct {
|
|||||||
int xcbc_init(xcbc_state *xcbc, int cipher, const unsigned char *key, unsigned long keylen);
|
int xcbc_init(xcbc_state *xcbc, int cipher, const unsigned char *key, unsigned long keylen);
|
||||||
int xcbc_process(xcbc_state *xcbc, const unsigned char *in, unsigned long inlen);
|
int xcbc_process(xcbc_state *xcbc, const unsigned char *in, unsigned long inlen);
|
||||||
int xcbc_done(xcbc_state *xcbc, unsigned char *out, unsigned long *outlen);
|
int xcbc_done(xcbc_state *xcbc, unsigned char *out, unsigned long *outlen);
|
||||||
int xcbc_memory(int cipher,
|
int xcbc_memory(int cipher,
|
||||||
const unsigned char *key, unsigned long keylen,
|
const unsigned char *key, unsigned long keylen,
|
||||||
const unsigned char *in, unsigned long inlen,
|
const unsigned char *in, unsigned long inlen,
|
||||||
unsigned char *out, unsigned long *outlen);
|
unsigned char *out, unsigned long *outlen);
|
||||||
int xcbc_memory_multi(int cipher,
|
int xcbc_memory_multi(int cipher,
|
||||||
const unsigned char *key, unsigned long keylen,
|
const unsigned char *key, unsigned long keylen,
|
||||||
unsigned char *out, unsigned long *outlen,
|
unsigned char *out, unsigned long *outlen,
|
||||||
const unsigned char *in, unsigned long inlen, ...);
|
const unsigned char *in, unsigned long inlen, ...);
|
||||||
int xcbc_file(int cipher,
|
int xcbc_file(int cipher,
|
||||||
const unsigned char *key, unsigned long keylen,
|
const unsigned char *key, unsigned long keylen,
|
||||||
const char *filename,
|
const char *filename,
|
||||||
unsigned char *out, unsigned long *outlen);
|
unsigned char *out, unsigned long *outlen);
|
||||||
int xcbc_test(void);
|
int xcbc_test(void);
|
||||||
|
|
||||||
@ -436,17 +436,17 @@ typedef struct {
|
|||||||
int f9_init(f9_state *f9, int cipher, const unsigned char *key, unsigned long keylen);
|
int f9_init(f9_state *f9, int cipher, const unsigned char *key, unsigned long keylen);
|
||||||
int f9_process(f9_state *f9, const unsigned char *in, unsigned long inlen);
|
int f9_process(f9_state *f9, const unsigned char *in, unsigned long inlen);
|
||||||
int f9_done(f9_state *f9, unsigned char *out, unsigned long *outlen);
|
int f9_done(f9_state *f9, unsigned char *out, unsigned long *outlen);
|
||||||
int f9_memory(int cipher,
|
int f9_memory(int cipher,
|
||||||
const unsigned char *key, unsigned long keylen,
|
const unsigned char *key, unsigned long keylen,
|
||||||
const unsigned char *in, unsigned long inlen,
|
const unsigned char *in, unsigned long inlen,
|
||||||
unsigned char *out, unsigned long *outlen);
|
unsigned char *out, unsigned long *outlen);
|
||||||
int f9_memory_multi(int cipher,
|
int f9_memory_multi(int cipher,
|
||||||
const unsigned char *key, unsigned long keylen,
|
const unsigned char *key, unsigned long keylen,
|
||||||
unsigned char *out, unsigned long *outlen,
|
unsigned char *out, unsigned long *outlen,
|
||||||
const unsigned char *in, unsigned long inlen, ...);
|
const unsigned char *in, unsigned long inlen, ...);
|
||||||
int f9_file(int cipher,
|
int f9_file(int cipher,
|
||||||
const unsigned char *key, unsigned long keylen,
|
const unsigned char *key, unsigned long keylen,
|
||||||
const char *filename,
|
const char *filename,
|
||||||
unsigned char *out, unsigned long *outlen);
|
unsigned char *out, unsigned long *outlen);
|
||||||
int f9_test(void);
|
int f9_test(void);
|
||||||
|
|
||||||
|
@ -7,8 +7,8 @@
|
|||||||
typedef unsigned long long ulong64;
|
typedef unsigned long long ulong64;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* this is the "32-bit at least" data type
|
/* this is the "32-bit at least" data type
|
||||||
* Re-define it to suit your platform but it must be at least 32-bits
|
* Re-define it to suit your platform but it must be at least 32-bits
|
||||||
*/
|
*/
|
||||||
#if defined(__x86_64__) || (defined(__sparc__) && defined(__arch64__))
|
#if defined(__x86_64__) || (defined(__sparc__) && defined(__arch64__))
|
||||||
typedef unsigned ulong32;
|
typedef unsigned ulong32;
|
||||||
@ -148,7 +148,7 @@ asm __volatile__ ( \
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ENDIAN_32BITWORD
|
#ifdef ENDIAN_32BITWORD
|
||||||
|
|
||||||
#define STORE32L(x, y) \
|
#define STORE32L(x, y) \
|
||||||
{ ulong32 __t = (x); XMEMCPY(y, &__t, 4); }
|
{ ulong32 __t = (x); XMEMCPY(y, &__t, 4); }
|
||||||
@ -209,7 +209,7 @@ asm __volatile__ ( \
|
|||||||
(((ulong64)((y)[3] & 255))<<24)|(((ulong64)((y)[2] & 255))<<16) | \
|
(((ulong64)((y)[3] & 255))<<24)|(((ulong64)((y)[2] & 255))<<16) | \
|
||||||
(((ulong64)((y)[1] & 255))<<8)|(((ulong64)((y)[0] & 255))); }
|
(((ulong64)((y)[1] & 255))<<8)|(((ulong64)((y)[0] & 255))); }
|
||||||
|
|
||||||
#ifdef ENDIAN_32BITWORD
|
#ifdef ENDIAN_32BITWORD
|
||||||
|
|
||||||
#define STORE32H(x, y) \
|
#define STORE32H(x, y) \
|
||||||
{ ulong32 __t = (x); XMEMCPY(y, &__t, 4); }
|
{ ulong32 __t = (x); XMEMCPY(y, &__t, 4); }
|
||||||
@ -436,7 +436,7 @@ static inline unsigned long ROR64c(unsigned long word, const int i)
|
|||||||
#define byte(x, n) ((unsigned char)((x) >> (8 * (n))))
|
#define byte(x, n) ((unsigned char)((x) >> (8 * (n))))
|
||||||
#else
|
#else
|
||||||
#define byte(x, n) (((x) >> (8 * (n))) & 255)
|
#define byte(x, n) (((x) >> (8 * (n))) & 255)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* $Source$ */
|
/* $Source$ */
|
||||||
/* $Revision$ */
|
/* $Revision$ */
|
||||||
|
@ -30,15 +30,15 @@ typedef struct {
|
|||||||
@return CRYPT_OK on success
|
@return CRYPT_OK on success
|
||||||
*/
|
*/
|
||||||
int (*init)(void **a);
|
int (*init)(void **a);
|
||||||
|
|
||||||
/** init copy
|
/** init copy
|
||||||
@param dst The number to initialize and write to
|
@param dst The number to initialize and write to
|
||||||
@param src The number to copy from
|
@param src The number to copy from
|
||||||
@return CRYPT_OK on success
|
@return CRYPT_OK on success
|
||||||
*/
|
*/
|
||||||
int (*init_copy)(void **dst, void *src);
|
int (*init_copy)(void **dst, void *src);
|
||||||
|
|
||||||
/** deinit
|
/** deinit
|
||||||
@param a The number to free
|
@param a The number to free
|
||||||
@return CRYPT_OK on success
|
@return CRYPT_OK on success
|
||||||
*/
|
*/
|
||||||
@ -52,30 +52,30 @@ typedef struct {
|
|||||||
@return CRYPT_OK on success
|
@return CRYPT_OK on success
|
||||||
*/
|
*/
|
||||||
int (*neg)(void *src, void *dst);
|
int (*neg)(void *src, void *dst);
|
||||||
|
|
||||||
/** copy
|
/** copy
|
||||||
@param src The number to copy from
|
@param src The number to copy from
|
||||||
@param dst The number to write to
|
@param dst The number to write to
|
||||||
@return CRYPT_OK on success
|
@return CRYPT_OK on success
|
||||||
*/
|
*/
|
||||||
int (*copy)(void *src, void *dst);
|
int (*copy)(void *src, void *dst);
|
||||||
|
|
||||||
/* ---- trivial low level functions ---- */
|
/* ---- trivial low level functions ---- */
|
||||||
|
|
||||||
/** set small constant
|
/** set small constant
|
||||||
@param a Number to write to
|
@param a Number to write to
|
||||||
@param n Source upto bits_per_digit (actually meant for very small constants)
|
@param n Source upto bits_per_digit (actually meant for very small constants)
|
||||||
@return CRYPT_OK on succcess
|
@return CRYPT_OK on succcess
|
||||||
*/
|
*/
|
||||||
int (*set_int)(void *a, unsigned long n);
|
int (*set_int)(void *a, unsigned long n);
|
||||||
|
|
||||||
/** get small constant
|
/** get small constant
|
||||||
@param a Number to read, only fetches upto bits_per_digit from the number
|
@param a Number to read, only fetches upto bits_per_digit from the number
|
||||||
@return The lower bits_per_digit of the integer (unsigned)
|
@return The lower bits_per_digit of the integer (unsigned)
|
||||||
*/
|
*/
|
||||||
unsigned long (*get_int)(void *a);
|
unsigned long (*get_int)(void *a);
|
||||||
|
|
||||||
/** get digit n
|
/** get digit n
|
||||||
@param a The number to read from
|
@param a The number to read from
|
||||||
@param n The number of the digit to fetch
|
@param n The number of the digit to fetch
|
||||||
@return The bits_per_digit sized n'th digit of a
|
@return The bits_per_digit sized n'th digit of a
|
||||||
@ -95,7 +95,7 @@ typedef struct {
|
|||||||
*/
|
*/
|
||||||
int (*compare)(void *a, void *b);
|
int (*compare)(void *a, void *b);
|
||||||
|
|
||||||
/** compare against int
|
/** compare against int
|
||||||
@param a The left side integer
|
@param a The left side integer
|
||||||
@param b The right side integer (upto bits_per_digit)
|
@param b The right side integer (upto bits_per_digit)
|
||||||
@return LTC_MP_LT if a < b, LTC_MP_GT if a > b and LTC_MP_EQ otherwise. (signed comparison)
|
@return LTC_MP_LT if a < b, LTC_MP_GT if a > b and LTC_MP_EQ otherwise. (signed comparison)
|
||||||
@ -108,7 +108,7 @@ typedef struct {
|
|||||||
*/
|
*/
|
||||||
int (*count_bits)(void * a);
|
int (*count_bits)(void * a);
|
||||||
|
|
||||||
/** Count the number of LSB bits which are zero
|
/** Count the number of LSB bits which are zero
|
||||||
@param a The integer to count
|
@param a The integer to count
|
||||||
@return The number of contiguous zero LSB bits
|
@return The number of contiguous zero LSB bits
|
||||||
*/
|
*/
|
||||||
@ -122,8 +122,8 @@ typedef struct {
|
|||||||
int (*twoexpt)(void *a , int n);
|
int (*twoexpt)(void *a , int n);
|
||||||
|
|
||||||
/* ---- radix conversions ---- */
|
/* ---- radix conversions ---- */
|
||||||
|
|
||||||
/** read ascii string
|
/** read ascii string
|
||||||
@param a The integer to store into
|
@param a The integer to store into
|
||||||
@param str The string to read
|
@param str The string to read
|
||||||
@param radix The radix the integer has been represented in (2-64)
|
@param radix The radix the integer has been represented in (2-64)
|
||||||
@ -139,13 +139,13 @@ typedef struct {
|
|||||||
*/
|
*/
|
||||||
int (*write_radix)(void *a, char *str, int radix);
|
int (*write_radix)(void *a, char *str, int radix);
|
||||||
|
|
||||||
/** get size as unsigned char string
|
/** get size as unsigned char string
|
||||||
@param a The integer to get the size (when stored in array of octets)
|
@param a The integer to get the size (when stored in array of octets)
|
||||||
@return The length of the integer
|
@return The length of the integer
|
||||||
*/
|
*/
|
||||||
unsigned long (*unsigned_size)(void *a);
|
unsigned long (*unsigned_size)(void *a);
|
||||||
|
|
||||||
/** store an integer as an array of octets
|
/** store an integer as an array of octets
|
||||||
@param src The integer to store
|
@param src The integer to store
|
||||||
@param dst The buffer to store the integer in
|
@param dst The buffer to store the integer in
|
||||||
@return CRYPT_OK on success
|
@return CRYPT_OK on success
|
||||||
@ -154,15 +154,15 @@ typedef struct {
|
|||||||
|
|
||||||
/** read an array of octets and store as integer
|
/** read an array of octets and store as integer
|
||||||
@param dst The integer to load
|
@param dst The integer to load
|
||||||
@param src The array of octets
|
@param src The array of octets
|
||||||
@param len The number of octets
|
@param len The number of octets
|
||||||
@return CRYPT_OK on success
|
@return CRYPT_OK on success
|
||||||
*/
|
*/
|
||||||
int (*unsigned_read)(void *dst, unsigned char *src, unsigned long len);
|
int (*unsigned_read)(void *dst, unsigned char *src, unsigned long len);
|
||||||
|
|
||||||
/* ---- basic math ---- */
|
/* ---- basic math ---- */
|
||||||
|
|
||||||
/** add two integers
|
/** add two integers
|
||||||
@param a The first source integer
|
@param a The first source integer
|
||||||
@param b The second source integer
|
@param b The second source integer
|
||||||
@param c The destination of "a + b"
|
@param c The destination of "a + b"
|
||||||
@ -171,7 +171,7 @@ typedef struct {
|
|||||||
int (*add)(void *a, void *b, void *c);
|
int (*add)(void *a, void *b, void *c);
|
||||||
|
|
||||||
|
|
||||||
/** add two integers
|
/** add two integers
|
||||||
@param a The first source integer
|
@param a The first source integer
|
||||||
@param b The second source integer (single digit of upto bits_per_digit in length)
|
@param b The second source integer (single digit of upto bits_per_digit in length)
|
||||||
@param c The destination of "a + b"
|
@param c The destination of "a + b"
|
||||||
@ -179,7 +179,7 @@ typedef struct {
|
|||||||
*/
|
*/
|
||||||
int (*addi)(void *a, unsigned long b, void *c);
|
int (*addi)(void *a, unsigned long b, void *c);
|
||||||
|
|
||||||
/** subtract two integers
|
/** subtract two integers
|
||||||
@param a The first source integer
|
@param a The first source integer
|
||||||
@param b The second source integer
|
@param b The second source integer
|
||||||
@param c The destination of "a - b"
|
@param c The destination of "a - b"
|
||||||
@ -187,7 +187,7 @@ typedef struct {
|
|||||||
*/
|
*/
|
||||||
int (*sub)(void *a, void *b, void *c);
|
int (*sub)(void *a, void *b, void *c);
|
||||||
|
|
||||||
/** subtract two integers
|
/** subtract two integers
|
||||||
@param a The first source integer
|
@param a The first source integer
|
||||||
@param b The second source integer (single digit of upto bits_per_digit in length)
|
@param b The second source integer (single digit of upto bits_per_digit in length)
|
||||||
@param c The destination of "a - b"
|
@param c The destination of "a - b"
|
||||||
@ -195,7 +195,7 @@ typedef struct {
|
|||||||
*/
|
*/
|
||||||
int (*subi)(void *a, unsigned long b, void *c);
|
int (*subi)(void *a, unsigned long b, void *c);
|
||||||
|
|
||||||
/** multiply two integers
|
/** multiply two integers
|
||||||
@param a The first source integer
|
@param a The first source integer
|
||||||
@param b The second source integer (single digit of upto bits_per_digit in length)
|
@param b The second source integer (single digit of upto bits_per_digit in length)
|
||||||
@param c The destination of "a * b"
|
@param c The destination of "a * b"
|
||||||
@ -203,7 +203,7 @@ typedef struct {
|
|||||||
*/
|
*/
|
||||||
int (*mul)(void *a, void *b, void *c);
|
int (*mul)(void *a, void *b, void *c);
|
||||||
|
|
||||||
/** multiply two integers
|
/** multiply two integers
|
||||||
@param a The first source integer
|
@param a The first source integer
|
||||||
@param b The second source integer (single digit of upto bits_per_digit in length)
|
@param b The second source integer (single digit of upto bits_per_digit in length)
|
||||||
@param c The destination of "a * b"
|
@param c The destination of "a * b"
|
||||||
@ -227,9 +227,9 @@ typedef struct {
|
|||||||
*/
|
*/
|
||||||
int (*mpdiv)(void *a, void *b, void *c, void *d);
|
int (*mpdiv)(void *a, void *b, void *c, void *d);
|
||||||
|
|
||||||
/** divide by two
|
/** divide by two
|
||||||
@param a The integer to divide (shift right)
|
@param a The integer to divide (shift right)
|
||||||
@param b The destination
|
@param b The destination
|
||||||
@return CRYPT_OK on success
|
@return CRYPT_OK on success
|
||||||
*/
|
*/
|
||||||
int (*div_2)(void *a, void *b);
|
int (*div_2)(void *a, void *b);
|
||||||
@ -242,7 +242,7 @@ typedef struct {
|
|||||||
*/
|
*/
|
||||||
int (*modi)(void *a, unsigned long b, unsigned long *c);
|
int (*modi)(void *a, unsigned long b, unsigned long *c);
|
||||||
|
|
||||||
/** gcd
|
/** gcd
|
||||||
@param a The first integer
|
@param a The first integer
|
||||||
@param b The second integer
|
@param b The second integer
|
||||||
@param c The destination for (a, b)
|
@param c The destination for (a, b)
|
||||||
@ -250,7 +250,7 @@ typedef struct {
|
|||||||
*/
|
*/
|
||||||
int (*gcd)(void *a, void *b, void *c);
|
int (*gcd)(void *a, void *b, void *c);
|
||||||
|
|
||||||
/** lcm
|
/** lcm
|
||||||
@param a The first integer
|
@param a The first integer
|
||||||
@param b The second integer
|
@param b The second integer
|
||||||
@param c The destination for [a, b]
|
@param c The destination for [a, b]
|
||||||
@ -260,7 +260,7 @@ typedef struct {
|
|||||||
|
|
||||||
/** Modular multiplication
|
/** Modular multiplication
|
||||||
@param a The first source
|
@param a The first source
|
||||||
@param b The second source
|
@param b The second source
|
||||||
@param c The modulus
|
@param c The modulus
|
||||||
@param d The destination (a*b mod c)
|
@param d The destination (a*b mod c)
|
||||||
@return CRYPT_OK on success
|
@return CRYPT_OK on success
|
||||||
@ -277,7 +277,7 @@ typedef struct {
|
|||||||
|
|
||||||
/** Modular inversion
|
/** Modular inversion
|
||||||
@param a The value to invert
|
@param a The value to invert
|
||||||
@param b The modulus
|
@param b The modulus
|
||||||
@param c The destination (1/a mod b)
|
@param c The destination (1/a mod b)
|
||||||
@return CRYPT_OK on success
|
@return CRYPT_OK on success
|
||||||
*/
|
*/
|
||||||
@ -286,13 +286,13 @@ typedef struct {
|
|||||||
/* ---- reduction ---- */
|
/* ---- reduction ---- */
|
||||||
|
|
||||||
/** setup montgomery
|
/** setup montgomery
|
||||||
@param a The modulus
|
@param a The modulus
|
||||||
@param b The destination for the reduction digit
|
@param b The destination for the reduction digit
|
||||||
@return CRYPT_OK on success
|
@return CRYPT_OK on success
|
||||||
*/
|
*/
|
||||||
int (*montgomery_setup)(void *a, void **b);
|
int (*montgomery_setup)(void *a, void **b);
|
||||||
|
|
||||||
/** get normalization value
|
/** get normalization value
|
||||||
@param a The destination for the normalization value
|
@param a The destination for the normalization value
|
||||||
@param b The modulus
|
@param b The modulus
|
||||||
@return CRYPT_OK on success
|
@return CRYPT_OK on success
|
||||||
@ -310,7 +310,7 @@ typedef struct {
|
|||||||
/** clean up (frees memory)
|
/** clean up (frees memory)
|
||||||
@param a The value "b" from montgomery_setup()
|
@param a The value "b" from montgomery_setup()
|
||||||
@return CRYPT_OK on success
|
@return CRYPT_OK on success
|
||||||
*/
|
*/
|
||||||
void (*montgomery_deinit)(void *a);
|
void (*montgomery_deinit)(void *a);
|
||||||
|
|
||||||
/* ---- exponentiation ---- */
|
/* ---- exponentiation ---- */
|
||||||
@ -336,14 +336,14 @@ typedef struct {
|
|||||||
/** ECC GF(p) point multiplication (from the NIST curves)
|
/** ECC GF(p) point multiplication (from the NIST curves)
|
||||||
@param k The integer to multiply the point by
|
@param k The integer to multiply the point by
|
||||||
@param G The point to multiply
|
@param G The point to multiply
|
||||||
@param R The destination for kG
|
@param R The destination for kG
|
||||||
@param modulus The modulus for the field
|
@param modulus The modulus for the field
|
||||||
@param map Boolean indicated whether to map back to affine or not (can be ignored if you work in affine only)
|
@param map Boolean indicated whether to map back to affine or not (can be ignored if you work in affine only)
|
||||||
@return CRYPT_OK on success
|
@return CRYPT_OK on success
|
||||||
*/
|
*/
|
||||||
int (*ecc_ptmul)(void *k, ecc_point *G, ecc_point *R, void *modulus, int map);
|
int (*ecc_ptmul)(void *k, ecc_point *G, ecc_point *R, void *modulus, int map);
|
||||||
|
|
||||||
/** ECC GF(p) point addition
|
/** ECC GF(p) point addition
|
||||||
@param P The first point
|
@param P The first point
|
||||||
@param Q The second point
|
@param Q The second point
|
||||||
@param R The destination of P + Q
|
@param R The destination of P + Q
|
||||||
@ -353,7 +353,7 @@ typedef struct {
|
|||||||
*/
|
*/
|
||||||
int (*ecc_ptadd)(ecc_point *P, ecc_point *Q, ecc_point *R, void *modulus, void *mp);
|
int (*ecc_ptadd)(ecc_point *P, ecc_point *Q, ecc_point *R, void *modulus, void *mp);
|
||||||
|
|
||||||
/** ECC GF(p) point double
|
/** ECC GF(p) point double
|
||||||
@param P The first point
|
@param P The first point
|
||||||
@param R The destination of 2P
|
@param R The destination of 2P
|
||||||
@param modulus The modulus
|
@param modulus The modulus
|
||||||
@ -367,7 +367,7 @@ typedef struct {
|
|||||||
@param modulus The modulus
|
@param modulus The modulus
|
||||||
@param mp The "b" value from montgomery_setup()
|
@param mp The "b" value from montgomery_setup()
|
||||||
@return CRYPT_OK on success
|
@return CRYPT_OK on success
|
||||||
@remark The mapping can be different but keep in mind a ecc_point only has three
|
@remark The mapping can be different but keep in mind a ecc_point only has three
|
||||||
integers (x,y,z) so if you use a different mapping you have to make it fit.
|
integers (x,y,z) so if you use a different mapping you have to make it fit.
|
||||||
*/
|
*/
|
||||||
int (*ecc_map)(ecc_point *P, void *modulus, void *mp);
|
int (*ecc_map)(ecc_point *P, void *modulus, void *mp);
|
||||||
@ -378,9 +378,9 @@ typedef struct {
|
|||||||
@param B Second point to multiply
|
@param B Second point to multiply
|
||||||
@param kB What to multiple B by
|
@param kB What to multiple B by
|
||||||
@param C [out] Destination point (can overlap with A or B
|
@param C [out] Destination point (can overlap with A or B
|
||||||
@param modulus Modulus for curve
|
@param modulus Modulus for curve
|
||||||
@return CRYPT_OK on success
|
@return CRYPT_OK on success
|
||||||
*/
|
*/
|
||||||
int (*ecc_mul2add)(ecc_point *A, void *kA,
|
int (*ecc_mul2add)(ecc_point *A, void *kA,
|
||||||
ecc_point *B, void *kB,
|
ecc_point *B, void *kB,
|
||||||
ecc_point *C,
|
ecc_point *C,
|
||||||
@ -388,7 +388,7 @@ typedef struct {
|
|||||||
|
|
||||||
/* ---- (optional) rsa optimized math (for internal CRT) ---- */
|
/* ---- (optional) rsa optimized math (for internal CRT) ---- */
|
||||||
|
|
||||||
/** RSA Key Generation
|
/** RSA Key Generation
|
||||||
@param prng An active PRNG state
|
@param prng An active PRNG state
|
||||||
@param wprng The index of the PRNG desired
|
@param wprng The index of the PRNG desired
|
||||||
@param size The size of the modulus (key size) desired (octets)
|
@param size The size of the modulus (key size) desired (octets)
|
||||||
@ -397,7 +397,7 @@ typedef struct {
|
|||||||
@return CRYPT_OK if successful, upon error all allocated ram is freed
|
@return CRYPT_OK if successful, upon error all allocated ram is freed
|
||||||
*/
|
*/
|
||||||
int (*rsa_keygen)(prng_state *prng, int wprng, int size, long e, rsa_key *key);
|
int (*rsa_keygen)(prng_state *prng, int wprng, int size, long e, rsa_key *key);
|
||||||
|
|
||||||
|
|
||||||
/** RSA exponentiation
|
/** RSA exponentiation
|
||||||
@param in The octet array representing the base
|
@param in The octet array representing the base
|
||||||
@ -405,7 +405,7 @@ typedef struct {
|
|||||||
@param out The destination (to be stored in an octet array format)
|
@param out The destination (to be stored in an octet array format)
|
||||||
@param outlen The length of the output buffer and the resulting size (zero padded to the size of the modulus)
|
@param outlen The length of the output buffer and the resulting size (zero padded to the size of the modulus)
|
||||||
@param which PK_PUBLIC for public RSA and PK_PRIVATE for private RSA
|
@param which PK_PUBLIC for public RSA and PK_PRIVATE for private RSA
|
||||||
@param key The RSA key to use
|
@param key The RSA key to use
|
||||||
@return CRYPT_OK on success
|
@return CRYPT_OK on success
|
||||||
*/
|
*/
|
||||||
int (*rsa_me)(const unsigned char *in, unsigned long inlen,
|
int (*rsa_me)(const unsigned char *in, unsigned long inlen,
|
||||||
@ -416,7 +416,7 @@ typedef struct {
|
|||||||
|
|
||||||
/** Modular addition
|
/** Modular addition
|
||||||
@param a The first source
|
@param a The first source
|
||||||
@param b The second source
|
@param b The second source
|
||||||
@param c The modulus
|
@param c The modulus
|
||||||
@param d The destination (a + b mod c)
|
@param d The destination (a + b mod c)
|
||||||
@return CRYPT_OK on success
|
@return CRYPT_OK on success
|
||||||
@ -425,7 +425,7 @@ typedef struct {
|
|||||||
|
|
||||||
/** Modular substraction
|
/** Modular substraction
|
||||||
@param a The first source
|
@param a The first source
|
||||||
@param b The second source
|
@param b The second source
|
||||||
@param c The modulus
|
@param c The modulus
|
||||||
@param d The destination (a - b mod c)
|
@param d The destination (a - b mod c)
|
||||||
@return CRYPT_OK on success
|
@return CRYPT_OK on success
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
/* ---- LTC_BASE64 Routines ---- */
|
/* ---- LTC_BASE64 Routines ---- */
|
||||||
#ifdef LTC_BASE64
|
#ifdef LTC_BASE64
|
||||||
int base64_encode(const unsigned char *in, unsigned long len,
|
int base64_encode(const unsigned char *in, unsigned long len,
|
||||||
unsigned char *out, unsigned long *outlen);
|
unsigned char *out, unsigned long *outlen);
|
||||||
|
|
||||||
int base64_decode(const unsigned char *in, unsigned long len,
|
int base64_decode(const unsigned char *in, unsigned long len,
|
||||||
unsigned char *out, unsigned long *outlen);
|
unsigned char *out, unsigned long *outlen);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -32,19 +32,19 @@ typedef struct Rsa_key {
|
|||||||
/** Type of key, PK_PRIVATE or PK_PUBLIC */
|
/** Type of key, PK_PRIVATE or PK_PUBLIC */
|
||||||
int type;
|
int type;
|
||||||
/** The public exponent */
|
/** The public exponent */
|
||||||
void *e;
|
void *e;
|
||||||
/** The private exponent */
|
/** The private exponent */
|
||||||
void *d;
|
void *d;
|
||||||
/** The modulus */
|
/** The modulus */
|
||||||
void *N;
|
void *N;
|
||||||
/** The p factor of N */
|
/** The p factor of N */
|
||||||
void *p;
|
void *p;
|
||||||
/** The q factor of N */
|
/** The q factor of N */
|
||||||
void *q;
|
void *q;
|
||||||
/** The 1/q mod p CRT param */
|
/** The 1/q mod p CRT param */
|
||||||
void *qP;
|
void *qP;
|
||||||
/** The d mod (p - 1) CRT param */
|
/** The d mod (p - 1) CRT param */
|
||||||
void *dP;
|
void *dP;
|
||||||
/** The d mod (q - 1) CRT param */
|
/** The d mod (q - 1) CRT param */
|
||||||
void *dQ;
|
void *dQ;
|
||||||
} rsa_key;
|
} rsa_key;
|
||||||
@ -98,7 +98,7 @@ int rsa_verify_hash_ex(const unsigned char *sig, unsigned long siglen,
|
|||||||
/* LTC_PKCS #1 import/export */
|
/* LTC_PKCS #1 import/export */
|
||||||
int rsa_export(unsigned char *out, unsigned long *outlen, int type, rsa_key *key);
|
int rsa_export(unsigned char *out, unsigned long *outlen, int type, rsa_key *key);
|
||||||
int rsa_import(const unsigned char *in, unsigned long inlen, rsa_key *key);
|
int rsa_import(const unsigned char *in, unsigned long inlen, rsa_key *key);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* ---- Katja ---- */
|
/* ---- Katja ---- */
|
||||||
@ -113,17 +113,17 @@ typedef struct KAT_key {
|
|||||||
/** Type of key, PK_PRIVATE or PK_PUBLIC */
|
/** Type of key, PK_PRIVATE or PK_PUBLIC */
|
||||||
int type;
|
int type;
|
||||||
/** The private exponent */
|
/** The private exponent */
|
||||||
void *d;
|
void *d;
|
||||||
/** The modulus */
|
/** The modulus */
|
||||||
void *N;
|
void *N;
|
||||||
/** The p factor of N */
|
/** The p factor of N */
|
||||||
void *p;
|
void *p;
|
||||||
/** The q factor of N */
|
/** The q factor of N */
|
||||||
void *q;
|
void *q;
|
||||||
/** The 1/q mod p CRT param */
|
/** The 1/q mod p CRT param */
|
||||||
void *qP;
|
void *qP;
|
||||||
/** The d mod (p - 1) CRT param */
|
/** The d mod (p - 1) CRT param */
|
||||||
void *dP;
|
void *dP;
|
||||||
/** The d mod (q - 1) CRT param */
|
/** The d mod (q - 1) CRT param */
|
||||||
void *dQ;
|
void *dQ;
|
||||||
/** The pq param */
|
/** The pq param */
|
||||||
@ -143,9 +143,9 @@ int katja_encrypt_key(const unsigned char *in, unsigned long inlen,
|
|||||||
unsigned char *out, unsigned long *outlen,
|
unsigned char *out, unsigned long *outlen,
|
||||||
const unsigned char *lparam, unsigned long lparamlen,
|
const unsigned char *lparam, unsigned long lparamlen,
|
||||||
prng_state *prng, int prng_idx, int hash_idx, katja_key *key);
|
prng_state *prng, int prng_idx, int hash_idx, katja_key *key);
|
||||||
|
|
||||||
int katja_decrypt_key(const unsigned char *in, unsigned long inlen,
|
int katja_decrypt_key(const unsigned char *in, unsigned long inlen,
|
||||||
unsigned char *out, unsigned long *outlen,
|
unsigned char *out, unsigned long *outlen,
|
||||||
const unsigned char *lparam, unsigned long lparamlen,
|
const unsigned char *lparam, unsigned long lparamlen,
|
||||||
int hash_idx, int *stat,
|
int hash_idx, int *stat,
|
||||||
katja_key *key);
|
katja_key *key);
|
||||||
@ -153,11 +153,11 @@ int katja_decrypt_key(const unsigned char *in, unsigned long inlen,
|
|||||||
/* LTC_PKCS #1 import/export */
|
/* LTC_PKCS #1 import/export */
|
||||||
int katja_export(unsigned char *out, unsigned long *outlen, int type, katja_key *key);
|
int katja_export(unsigned char *out, unsigned long *outlen, int type, katja_key *key);
|
||||||
int katja_import(const unsigned char *in, unsigned long inlen, katja_key *key);
|
int katja_import(const unsigned char *in, unsigned long inlen, katja_key *key);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* ---- DH Routines ---- */
|
/* ---- DH Routines ---- */
|
||||||
#ifdef MDH
|
#ifdef MDH
|
||||||
|
|
||||||
typedef struct Dh_key {
|
typedef struct Dh_key {
|
||||||
int idx, type;
|
int idx, type;
|
||||||
@ -179,12 +179,12 @@ int dh_shared_secret(dh_key *private_key, dh_key *public_key,
|
|||||||
unsigned char *out, unsigned long *outlen);
|
unsigned char *out, unsigned long *outlen);
|
||||||
|
|
||||||
int dh_encrypt_key(const unsigned char *in, unsigned long keylen,
|
int dh_encrypt_key(const unsigned char *in, unsigned long keylen,
|
||||||
unsigned char *out, unsigned long *outlen,
|
unsigned char *out, unsigned long *outlen,
|
||||||
prng_state *prng, int wprng, int hash,
|
prng_state *prng, int wprng, int hash,
|
||||||
dh_key *key);
|
dh_key *key);
|
||||||
|
|
||||||
int dh_decrypt_key(const unsigned char *in, unsigned long inlen,
|
int dh_decrypt_key(const unsigned char *in, unsigned long inlen,
|
||||||
unsigned char *out, unsigned long *outlen,
|
unsigned char *out, unsigned long *outlen,
|
||||||
dh_key *key);
|
dh_key *key);
|
||||||
|
|
||||||
int dh_sign_hash(const unsigned char *in, unsigned long inlen,
|
int dh_sign_hash(const unsigned char *in, unsigned long inlen,
|
||||||
@ -192,7 +192,7 @@ int dh_sign_hash(const unsigned char *in, unsigned long inlen,
|
|||||||
prng_state *prng, int wprng, dh_key *key);
|
prng_state *prng, int wprng, dh_key *key);
|
||||||
|
|
||||||
int dh_verify_hash(const unsigned char *sig, unsigned long siglen,
|
int dh_verify_hash(const unsigned char *sig, unsigned long siglen,
|
||||||
const unsigned char *hash, unsigned long hashlen,
|
const unsigned char *hash, unsigned long hashlen,
|
||||||
int *stat, dh_key *key);
|
int *stat, dh_key *key);
|
||||||
|
|
||||||
|
|
||||||
@ -214,7 +214,7 @@ typedef struct {
|
|||||||
int size;
|
int size;
|
||||||
|
|
||||||
/** name of curve */
|
/** name of curve */
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
/** The prime that defines the field the curve is in (encoded in hex) */
|
/** The prime that defines the field the curve is in (encoded in hex) */
|
||||||
char *prime;
|
char *prime;
|
||||||
@ -224,10 +224,10 @@ typedef struct {
|
|||||||
|
|
||||||
/** The order of the curve (hex) */
|
/** The order of the curve (hex) */
|
||||||
char *order;
|
char *order;
|
||||||
|
|
||||||
/** The x co-ordinate of the base point on the curve (hex) */
|
/** The x co-ordinate of the base point on the curve (hex) */
|
||||||
char *Gx;
|
char *Gx;
|
||||||
|
|
||||||
/** The y co-ordinate of the base point on the curve (hex) */
|
/** The y co-ordinate of the base point on the curve (hex) */
|
||||||
char *Gy;
|
char *Gy;
|
||||||
} ltc_ecc_set_type;
|
} ltc_ecc_set_type;
|
||||||
@ -281,24 +281,24 @@ int ecc_ansi_x963_export(ecc_key *key, unsigned char *out, unsigned long *outlen
|
|||||||
int ecc_ansi_x963_import(const unsigned char *in, unsigned long inlen, ecc_key *key);
|
int ecc_ansi_x963_import(const unsigned char *in, unsigned long inlen, ecc_key *key);
|
||||||
int ecc_ansi_x963_import_ex(const unsigned char *in, unsigned long inlen, ecc_key *key, ltc_ecc_set_type *dp);
|
int ecc_ansi_x963_import_ex(const unsigned char *in, unsigned long inlen, ecc_key *key, ltc_ecc_set_type *dp);
|
||||||
|
|
||||||
int ecc_shared_secret(ecc_key *private_key, ecc_key *public_key,
|
int ecc_shared_secret(ecc_key *private_key, ecc_key *public_key,
|
||||||
unsigned char *out, unsigned long *outlen);
|
unsigned char *out, unsigned long *outlen);
|
||||||
|
|
||||||
int ecc_encrypt_key(const unsigned char *in, unsigned long inlen,
|
int ecc_encrypt_key(const unsigned char *in, unsigned long inlen,
|
||||||
unsigned char *out, unsigned long *outlen,
|
unsigned char *out, unsigned long *outlen,
|
||||||
prng_state *prng, int wprng, int hash,
|
prng_state *prng, int wprng, int hash,
|
||||||
ecc_key *key);
|
ecc_key *key);
|
||||||
|
|
||||||
int ecc_decrypt_key(const unsigned char *in, unsigned long inlen,
|
int ecc_decrypt_key(const unsigned char *in, unsigned long inlen,
|
||||||
unsigned char *out, unsigned long *outlen,
|
unsigned char *out, unsigned long *outlen,
|
||||||
ecc_key *key);
|
ecc_key *key);
|
||||||
|
|
||||||
int ecc_sign_hash(const unsigned char *in, unsigned long inlen,
|
int ecc_sign_hash(const unsigned char *in, unsigned long inlen,
|
||||||
unsigned char *out, unsigned long *outlen,
|
unsigned char *out, unsigned long *outlen,
|
||||||
prng_state *prng, int wprng, ecc_key *key);
|
prng_state *prng, int wprng, ecc_key *key);
|
||||||
|
|
||||||
int ecc_verify_hash(const unsigned char *sig, unsigned long siglen,
|
int ecc_verify_hash(const unsigned char *sig, unsigned long siglen,
|
||||||
const unsigned char *hash, unsigned long hashlen,
|
const unsigned char *hash, unsigned long hashlen,
|
||||||
int *stat, ecc_key *key);
|
int *stat, ecc_key *key);
|
||||||
|
|
||||||
/* low level functions */
|
/* low level functions */
|
||||||
@ -365,7 +365,7 @@ int ltc_ecc_map(ecc_point *P, void *modulus, void *mp);
|
|||||||
/** DSA key structure */
|
/** DSA key structure */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/** The key type, PK_PRIVATE or PK_PUBLIC */
|
/** The key type, PK_PRIVATE or PK_PUBLIC */
|
||||||
int type;
|
int type;
|
||||||
|
|
||||||
/** The order of the sub-group used in octets */
|
/** The order of the sub-group used in octets */
|
||||||
int qord;
|
int qord;
|
||||||
@ -398,22 +398,22 @@ int dsa_sign_hash(const unsigned char *in, unsigned long inlen,
|
|||||||
prng_state *prng, int wprng, dsa_key *key);
|
prng_state *prng, int wprng, dsa_key *key);
|
||||||
|
|
||||||
int dsa_verify_hash_raw( void *r, void *s,
|
int dsa_verify_hash_raw( void *r, void *s,
|
||||||
const unsigned char *hash, unsigned long hashlen,
|
const unsigned char *hash, unsigned long hashlen,
|
||||||
int *stat, dsa_key *key);
|
int *stat, dsa_key *key);
|
||||||
|
|
||||||
int dsa_verify_hash(const unsigned char *sig, unsigned long siglen,
|
int dsa_verify_hash(const unsigned char *sig, unsigned long siglen,
|
||||||
const unsigned char *hash, unsigned long hashlen,
|
const unsigned char *hash, unsigned long hashlen,
|
||||||
int *stat, dsa_key *key);
|
int *stat, dsa_key *key);
|
||||||
|
|
||||||
int dsa_encrypt_key(const unsigned char *in, unsigned long inlen,
|
int dsa_encrypt_key(const unsigned char *in, unsigned long inlen,
|
||||||
unsigned char *out, unsigned long *outlen,
|
unsigned char *out, unsigned long *outlen,
|
||||||
prng_state *prng, int wprng, int hash,
|
prng_state *prng, int wprng, int hash,
|
||||||
dsa_key *key);
|
dsa_key *key);
|
||||||
|
|
||||||
int dsa_decrypt_key(const unsigned char *in, unsigned long inlen,
|
int dsa_decrypt_key(const unsigned char *in, unsigned long inlen,
|
||||||
unsigned char *out, unsigned long *outlen,
|
unsigned char *out, unsigned long *outlen,
|
||||||
dsa_key *key);
|
dsa_key *key);
|
||||||
|
|
||||||
int dsa_import(const unsigned char *in, unsigned long inlen, dsa_key *key);
|
int dsa_import(const unsigned char *in, unsigned long inlen, dsa_key *key);
|
||||||
int dsa_export(unsigned char *out, unsigned long *outlen, int type, dsa_key *key);
|
int dsa_export(unsigned char *out, unsigned long *outlen, int type, dsa_key *key);
|
||||||
int dsa_verify_key(dsa_key *key, int *stat);
|
int dsa_verify_key(dsa_key *key, int *stat);
|
||||||
@ -475,12 +475,12 @@ typedef struct ltc_asn1_list_ {
|
|||||||
/* SEQUENCE */
|
/* SEQUENCE */
|
||||||
int der_encode_sequence_ex(ltc_asn1_list *list, unsigned long inlen,
|
int der_encode_sequence_ex(ltc_asn1_list *list, unsigned long inlen,
|
||||||
unsigned char *out, unsigned long *outlen, int type_of);
|
unsigned char *out, unsigned long *outlen, int type_of);
|
||||||
|
|
||||||
#define der_encode_sequence(list, inlen, out, outlen) der_encode_sequence_ex(list, inlen, out, outlen, LTC_ASN1_SEQUENCE)
|
#define der_encode_sequence(list, inlen, out, outlen) der_encode_sequence_ex(list, inlen, out, outlen, LTC_ASN1_SEQUENCE)
|
||||||
|
|
||||||
int der_decode_sequence_ex(const unsigned char *in, unsigned long inlen,
|
int der_decode_sequence_ex(const unsigned char *in, unsigned long inlen,
|
||||||
ltc_asn1_list *list, unsigned long outlen, int ordered);
|
ltc_asn1_list *list, unsigned long outlen, int ordered);
|
||||||
|
|
||||||
#define der_decode_sequence(in, inlen, list, outlen) der_decode_sequence_ex(in, inlen, list, outlen, 1)
|
#define der_decode_sequence(in, inlen, list, outlen) der_decode_sequence_ex(in, inlen, list, outlen, 1)
|
||||||
|
|
||||||
int der_length_sequence(ltc_asn1_list *list, unsigned long inlen,
|
int der_length_sequence(ltc_asn1_list *list, unsigned long inlen,
|
||||||
@ -503,7 +503,7 @@ int der_encode_set(ltc_asn1_list *list, unsigned long inlen,
|
|||||||
|
|
||||||
int der_encode_setof(ltc_asn1_list *list, unsigned long inlen,
|
int der_encode_setof(ltc_asn1_list *list, unsigned long inlen,
|
||||||
unsigned char *out, unsigned long *outlen);
|
unsigned char *out, unsigned long *outlen);
|
||||||
|
|
||||||
/* VA list handy helpers with triplets of <type, size, data> */
|
/* VA list handy helpers with triplets of <type, size, data> */
|
||||||
int der_encode_sequence_multi(unsigned char *out, unsigned long *outlen, ...);
|
int der_encode_sequence_multi(unsigned char *out, unsigned long *outlen, ...);
|
||||||
int der_decode_sequence_multi(const unsigned char *in, unsigned long inlen, ...);
|
int der_decode_sequence_multi(const unsigned char *in, unsigned long inlen, ...);
|
||||||
@ -515,10 +515,10 @@ void der_sequence_free(ltc_asn1_list *in);
|
|||||||
|
|
||||||
/* BOOLEAN */
|
/* BOOLEAN */
|
||||||
int der_length_boolean(unsigned long *outlen);
|
int der_length_boolean(unsigned long *outlen);
|
||||||
int der_encode_boolean(int in,
|
int der_encode_boolean(int in,
|
||||||
unsigned char *out, unsigned long *outlen);
|
unsigned char *out, unsigned long *outlen);
|
||||||
int der_decode_boolean(const unsigned char *in, unsigned long inlen,
|
int der_decode_boolean(const unsigned char *in, unsigned long inlen,
|
||||||
int *out);
|
int *out);
|
||||||
/* INTEGER */
|
/* INTEGER */
|
||||||
int der_encode_integer(void *num, unsigned char *out, unsigned long *outlen);
|
int der_encode_integer(void *num, unsigned char *out, unsigned long *outlen);
|
||||||
int der_decode_integer(const unsigned char *in, unsigned long inlen, void *num);
|
int der_decode_integer(const unsigned char *in, unsigned long inlen, void *num);
|
||||||
@ -584,7 +584,7 @@ int der_printable_char_encode(int c);
|
|||||||
int der_printable_value_decode(int v);
|
int der_printable_value_decode(int v);
|
||||||
|
|
||||||
/* UTF-8 */
|
/* UTF-8 */
|
||||||
#if (defined(SIZE_MAX) || __STDC_VERSION__ >= 199901L || defined(WCHAR_MAX) || defined(_WCHAR_T) || defined(_WCHAR_T_DEFINED) || defined (__WCHAR_TYPE__)) && !defined(LTC_NO_WCHAR)
|
#if (defined(SIZE_MAX) || __STDC_VERSION__ >= 199901L || defined(WCHAR_MAX) || defined(_WCHAR_T) || defined(_WCHAR_T_DEFINED) || defined (__WCHAR_TYPE__)) && !defined(LTC_NO_WCHAR)
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
#else
|
#else
|
||||||
typedef ulong32 wchar_t;
|
typedef ulong32 wchar_t;
|
||||||
@ -616,7 +616,7 @@ typedef struct {
|
|||||||
off_mm; /* timezone offset minutes */
|
off_mm; /* timezone offset minutes */
|
||||||
} ltc_utctime;
|
} ltc_utctime;
|
||||||
|
|
||||||
int der_encode_utctime(ltc_utctime *utctime,
|
int der_encode_utctime(ltc_utctime *utctime,
|
||||||
unsigned char *out, unsigned long *outlen);
|
unsigned char *out, unsigned long *outlen);
|
||||||
|
|
||||||
int der_decode_utctime(const unsigned char *in, unsigned long *inlen,
|
int der_decode_utctime(const unsigned char *in, unsigned long *inlen,
|
||||||
|
@ -24,20 +24,20 @@ int pkcs_1_i2osp(void *n, unsigned long modulus_len, unsigned char *out);
|
|||||||
int pkcs_1_os2ip(void *n, unsigned char *in, unsigned long inlen);
|
int pkcs_1_os2ip(void *n, unsigned char *in, unsigned long inlen);
|
||||||
|
|
||||||
/* *** v1.5 padding */
|
/* *** v1.5 padding */
|
||||||
int pkcs_1_v1_5_encode(const unsigned char *msg,
|
int pkcs_1_v1_5_encode(const unsigned char *msg,
|
||||||
unsigned long msglen,
|
unsigned long msglen,
|
||||||
int block_type,
|
int block_type,
|
||||||
unsigned long modulus_bitlen,
|
unsigned long modulus_bitlen,
|
||||||
prng_state *prng,
|
prng_state *prng,
|
||||||
int prng_idx,
|
int prng_idx,
|
||||||
unsigned char *out,
|
unsigned char *out,
|
||||||
unsigned long *outlen);
|
unsigned long *outlen);
|
||||||
|
|
||||||
int pkcs_1_v1_5_decode(const unsigned char *msg,
|
int pkcs_1_v1_5_decode(const unsigned char *msg,
|
||||||
unsigned long msglen,
|
unsigned long msglen,
|
||||||
int block_type,
|
int block_type,
|
||||||
unsigned long modulus_bitlen,
|
unsigned long modulus_bitlen,
|
||||||
unsigned char *out,
|
unsigned char *out,
|
||||||
unsigned long *outlen,
|
unsigned long *outlen,
|
||||||
int *is_valid);
|
int *is_valid);
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ int pkcs_1_oaep_decode(const unsigned char *msg, unsigned long msglen,
|
|||||||
int *res);
|
int *res);
|
||||||
|
|
||||||
int pkcs_1_pss_encode(const unsigned char *msghash, unsigned long msghashlen,
|
int pkcs_1_pss_encode(const unsigned char *msghash, unsigned long msghashlen,
|
||||||
unsigned long saltlen, prng_state *prng,
|
unsigned long saltlen, prng_state *prng,
|
||||||
int prng_idx, int hash_idx,
|
int prng_idx, int hash_idx,
|
||||||
unsigned long modulus_bitlen,
|
unsigned long modulus_bitlen,
|
||||||
unsigned char *out, unsigned long *outlen);
|
unsigned char *out, unsigned long *outlen);
|
||||||
@ -71,13 +71,13 @@ int pkcs_1_pss_decode(const unsigned char *msghash, unsigned long msghashlen,
|
|||||||
#ifdef LTC_PKCS_5
|
#ifdef LTC_PKCS_5
|
||||||
|
|
||||||
/* Algorithm #1 (old) */
|
/* Algorithm #1 (old) */
|
||||||
int pkcs_5_alg1(const unsigned char *password, unsigned long password_len,
|
int pkcs_5_alg1(const unsigned char *password, unsigned long password_len,
|
||||||
const unsigned char *salt,
|
const unsigned char *salt,
|
||||||
int iteration_count, int hash_idx,
|
int iteration_count, int hash_idx,
|
||||||
unsigned char *out, unsigned long *outlen);
|
unsigned char *out, unsigned long *outlen);
|
||||||
|
|
||||||
/* Algorithm #2 (new) */
|
/* Algorithm #2 (new) */
|
||||||
int pkcs_5_alg2(const unsigned char *password, unsigned long password_len,
|
int pkcs_5_alg2(const unsigned char *password, unsigned long password_len,
|
||||||
const unsigned char *salt, unsigned long salt_len,
|
const unsigned char *salt, unsigned long salt_len,
|
||||||
int iteration_count, int hash_idx,
|
int iteration_count, int hash_idx,
|
||||||
unsigned char *out, unsigned long *outlen);
|
unsigned char *out, unsigned long *outlen);
|
||||||
|
@ -23,10 +23,10 @@ struct fortuna_prng {
|
|||||||
|
|
||||||
unsigned char K[32], /* the current key */
|
unsigned char K[32], /* the current key */
|
||||||
IV[16]; /* IV for CTR mode */
|
IV[16]; /* IV for CTR mode */
|
||||||
|
|
||||||
unsigned long pool_idx, /* current pool we will add to */
|
unsigned long pool_idx, /* current pool we will add to */
|
||||||
pool0_len, /* length of 0'th pool */
|
pool0_len, /* length of 0'th pool */
|
||||||
wd;
|
wd;
|
||||||
|
|
||||||
ulong64 reset_cnt; /* number of times we have reset */
|
ulong64 reset_cnt; /* number of times we have reset */
|
||||||
LTC_MUTEX_TYPE(prng_lock)
|
LTC_MUTEX_TYPE(prng_lock)
|
||||||
@ -36,14 +36,14 @@ struct fortuna_prng {
|
|||||||
#ifdef LTC_SOBER128
|
#ifdef LTC_SOBER128
|
||||||
struct sober128_prng {
|
struct sober128_prng {
|
||||||
ulong32 R[17], /* Working storage for the shift register */
|
ulong32 R[17], /* Working storage for the shift register */
|
||||||
initR[17], /* saved register contents */
|
initR[17], /* saved register contents */
|
||||||
konst, /* key dependent constant */
|
konst, /* key dependent constant */
|
||||||
sbuf; /* partial word encryption buffer */
|
sbuf; /* partial word encryption buffer */
|
||||||
|
|
||||||
int nbuf, /* number of part-word stream bits buffered */
|
int nbuf, /* number of part-word stream bits buffered */
|
||||||
flag, /* first add_entropy call or not? */
|
flag, /* first add_entropy call or not? */
|
||||||
set; /* did we call add_entropy to set key? */
|
set; /* did we call add_entropy to set key? */
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -98,7 +98,7 @@ extern struct ltc_prng_descriptor {
|
|||||||
@return CRYPT_OK if successful
|
@return CRYPT_OK if successful
|
||||||
*/
|
*/
|
||||||
int (*done)(prng_state *prng);
|
int (*done)(prng_state *prng);
|
||||||
/** Export a PRNG state
|
/** Export a PRNG state
|
||||||
@param out [out] The destination for the state
|
@param out [out] The destination for the state
|
||||||
@param outlen [in/out] The max size and resulting size of the PRNG state
|
@param outlen [in/out] The max size and resulting size of the PRNG state
|
||||||
@param prng The PRNG to export
|
@param prng The PRNG to export
|
||||||
@ -187,8 +187,8 @@ LTC_MUTEX_PROTO(ltc_prng_mutex)
|
|||||||
/* Slow RNG you **might** be able to use to seed a PRNG with. Be careful as this
|
/* Slow RNG you **might** be able to use to seed a PRNG with. Be careful as this
|
||||||
* might not work on all platforms as planned
|
* might not work on all platforms as planned
|
||||||
*/
|
*/
|
||||||
unsigned long rng_get_bytes(unsigned char *out,
|
unsigned long rng_get_bytes(unsigned char *out,
|
||||||
unsigned long outlen,
|
unsigned long outlen,
|
||||||
void (*callback)(void));
|
void (*callback)(void));
|
||||||
|
|
||||||
int rng_make_prng(int bits, int wprng, prng_state *prng, void (*callback)(void));
|
int rng_make_prng(int bits, int wprng, prng_state *prng, void (*callback)(void));
|
||||||
|
Loading…
Reference in New Issue
Block a user