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
|
||||
|
||||
#define LTC_ARGCHK(x)
|
||||
#define LTC_ARGCHK(x)
|
||||
#define LTC_ARGCHKVD(x) LTC_ARGCHK(x)
|
||||
|
||||
#elif ARGTYPE == 4
|
||||
|
@ -48,8 +48,8 @@ LTC_EXPORT int LTC_CALL XSTRCMP(const char *s1, const char *s2);
|
||||
#define ARGTYPE 0
|
||||
#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.
|
||||
* The x86 platforms allow this but some others [ARM for instance] do not. On those platforms you **MUST**
|
||||
* 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 LTC_FAST
|
||||
#define LTC_FAST_TYPE unsigned long
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* detect sparc and sparc64 */
|
||||
#if defined(__sparc__)
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* ---- 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.
|
||||
*/
|
||||
#ifdef LTC_BLOWFISH
|
||||
@ -109,7 +109,7 @@ struct noekeon_key {
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef LTC_SKIPJACK
|
||||
#ifdef LTC_SKIPJACK
|
||||
struct skipjack_key {
|
||||
unsigned char key[10];
|
||||
};
|
||||
@ -117,18 +117,18 @@ struct skipjack_key {
|
||||
|
||||
#ifdef LTC_KHAZAD
|
||||
struct khazad_key {
|
||||
ulong64 roundKeyEnc[8 + 1];
|
||||
ulong64 roundKeyDec[8 + 1];
|
||||
ulong64 roundKeyEnc[8 + 1];
|
||||
ulong64 roundKeyDec[8 + 1];
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef LTC_ANUBIS
|
||||
struct anubis_key {
|
||||
int keyBits;
|
||||
int R;
|
||||
ulong32 roundKeyEnc[18 + 1][4];
|
||||
ulong32 roundKeyDec[18 + 1][4];
|
||||
};
|
||||
struct anubis_key {
|
||||
int keyBits;
|
||||
int R;
|
||||
ulong32 roundKeyEnc[18 + 1][4];
|
||||
ulong32 roundKeyDec[18 + 1][4];
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef LTC_MULTI2
|
||||
@ -182,7 +182,7 @@ typedef union Symmetric_key {
|
||||
#endif
|
||||
#ifdef LTC_NOEKEON
|
||||
struct noekeon_key noekeon;
|
||||
#endif
|
||||
#endif
|
||||
#ifdef LTC_SKIPJACK
|
||||
struct skipjack_key skipjack;
|
||||
#endif
|
||||
@ -197,7 +197,7 @@ typedef union Symmetric_key {
|
||||
#endif
|
||||
#ifdef LTC_KASUMI
|
||||
struct kasumi_key kasumi;
|
||||
#endif
|
||||
#endif
|
||||
#ifdef LTC_MULTI2
|
||||
struct multi2_key multi2;
|
||||
#endif
|
||||
@ -211,10 +211,10 @@ typedef union Symmetric_key {
|
||||
/** A block cipher ECB structure */
|
||||
typedef struct {
|
||||
/** The index of the cipher chosen */
|
||||
int cipher,
|
||||
int cipher,
|
||||
/** The block size of the given cipher */
|
||||
blocklen;
|
||||
/** The scheduled key */
|
||||
/** The scheduled key */
|
||||
symmetric_key key;
|
||||
} symmetric_ECB;
|
||||
#endif
|
||||
@ -223,14 +223,14 @@ typedef struct {
|
||||
/** A block cipher CFB structure */
|
||||
typedef struct {
|
||||
/** The index of the cipher chosen */
|
||||
int cipher,
|
||||
/** The block size of the given cipher */
|
||||
blocklen,
|
||||
int cipher,
|
||||
/** The block size of the given cipher */
|
||||
blocklen,
|
||||
/** The padding offset */
|
||||
padlen;
|
||||
/** The current IV */
|
||||
unsigned char IV[MAXBLOCKSIZE],
|
||||
/** The pad used to encrypt/decrypt */
|
||||
unsigned char IV[MAXBLOCKSIZE],
|
||||
/** The pad used to encrypt/decrypt */
|
||||
pad[MAXBLOCKSIZE];
|
||||
/** The scheduled key */
|
||||
symmetric_key key;
|
||||
@ -241,9 +241,9 @@ typedef struct {
|
||||
/** A block cipher OFB structure */
|
||||
typedef struct {
|
||||
/** The index of the cipher chosen */
|
||||
int cipher,
|
||||
/** The block size of the given cipher */
|
||||
blocklen,
|
||||
int cipher,
|
||||
/** The block size of the given cipher */
|
||||
blocklen,
|
||||
/** The padding offset */
|
||||
padlen;
|
||||
/** The current IV */
|
||||
@ -257,8 +257,8 @@ typedef struct {
|
||||
/** A block cipher CBC structure */
|
||||
typedef struct {
|
||||
/** The index of the cipher chosen */
|
||||
int cipher,
|
||||
/** The block size of the given cipher */
|
||||
int cipher,
|
||||
/** The block size of the given cipher */
|
||||
blocklen;
|
||||
/** The current IV */
|
||||
unsigned char IV[MAXBLOCKSIZE];
|
||||
@ -273,18 +273,18 @@ typedef struct {
|
||||
typedef struct {
|
||||
/** The index of the cipher chosen */
|
||||
int cipher,
|
||||
/** The block size of the given cipher */
|
||||
blocklen,
|
||||
/** The block size of the given cipher */
|
||||
blocklen,
|
||||
/** The padding offset */
|
||||
padlen,
|
||||
padlen,
|
||||
/** The mode (endianess) of the CTR, 0==little, 1==big */
|
||||
mode,
|
||||
/** counter width */
|
||||
ctrlen;
|
||||
|
||||
/** The counter */
|
||||
unsigned char ctr[MAXBLOCKSIZE],
|
||||
/** The pad used to encrypt/decrypt */
|
||||
/** The counter */
|
||||
unsigned char ctr[MAXBLOCKSIZE],
|
||||
/** The pad used to encrypt/decrypt */
|
||||
pad[MAXBLOCKSIZE];
|
||||
/** The scheduled key */
|
||||
symmetric_key key;
|
||||
@ -300,7 +300,7 @@ typedef struct {
|
||||
|
||||
/** The current IV */
|
||||
unsigned char IV[16],
|
||||
|
||||
|
||||
/** the tweak key */
|
||||
tweak[16],
|
||||
|
||||
@ -321,9 +321,9 @@ typedef struct {
|
||||
/** A block cipher F8 structure */
|
||||
typedef struct {
|
||||
/** The index of the cipher chosen */
|
||||
int cipher,
|
||||
/** The block size of the given cipher */
|
||||
blocklen,
|
||||
int cipher,
|
||||
/** The block size of the given cipher */
|
||||
blocklen,
|
||||
/** The padding offset */
|
||||
padlen;
|
||||
/** The current IV */
|
||||
@ -344,14 +344,14 @@ extern struct ltc_cipher_descriptor {
|
||||
/** internal ID */
|
||||
unsigned char ID;
|
||||
/** min keysize (octets) */
|
||||
int min_key_length,
|
||||
int min_key_length,
|
||||
/** max keysize (octets) */
|
||||
max_key_length,
|
||||
max_key_length,
|
||||
/** block size (octets) */
|
||||
block_length,
|
||||
block_length,
|
||||
/** default number of rounds */
|
||||
default_rounds;
|
||||
/** Setup the cipher
|
||||
/** Setup the cipher
|
||||
@param key The input symmetric key
|
||||
@param keylen The length of the input key (octets)
|
||||
@param num_rounds The requested number of rounds (0==default)
|
||||
@ -378,10 +378,10 @@ extern struct ltc_cipher_descriptor {
|
||||
*/
|
||||
int (*test)(void);
|
||||
|
||||
/** Terminate the context
|
||||
/** Terminate the context
|
||||
@param skey The scheduled key
|
||||
*/
|
||||
void (*done)(symmetric_key *skey);
|
||||
void (*done)(symmetric_key *skey);
|
||||
|
||||
/** Determine a key 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);
|
||||
|
||||
/** Accelerators **/
|
||||
/** Accelerated ECB encryption
|
||||
/** Accelerated ECB encryption
|
||||
@param pt Plaintext
|
||||
@param ct Ciphertext
|
||||
@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);
|
||||
|
||||
/** Accelerated ECB decryption
|
||||
/** Accelerated ECB decryption
|
||||
@param pt Plaintext
|
||||
@param ct Ciphertext
|
||||
@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);
|
||||
|
||||
/** Accelerated CBC encryption
|
||||
/** Accelerated CBC encryption
|
||||
@param pt Plaintext
|
||||
@param ct Ciphertext
|
||||
@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);
|
||||
|
||||
/** Accelerated CBC decryption
|
||||
/** Accelerated CBC decryption
|
||||
@param pt Plaintext
|
||||
@param ct Ciphertext
|
||||
@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);
|
||||
|
||||
/** Accelerated CTR encryption
|
||||
/** Accelerated CTR encryption
|
||||
@param pt Plaintext
|
||||
@param ct Ciphertext
|
||||
@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);
|
||||
|
||||
/** Accelerated LRW
|
||||
/** Accelerated LRW
|
||||
@param pt Plaintext
|
||||
@param ct Ciphertext
|
||||
@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);
|
||||
|
||||
/** Accelerated LRW
|
||||
/** Accelerated LRW
|
||||
@param ct Ciphertext
|
||||
@param pt Plaintext
|
||||
@param blocks The number of complete blocks to process
|
||||
@ -490,7 +490,7 @@ extern struct ltc_cipher_descriptor {
|
||||
/** Accelerated GCM packet (one shot)
|
||||
@param key 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 adata The additional authentication data (header)
|
||||
@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 *adata, unsigned long adatalen,
|
||||
unsigned char *pt, unsigned long ptlen,
|
||||
unsigned char *ct,
|
||||
unsigned char *ct,
|
||||
unsigned char *tag, unsigned long *taglen,
|
||||
int direction);
|
||||
|
||||
/** Accelerated one shot LTC_OMAC
|
||||
/** Accelerated one shot LTC_OMAC
|
||||
@param key The secret key
|
||||
@param keylen The key length (octets)
|
||||
@param in The message
|
||||
@param keylen The key length (octets)
|
||||
@param in The message
|
||||
@param inlen Length of message (octets)
|
||||
@param out [out] Destination for tag
|
||||
@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,
|
||||
unsigned char *out, unsigned long *outlen);
|
||||
|
||||
/** Accelerated one shot XCBC
|
||||
/** Accelerated one shot XCBC
|
||||
@param key The secret key
|
||||
@param keylen The key length (octets)
|
||||
@param in The message
|
||||
@param keylen The key length (octets)
|
||||
@param in The message
|
||||
@param inlen Length of message (octets)
|
||||
@param out [out] Destination for tag
|
||||
@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,
|
||||
unsigned char *out, unsigned long *outlen);
|
||||
|
||||
/** Accelerated one shot F9
|
||||
/** Accelerated one shot F9
|
||||
@param key The secret key
|
||||
@param keylen The key length (octets)
|
||||
@param in The message
|
||||
@param keylen The key length (octets)
|
||||
@param in The message
|
||||
@param inlen Length of message (octets)
|
||||
@param out [out] Destination for tag
|
||||
@param outlen [in/out] Initial and final size of out
|
||||
@ -777,7 +777,7 @@ extern const struct ltc_cipher_descriptor camellia_desc;
|
||||
#endif
|
||||
|
||||
#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 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);
|
||||
@ -785,7 +785,7 @@ int ecb_done(symmetric_ECB *ecb);
|
||||
#endif
|
||||
|
||||
#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 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);
|
||||
@ -795,7 +795,7 @@ int cfb_done(symmetric_CFB *cfb);
|
||||
#endif
|
||||
|
||||
#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 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);
|
||||
@ -842,7 +842,7 @@ int lrw_start( int cipher,
|
||||
const unsigned char *IV,
|
||||
const unsigned char *key, int keylen,
|
||||
const unsigned char *tweak,
|
||||
int num_rounds,
|
||||
int num_rounds,
|
||||
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);
|
||||
@ -853,11 +853,11 @@ int lrw_test(void);
|
||||
|
||||
/* don't call */
|
||||
int lrw_process(const unsigned char *pt, unsigned char *ct, unsigned long len, int mode, symmetric_LRW *lrw);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef LTC_F8_MODE
|
||||
int f8_start( int cipher, const unsigned char *IV,
|
||||
const unsigned char *key, int keylen,
|
||||
int f8_start( int cipher, const unsigned char *IV,
|
||||
const unsigned char *key, int keylen,
|
||||
const unsigned char *salt_key, int skeylen,
|
||||
int num_rounds, 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;
|
||||
|
||||
int xts_start( int cipher,
|
||||
const unsigned char *key1,
|
||||
const unsigned char *key2,
|
||||
const unsigned char *key1,
|
||||
const unsigned char *key2,
|
||||
unsigned long keylen,
|
||||
int num_rounds,
|
||||
int num_rounds,
|
||||
symmetric_xts *xts);
|
||||
|
||||
int xts_encrypt(
|
||||
|
@ -3,19 +3,19 @@
|
||||
|
||||
/* macros for various libc functions you can change for embedded targets */
|
||||
#ifndef XMALLOC
|
||||
#ifdef malloc
|
||||
#ifdef malloc
|
||||
#define LTC_NO_PROTOTYPES
|
||||
#endif
|
||||
#define XMALLOC malloc
|
||||
#endif
|
||||
#ifndef XREALLOC
|
||||
#ifdef realloc
|
||||
#ifdef realloc
|
||||
#define LTC_NO_PROTOTYPES
|
||||
#endif
|
||||
#define XREALLOC realloc
|
||||
#endif
|
||||
#ifndef XCALLOC
|
||||
#ifdef calloc
|
||||
#ifdef calloc
|
||||
#define LTC_NO_PROTOTYPES
|
||||
#endif
|
||||
#define XCALLOC calloc
|
||||
@ -40,7 +40,7 @@
|
||||
#define XMEMCPY memcpy
|
||||
#endif
|
||||
#ifndef XMEMCMP
|
||||
#ifdef memcmp
|
||||
#ifdef memcmp
|
||||
#define LTC_NO_PROTOTYPES
|
||||
#endif
|
||||
#define XMEMCMP memcmp
|
||||
@ -73,19 +73,19 @@
|
||||
#define LTC_BLOWFISH
|
||||
#define LTC_DES
|
||||
#define LTC_CAST5
|
||||
|
||||
|
||||
#define LTC_NO_MODES
|
||||
#define LTC_ECB_MODE
|
||||
#define LTC_CBC_MODE
|
||||
#define LTC_CTR_MODE
|
||||
|
||||
|
||||
#define LTC_NO_HASHES
|
||||
#define LTC_SHA1
|
||||
#define LTC_SHA512
|
||||
#define LTC_SHA384
|
||||
#define LTC_SHA256
|
||||
#define LTC_SHA224
|
||||
|
||||
|
||||
#define LTC_NO_MACS
|
||||
#define LTC_HMAC
|
||||
#define LTC_OMAC
|
||||
@ -96,11 +96,11 @@
|
||||
#define LTC_YARROW
|
||||
#define LTC_DEVRANDOM
|
||||
#define TRY_URANDOM_FIRST
|
||||
|
||||
|
||||
#define LTC_NO_PK
|
||||
#define LTC_MRSA
|
||||
#define LTC_MECC
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Use small code where possible */
|
||||
/* #define LTC_SMALL_CODE */
|
||||
@ -178,7 +178,7 @@
|
||||
#define LTC_LRW_MODE
|
||||
#ifndef LTC_NO_TABLES
|
||||
/* like GCM mode this will enable 16 8x128 tables [64KB] that make
|
||||
* seeking very fast.
|
||||
* seeking very fast.
|
||||
*/
|
||||
#define LRW_TABLES
|
||||
#endif
|
||||
@ -189,7 +189,7 @@
|
||||
#endif /* LTC_NO_MODES */
|
||||
|
||||
/* ---> One-Way Hash Functions <--- */
|
||||
#ifndef LTC_NO_HASHES
|
||||
#ifndef LTC_NO_HASHES
|
||||
|
||||
#define LTC_CHC_HASH
|
||||
#define LTC_WHIRLPOOL
|
||||
@ -237,7 +237,7 @@
|
||||
|
||||
/* Use 64KiB tables */
|
||||
#ifndef LTC_NO_TABLES
|
||||
#define LTC_GCM_TABLES
|
||||
#define LTC_GCM_TABLES
|
||||
#endif
|
||||
|
||||
/* USE SSE2? requires GCC works on x86_32 and x86_64*/
|
||||
@ -331,7 +331,7 @@
|
||||
#endif
|
||||
|
||||
/* Include Katja (a Rabin variant like RSA) */
|
||||
/* #define MKAT */
|
||||
/* #define MKAT */
|
||||
|
||||
/* Digital Signature Algorithm */
|
||||
#define LTC_MDSA
|
||||
@ -344,7 +344,7 @@
|
||||
|
||||
#if defined(TFM_LTC_DESC) && defined(LTC_MECC)
|
||||
#define LTC_MECC_ACCEL
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* do we want fixed point ECC */
|
||||
/* #define LTC_MECC_FP */
|
||||
@ -395,14 +395,14 @@
|
||||
|
||||
#ifdef LTC_MRSA
|
||||
#define LTC_PKCS_1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(TFM_DESC) && defined(LTC_RSA_BLINDING)
|
||||
#warning RSA blinding currently not supported in combination with TFM
|
||||
#undef LTC_RSA_BLINDING
|
||||
#endif
|
||||
|
||||
#if defined(LTC_DER) && !defined(MPI)
|
||||
#if defined(LTC_DER) && !defined(MPI)
|
||||
#error ASN.1 DER requires MPI functionality
|
||||
#endif
|
||||
|
||||
|
@ -166,7 +166,7 @@ extern struct ltc_hash_descriptor {
|
||||
@return CRYPT_OK if successful
|
||||
*/
|
||||
int (*init)(hash_state *hash);
|
||||
/** Process a block of data
|
||||
/** Process a block of data
|
||||
@param hash The hash state
|
||||
@param in The data to hash
|
||||
@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 */
|
||||
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);
|
||||
|
||||
} hash_descriptor[];
|
||||
@ -329,8 +329,8 @@ int hash_is_valid(int idx);
|
||||
|
||||
LTC_MUTEX_PROTO(ltc_hash_mutex)
|
||||
|
||||
int hash_memory(int hash,
|
||||
const unsigned char *in, unsigned long inlen,
|
||||
int hash_memory(int hash,
|
||||
const unsigned char *in, unsigned long inlen,
|
||||
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, ...);
|
||||
|
@ -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_done(hmac_state *hmac, unsigned char *out, unsigned long *outlen);
|
||||
int hmac_test(void);
|
||||
int hmac_memory(int hash,
|
||||
int hmac_memory(int hash,
|
||||
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);
|
||||
int hmac_memory_multi(int hash,
|
||||
int hmac_memory_multi(int hash,
|
||||
const unsigned char *key, unsigned long keylen,
|
||||
unsigned char *out, unsigned long *outlen,
|
||||
const unsigned char *in, unsigned long inlen, ...);
|
||||
int hmac_file(int hash, const char *fname, const unsigned char *key,
|
||||
unsigned long keylen,
|
||||
unsigned long keylen,
|
||||
unsigned char *dst, unsigned long *dstlen);
|
||||
#endif
|
||||
|
||||
#ifdef LTC_OMAC
|
||||
|
||||
typedef struct {
|
||||
int cipher_idx,
|
||||
int cipher_idx,
|
||||
buflen,
|
||||
blklen;
|
||||
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_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_memory(int cipher,
|
||||
int omac_memory(int cipher,
|
||||
const unsigned char *key, unsigned long keylen,
|
||||
const unsigned char *in, unsigned long inlen,
|
||||
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,
|
||||
unsigned char *out, unsigned long *outlen,
|
||||
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 char *filename,
|
||||
const char *filename,
|
||||
unsigned char *out, unsigned long *outlen);
|
||||
int omac_test(void);
|
||||
#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_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 *msg, unsigned long msglen,
|
||||
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,
|
||||
unsigned char *out, unsigned long *outlen,
|
||||
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 char *filename,
|
||||
const char *filename,
|
||||
unsigned char *out, unsigned long *outlen);
|
||||
|
||||
int pmac_test(void);
|
||||
@ -152,32 +152,32 @@ typedef struct {
|
||||
block_len; /* length of block */
|
||||
} 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);
|
||||
|
||||
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_done_encrypt(ocb_state *ocb,
|
||||
int ocb_done_encrypt(ocb_state *ocb,
|
||||
const unsigned char *pt, unsigned long ptlen,
|
||||
unsigned char *ct,
|
||||
unsigned char *ct,
|
||||
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,
|
||||
unsigned char *pt,
|
||||
unsigned char *pt,
|
||||
const unsigned char *tag, unsigned long taglen, int *stat);
|
||||
|
||||
int ocb_encrypt_authenticate_memory(int cipher,
|
||||
const unsigned char *key, unsigned long keylen,
|
||||
const unsigned char *nonce,
|
||||
const unsigned char *nonce,
|
||||
const unsigned char *pt, unsigned long ptlen,
|
||||
unsigned char *ct,
|
||||
unsigned char *tag, unsigned long *taglen);
|
||||
|
||||
int ocb_decrypt_verify_memory(int cipher,
|
||||
const unsigned char *key, unsigned long keylen,
|
||||
const unsigned char *nonce,
|
||||
const unsigned char *nonce,
|
||||
const unsigned char *ct, unsigned long ctlen,
|
||||
unsigned char *pt,
|
||||
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_TEXT 2
|
||||
|
||||
typedef struct {
|
||||
typedef struct {
|
||||
symmetric_key K;
|
||||
unsigned char H[16], /* multiplier */
|
||||
X[16], /* accumulator */
|
||||
@ -327,7 +327,7 @@ typedef struct {
|
||||
__attribute__ ((aligned (16)))
|
||||
#endif
|
||||
;
|
||||
#endif
|
||||
#endif
|
||||
} gcm_state;
|
||||
|
||||
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_add_iv(gcm_state *gcm,
|
||||
int gcm_add_iv(gcm_state *gcm,
|
||||
const unsigned char *IV, unsigned long IVlen);
|
||||
|
||||
int gcm_add_aad(gcm_state *gcm,
|
||||
@ -348,7 +348,7 @@ int gcm_process(gcm_state *gcm,
|
||||
unsigned char *ct,
|
||||
int direction);
|
||||
|
||||
int gcm_done(gcm_state *gcm,
|
||||
int gcm_done(gcm_state *gcm,
|
||||
unsigned char *tag, unsigned long *taglen);
|
||||
|
||||
int gcm_memory( int cipher,
|
||||
@ -356,7 +356,7 @@ int gcm_memory( int cipher,
|
||||
const unsigned char *IV, unsigned long IVlen,
|
||||
const unsigned char *adata, unsigned long adatalen,
|
||||
unsigned char *pt, unsigned long ptlen,
|
||||
unsigned char *ct,
|
||||
unsigned char *ct,
|
||||
unsigned char *tag, unsigned long *taglen,
|
||||
int direction);
|
||||
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_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_memory(int cipher,
|
||||
int xcbc_memory(int cipher,
|
||||
const unsigned char *key, unsigned long keylen,
|
||||
const unsigned char *in, unsigned long inlen,
|
||||
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,
|
||||
unsigned char *out, unsigned long *outlen,
|
||||
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 char *filename,
|
||||
const char *filename,
|
||||
unsigned char *out, unsigned long *outlen);
|
||||
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_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_memory(int cipher,
|
||||
int f9_memory(int cipher,
|
||||
const unsigned char *key, unsigned long keylen,
|
||||
const unsigned char *in, unsigned long inlen,
|
||||
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,
|
||||
unsigned char *out, unsigned long *outlen,
|
||||
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 char *filename,
|
||||
const char *filename,
|
||||
unsigned char *out, unsigned long *outlen);
|
||||
int f9_test(void);
|
||||
|
||||
|
@ -7,8 +7,8 @@
|
||||
typedef unsigned long long ulong64;
|
||||
#endif
|
||||
|
||||
/* this is the "32-bit at least" data type
|
||||
* Re-define it to suit your platform but it must be at least 32-bits
|
||||
/* this is the "32-bit at least" data type
|
||||
* Re-define it to suit your platform but it must be at least 32-bits
|
||||
*/
|
||||
#if defined(__x86_64__) || (defined(__sparc__) && defined(__arch64__))
|
||||
typedef unsigned ulong32;
|
||||
@ -148,7 +148,7 @@ asm __volatile__ ( \
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef ENDIAN_32BITWORD
|
||||
#ifdef ENDIAN_32BITWORD
|
||||
|
||||
#define STORE32L(x, y) \
|
||||
{ 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)[1] & 255))<<8)|(((ulong64)((y)[0] & 255))); }
|
||||
|
||||
#ifdef ENDIAN_32BITWORD
|
||||
#ifdef ENDIAN_32BITWORD
|
||||
|
||||
#define STORE32H(x, y) \
|
||||
{ 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))))
|
||||
#else
|
||||
#define byte(x, n) (((x) >> (8 * (n))) & 255)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
|
@ -30,15 +30,15 @@ typedef struct {
|
||||
@return CRYPT_OK on success
|
||||
*/
|
||||
int (*init)(void **a);
|
||||
|
||||
/** init copy
|
||||
|
||||
/** init copy
|
||||
@param dst The number to initialize and write to
|
||||
@param src The number to copy from
|
||||
@return CRYPT_OK on success
|
||||
*/
|
||||
int (*init_copy)(void **dst, void *src);
|
||||
|
||||
/** deinit
|
||||
/** deinit
|
||||
@param a The number to free
|
||||
@return CRYPT_OK on success
|
||||
*/
|
||||
@ -52,30 +52,30 @@ typedef struct {
|
||||
@return CRYPT_OK on success
|
||||
*/
|
||||
int (*neg)(void *src, void *dst);
|
||||
|
||||
/** copy
|
||||
|
||||
/** copy
|
||||
@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
|
||||
*/
|
||||
int (*copy)(void *src, void *dst);
|
||||
|
||||
/* ---- trivial low level functions ---- */
|
||||
|
||||
/** set small constant
|
||||
/** set small constant
|
||||
@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
|
||||
*/
|
||||
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
|
||||
@return The lower bits_per_digit of the integer (unsigned)
|
||||
*/
|
||||
unsigned long (*get_int)(void *a);
|
||||
|
||||
/** get digit n
|
||||
/** get digit n
|
||||
@param a The number to read from
|
||||
@param n The number of the digit to fetch
|
||||
@return The bits_per_digit sized n'th digit of a
|
||||
@ -95,7 +95,7 @@ typedef struct {
|
||||
*/
|
||||
int (*compare)(void *a, void *b);
|
||||
|
||||
/** compare against int
|
||||
/** compare against int
|
||||
@param a The left side integer
|
||||
@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)
|
||||
@ -108,7 +108,7 @@ typedef struct {
|
||||
*/
|
||||
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
|
||||
@return The number of contiguous zero LSB bits
|
||||
*/
|
||||
@ -122,8 +122,8 @@ typedef struct {
|
||||
int (*twoexpt)(void *a , int n);
|
||||
|
||||
/* ---- radix conversions ---- */
|
||||
|
||||
/** read ascii string
|
||||
|
||||
/** read ascii string
|
||||
@param a The integer to store into
|
||||
@param str The string to read
|
||||
@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);
|
||||
|
||||
/** 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)
|
||||
@return The length of the integer
|
||||
*/
|
||||
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 dst The buffer to store the integer in
|
||||
@return CRYPT_OK on success
|
||||
@ -154,15 +154,15 @@ typedef struct {
|
||||
|
||||
/** read an array of octets and store as integer
|
||||
@param dst The integer to load
|
||||
@param src The array of octets
|
||||
@param len The number of octets
|
||||
@param src The array of octets
|
||||
@param len The number of octets
|
||||
@return CRYPT_OK on success
|
||||
*/
|
||||
int (*unsigned_read)(void *dst, unsigned char *src, unsigned long len);
|
||||
|
||||
/* ---- basic math ---- */
|
||||
|
||||
/** add two integers
|
||||
/** add two integers
|
||||
@param a The first source integer
|
||||
@param b The second source integer
|
||||
@param c The destination of "a + b"
|
||||
@ -171,7 +171,7 @@ typedef struct {
|
||||
int (*add)(void *a, void *b, void *c);
|
||||
|
||||
|
||||
/** add two integers
|
||||
/** add two integers
|
||||
@param a The first source integer
|
||||
@param b The second source integer (single digit of upto bits_per_digit in length)
|
||||
@param c The destination of "a + b"
|
||||
@ -179,7 +179,7 @@ typedef struct {
|
||||
*/
|
||||
int (*addi)(void *a, unsigned long b, void *c);
|
||||
|
||||
/** subtract two integers
|
||||
/** subtract two integers
|
||||
@param a The first source integer
|
||||
@param b The second source integer
|
||||
@param c The destination of "a - b"
|
||||
@ -187,7 +187,7 @@ typedef struct {
|
||||
*/
|
||||
int (*sub)(void *a, void *b, void *c);
|
||||
|
||||
/** subtract two integers
|
||||
/** subtract two integers
|
||||
@param a The first source integer
|
||||
@param b The second source integer (single digit of upto bits_per_digit in length)
|
||||
@param c The destination of "a - b"
|
||||
@ -195,7 +195,7 @@ typedef struct {
|
||||
*/
|
||||
int (*subi)(void *a, unsigned long b, void *c);
|
||||
|
||||
/** multiply two integers
|
||||
/** multiply two integers
|
||||
@param a The first source integer
|
||||
@param b The second source integer (single digit of upto bits_per_digit in length)
|
||||
@param c The destination of "a * b"
|
||||
@ -203,7 +203,7 @@ typedef struct {
|
||||
*/
|
||||
int (*mul)(void *a, void *b, void *c);
|
||||
|
||||
/** multiply two integers
|
||||
/** multiply two integers
|
||||
@param a The first source integer
|
||||
@param b The second source integer (single digit of upto bits_per_digit in length)
|
||||
@param c The destination of "a * b"
|
||||
@ -227,9 +227,9 @@ typedef struct {
|
||||
*/
|
||||
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 b The destination
|
||||
@param b The destination
|
||||
@return CRYPT_OK on success
|
||||
*/
|
||||
int (*div_2)(void *a, void *b);
|
||||
@ -242,7 +242,7 @@ typedef struct {
|
||||
*/
|
||||
int (*modi)(void *a, unsigned long b, unsigned long *c);
|
||||
|
||||
/** gcd
|
||||
/** gcd
|
||||
@param a The first integer
|
||||
@param b The second integer
|
||||
@param c The destination for (a, b)
|
||||
@ -250,7 +250,7 @@ typedef struct {
|
||||
*/
|
||||
int (*gcd)(void *a, void *b, void *c);
|
||||
|
||||
/** lcm
|
||||
/** lcm
|
||||
@param a The first integer
|
||||
@param b The second integer
|
||||
@param c The destination for [a, b]
|
||||
@ -260,7 +260,7 @@ typedef struct {
|
||||
|
||||
/** Modular multiplication
|
||||
@param a The first source
|
||||
@param b The second source
|
||||
@param b The second source
|
||||
@param c The modulus
|
||||
@param d The destination (a*b mod c)
|
||||
@return CRYPT_OK on success
|
||||
@ -277,7 +277,7 @@ typedef struct {
|
||||
|
||||
/** Modular inversion
|
||||
@param a The value to invert
|
||||
@param b The modulus
|
||||
@param b The modulus
|
||||
@param c The destination (1/a mod b)
|
||||
@return CRYPT_OK on success
|
||||
*/
|
||||
@ -286,13 +286,13 @@ typedef struct {
|
||||
/* ---- reduction ---- */
|
||||
|
||||
/** setup montgomery
|
||||
@param a The modulus
|
||||
@param b The destination for the reduction digit
|
||||
@param a The modulus
|
||||
@param b The destination for the reduction digit
|
||||
@return CRYPT_OK on success
|
||||
*/
|
||||
int (*montgomery_setup)(void *a, void **b);
|
||||
|
||||
/** get normalization value
|
||||
/** get normalization value
|
||||
@param a The destination for the normalization value
|
||||
@param b The modulus
|
||||
@return CRYPT_OK on success
|
||||
@ -310,7 +310,7 @@ typedef struct {
|
||||
/** clean up (frees memory)
|
||||
@param a The value "b" from montgomery_setup()
|
||||
@return CRYPT_OK on success
|
||||
*/
|
||||
*/
|
||||
void (*montgomery_deinit)(void *a);
|
||||
|
||||
/* ---- exponentiation ---- */
|
||||
@ -336,14 +336,14 @@ typedef struct {
|
||||
/** ECC GF(p) point multiplication (from the NIST curves)
|
||||
@param k The integer to multiply the point by
|
||||
@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 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
|
||||
*/
|
||||
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 Q The second point
|
||||
@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);
|
||||
|
||||
/** ECC GF(p) point double
|
||||
/** ECC GF(p) point double
|
||||
@param P The first point
|
||||
@param R The destination of 2P
|
||||
@param modulus The modulus
|
||||
@ -367,7 +367,7 @@ typedef struct {
|
||||
@param modulus The modulus
|
||||
@param mp The "b" value from montgomery_setup()
|
||||
@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.
|
||||
*/
|
||||
int (*ecc_map)(ecc_point *P, void *modulus, void *mp);
|
||||
@ -378,9 +378,9 @@ typedef struct {
|
||||
@param B Second point to multiply
|
||||
@param kB What to multiple B by
|
||||
@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
|
||||
*/
|
||||
*/
|
||||
int (*ecc_mul2add)(ecc_point *A, void *kA,
|
||||
ecc_point *B, void *kB,
|
||||
ecc_point *C,
|
||||
@ -388,7 +388,7 @@ typedef struct {
|
||||
|
||||
/* ---- (optional) rsa optimized math (for internal CRT) ---- */
|
||||
|
||||
/** RSA Key Generation
|
||||
/** RSA Key Generation
|
||||
@param prng An active PRNG state
|
||||
@param wprng The index of the PRNG desired
|
||||
@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
|
||||
*/
|
||||
int (*rsa_keygen)(prng_state *prng, int wprng, int size, long e, rsa_key *key);
|
||||
|
||||
|
||||
|
||||
/** RSA exponentiation
|
||||
@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 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 key The RSA key to use
|
||||
@param key The RSA key to use
|
||||
@return CRYPT_OK on success
|
||||
*/
|
||||
int (*rsa_me)(const unsigned char *in, unsigned long inlen,
|
||||
@ -416,7 +416,7 @@ typedef struct {
|
||||
|
||||
/** Modular addition
|
||||
@param a The first source
|
||||
@param b The second source
|
||||
@param b The second source
|
||||
@param c The modulus
|
||||
@param d The destination (a + b mod c)
|
||||
@return CRYPT_OK on success
|
||||
@ -425,7 +425,7 @@ typedef struct {
|
||||
|
||||
/** Modular substraction
|
||||
@param a The first source
|
||||
@param b The second source
|
||||
@param b The second source
|
||||
@param c The modulus
|
||||
@param d The destination (a - b mod c)
|
||||
@return CRYPT_OK on success
|
||||
|
@ -1,9 +1,9 @@
|
||||
/* ---- LTC_BASE64 Routines ---- */
|
||||
#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);
|
||||
|
||||
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);
|
||||
#endif
|
||||
|
||||
|
@ -32,19 +32,19 @@ typedef struct Rsa_key {
|
||||
/** Type of key, PK_PRIVATE or PK_PUBLIC */
|
||||
int type;
|
||||
/** The public exponent */
|
||||
void *e;
|
||||
void *e;
|
||||
/** The private exponent */
|
||||
void *d;
|
||||
void *d;
|
||||
/** The modulus */
|
||||
void *N;
|
||||
void *N;
|
||||
/** The p factor of N */
|
||||
void *p;
|
||||
void *p;
|
||||
/** The q factor of N */
|
||||
void *q;
|
||||
void *q;
|
||||
/** The 1/q mod p CRT param */
|
||||
void *qP;
|
||||
void *qP;
|
||||
/** The d mod (p - 1) CRT param */
|
||||
void *dP;
|
||||
void *dP;
|
||||
/** The d mod (q - 1) CRT param */
|
||||
void *dQ;
|
||||
} rsa_key;
|
||||
@ -98,7 +98,7 @@ int rsa_verify_hash_ex(const unsigned char *sig, unsigned long siglen,
|
||||
/* LTC_PKCS #1 import/export */
|
||||
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);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
/* ---- Katja ---- */
|
||||
@ -113,17 +113,17 @@ typedef struct KAT_key {
|
||||
/** Type of key, PK_PRIVATE or PK_PUBLIC */
|
||||
int type;
|
||||
/** The private exponent */
|
||||
void *d;
|
||||
void *d;
|
||||
/** The modulus */
|
||||
void *N;
|
||||
void *N;
|
||||
/** The p factor of N */
|
||||
void *p;
|
||||
void *p;
|
||||
/** The q factor of N */
|
||||
void *q;
|
||||
void *q;
|
||||
/** The 1/q mod p CRT param */
|
||||
void *qP;
|
||||
void *qP;
|
||||
/** The d mod (p - 1) CRT param */
|
||||
void *dP;
|
||||
void *dP;
|
||||
/** The d mod (q - 1) CRT param */
|
||||
void *dQ;
|
||||
/** The pq param */
|
||||
@ -143,9 +143,9 @@ int katja_encrypt_key(const unsigned char *in, unsigned long inlen,
|
||||
unsigned char *out, unsigned long *outlen,
|
||||
const unsigned char *lparam, unsigned long lparamlen,
|
||||
prng_state *prng, int prng_idx, int hash_idx, katja_key *key);
|
||||
|
||||
|
||||
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,
|
||||
int hash_idx, int *stat,
|
||||
katja_key *key);
|
||||
@ -153,11 +153,11 @@ int katja_decrypt_key(const unsigned char *in, unsigned long inlen,
|
||||
/* LTC_PKCS #1 import/export */
|
||||
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);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
/* ---- DH Routines ---- */
|
||||
#ifdef MDH
|
||||
#ifdef MDH
|
||||
|
||||
typedef struct Dh_key {
|
||||
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);
|
||||
|
||||
int dh_encrypt_key(const unsigned char *in, unsigned long keylen,
|
||||
unsigned char *out, unsigned long *outlen,
|
||||
prng_state *prng, int wprng, int hash,
|
||||
unsigned char *out, unsigned long *outlen,
|
||||
prng_state *prng, int wprng, int hash,
|
||||
dh_key *key);
|
||||
|
||||
int dh_decrypt_key(const unsigned char *in, unsigned long inlen,
|
||||
unsigned char *out, unsigned long *outlen,
|
||||
int dh_decrypt_key(const unsigned char *in, unsigned long inlen,
|
||||
unsigned char *out, unsigned long *outlen,
|
||||
dh_key *key);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
|
||||
@ -214,7 +214,7 @@ typedef struct {
|
||||
int size;
|
||||
|
||||
/** name of curve */
|
||||
char *name;
|
||||
char *name;
|
||||
|
||||
/** The prime that defines the field the curve is in (encoded in hex) */
|
||||
char *prime;
|
||||
@ -224,10 +224,10 @@ typedef struct {
|
||||
|
||||
/** The order of the curve (hex) */
|
||||
char *order;
|
||||
|
||||
|
||||
/** The x co-ordinate of the base point on the curve (hex) */
|
||||
char *Gx;
|
||||
|
||||
|
||||
/** The y co-ordinate of the base point on the curve (hex) */
|
||||
char *Gy;
|
||||
} 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_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);
|
||||
|
||||
int ecc_encrypt_key(const unsigned char *in, unsigned long inlen,
|
||||
unsigned char *out, unsigned long *outlen,
|
||||
prng_state *prng, int wprng, int hash,
|
||||
unsigned char *out, unsigned long *outlen,
|
||||
prng_state *prng, int wprng, int hash,
|
||||
ecc_key *key);
|
||||
|
||||
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);
|
||||
|
||||
int ecc_sign_hash(const unsigned char *in, unsigned long inlen,
|
||||
unsigned char *out, unsigned long *outlen,
|
||||
int ecc_sign_hash(const unsigned char *in, unsigned long inlen,
|
||||
unsigned char *out, unsigned long *outlen,
|
||||
prng_state *prng, int wprng, ecc_key *key);
|
||||
|
||||
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);
|
||||
|
||||
/* low level functions */
|
||||
@ -365,7 +365,7 @@ int ltc_ecc_map(ecc_point *P, void *modulus, void *mp);
|
||||
/** DSA key structure */
|
||||
typedef struct {
|
||||
/** The key type, PK_PRIVATE or PK_PUBLIC */
|
||||
int type;
|
||||
int type;
|
||||
|
||||
/** The order of the sub-group used in octets */
|
||||
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);
|
||||
|
||||
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 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 dsa_encrypt_key(const unsigned char *in, unsigned long inlen,
|
||||
unsigned char *out, unsigned long *outlen,
|
||||
prng_state *prng, int wprng, int hash,
|
||||
unsigned char *out, unsigned long *outlen,
|
||||
prng_state *prng, int wprng, int hash,
|
||||
dsa_key *key);
|
||||
|
||||
|
||||
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);
|
||||
|
||||
|
||||
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_verify_key(dsa_key *key, int *stat);
|
||||
@ -475,12 +475,12 @@ typedef struct ltc_asn1_list_ {
|
||||
/* SEQUENCE */
|
||||
int der_encode_sequence_ex(ltc_asn1_list *list, unsigned long inlen,
|
||||
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,
|
||||
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)
|
||||
|
||||
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,
|
||||
unsigned char *out, unsigned long *outlen);
|
||||
|
||||
|
||||
/* VA list handy helpers with triplets of <type, size, data> */
|
||||
int der_encode_sequence_multi(unsigned char *out, unsigned long *outlen, ...);
|
||||
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 */
|
||||
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);
|
||||
int der_decode_boolean(const unsigned char *in, unsigned long inlen,
|
||||
int *out);
|
||||
int *out);
|
||||
/* INTEGER */
|
||||
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);
|
||||
@ -584,7 +584,7 @@ int der_printable_char_encode(int c);
|
||||
int der_printable_value_decode(int v);
|
||||
|
||||
/* 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>
|
||||
#else
|
||||
typedef ulong32 wchar_t;
|
||||
@ -616,7 +616,7 @@ typedef struct {
|
||||
off_mm; /* timezone offset minutes */
|
||||
} ltc_utctime;
|
||||
|
||||
int der_encode_utctime(ltc_utctime *utctime,
|
||||
int der_encode_utctime(ltc_utctime *utctime,
|
||||
unsigned char *out, unsigned long *outlen);
|
||||
|
||||
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);
|
||||
|
||||
/* *** 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,
|
||||
int block_type,
|
||||
unsigned long modulus_bitlen,
|
||||
prng_state *prng,
|
||||
prng_state *prng,
|
||||
int prng_idx,
|
||||
unsigned char *out,
|
||||
unsigned char *out,
|
||||
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,
|
||||
int block_type,
|
||||
unsigned long modulus_bitlen,
|
||||
unsigned char *out,
|
||||
unsigned char *out,
|
||||
unsigned long *outlen,
|
||||
int *is_valid);
|
||||
|
||||
@ -55,7 +55,7 @@ int pkcs_1_oaep_decode(const unsigned char *msg, unsigned long msglen,
|
||||
int *res);
|
||||
|
||||
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,
|
||||
unsigned long modulus_bitlen,
|
||||
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
|
||||
|
||||
/* Algorithm #1 (old) */
|
||||
int pkcs_5_alg1(const unsigned char *password, unsigned long password_len,
|
||||
const unsigned char *salt,
|
||||
int pkcs_5_alg1(const unsigned char *password, unsigned long password_len,
|
||||
const unsigned char *salt,
|
||||
int iteration_count, int hash_idx,
|
||||
unsigned char *out, unsigned long *outlen);
|
||||
|
||||
/* 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,
|
||||
int iteration_count, int hash_idx,
|
||||
unsigned char *out, unsigned long *outlen);
|
||||
|
@ -23,10 +23,10 @@ struct fortuna_prng {
|
||||
|
||||
unsigned char K[32], /* the current key */
|
||||
IV[16]; /* IV for CTR mode */
|
||||
|
||||
|
||||
unsigned long pool_idx, /* current pool we will add to */
|
||||
pool0_len, /* length of 0'th pool */
|
||||
wd;
|
||||
wd;
|
||||
|
||||
ulong64 reset_cnt; /* number of times we have reset */
|
||||
LTC_MUTEX_TYPE(prng_lock)
|
||||
@ -36,14 +36,14 @@ struct fortuna_prng {
|
||||
#ifdef LTC_SOBER128
|
||||
struct sober128_prng {
|
||||
ulong32 R[17], /* Working storage for the shift register */
|
||||
initR[17], /* saved register contents */
|
||||
initR[17], /* saved register contents */
|
||||
konst, /* key dependent constant */
|
||||
sbuf; /* partial word encryption buffer */
|
||||
|
||||
int nbuf, /* number of part-word stream bits buffered */
|
||||
flag, /* first add_entropy call or not? */
|
||||
set; /* did we call add_entropy to set key? */
|
||||
|
||||
|
||||
};
|
||||
#endif
|
||||
|
||||
@ -98,7 +98,7 @@ extern struct ltc_prng_descriptor {
|
||||
@return CRYPT_OK if successful
|
||||
*/
|
||||
int (*done)(prng_state *prng);
|
||||
/** Export a PRNG state
|
||||
/** Export a PRNG state
|
||||
@param out [out] The destination for the state
|
||||
@param outlen [in/out] The max size and resulting size of the PRNG state
|
||||
@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
|
||||
* might not work on all platforms as planned
|
||||
*/
|
||||
unsigned long rng_get_bytes(unsigned char *out,
|
||||
unsigned long outlen,
|
||||
unsigned long rng_get_bytes(unsigned char *out,
|
||||
unsigned long outlen,
|
||||
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