trim trailing spaces/clean up
This commit is contained in:
parent
d78aa37c10
commit
8e7777b554
@ -15,7 +15,7 @@
|
|||||||
CCM support, process a block of memory, Tom St Denis
|
CCM support, process a block of memory, Tom St Denis
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef CCM_MODE
|
#ifdef LTC_CCM_MODE
|
||||||
|
|
||||||
/**
|
/**
|
||||||
CCM encrypt/decrypt and produce an authentication tag
|
CCM encrypt/decrypt and produce an authentication tag
|
||||||
@ -250,7 +250,7 @@ if (CTR == NULL) {
|
|||||||
if (direction == CCM_ENCRYPT) {
|
if (direction == CCM_ENCRYPT) {
|
||||||
for (; y < (ptlen & ~15); y += 16) {
|
for (; y < (ptlen & ~15); y += 16) {
|
||||||
/* increment the ctr? */
|
/* increment the ctr? */
|
||||||
for (z = 15; z > 15-ctrwidth; z--) {
|
for (z = 15; (int)z > (int)(15-ctrwidth); z--) {
|
||||||
ctr[z] = (ctr[z] + 1) & 255;
|
ctr[z] = (ctr[z] + 1) & 255;
|
||||||
if (ctr[z]) break;
|
if (ctr[z]) break;
|
||||||
}
|
}
|
||||||
@ -270,7 +270,7 @@ if (CTR == NULL) {
|
|||||||
} else {
|
} else {
|
||||||
for (; y < (ptlen & ~15); y += 16) {
|
for (; y < (ptlen & ~15); y += 16) {
|
||||||
/* increment the ctr? */
|
/* increment the ctr? */
|
||||||
for (z = 15; z > 15-ctrwidth; z--) {
|
for (z = 15; (int)z > (int)(15-ctrwidth); z--) {
|
||||||
ctr[z] = (ctr[z] + 1) & 255;
|
ctr[z] = (ctr[z] + 1) & 255;
|
||||||
if (ctr[z]) break;
|
if (ctr[z]) break;
|
||||||
}
|
}
|
||||||
@ -294,7 +294,7 @@ if (CTR == NULL) {
|
|||||||
for (; y < ptlen; y++) {
|
for (; y < ptlen; y++) {
|
||||||
/* increment the ctr? */
|
/* increment the ctr? */
|
||||||
if (CTRlen == 16) {
|
if (CTRlen == 16) {
|
||||||
for (z = 15; z > 15-ctrwidth; z--) {
|
for (z = 15; (int)z > (int)(15-ctrwidth); z--) {
|
||||||
ctr[z] = (ctr[z] + 1) & 255;
|
ctr[z] = (ctr[z] + 1) & 255;
|
||||||
if (ctr[z]) break;
|
if (ctr[z]) break;
|
||||||
}
|
}
|
||||||
@ -356,7 +356,7 @@ if (CTR == NULL) {
|
|||||||
*taglen = x;
|
*taglen = x;
|
||||||
|
|
||||||
if (CTR != NULL) {
|
if (CTR != NULL) {
|
||||||
for (z = 15; z > 15-ctrwidth; z--) {
|
for (z = 15; (int)z > (int)(15-ctrwidth); z--) {
|
||||||
ctrcopy[z] = (ctrcopy[z] + 1) & 255;
|
ctrcopy[z] = (ctrcopy[z] + 1) & 255;
|
||||||
if (ctrcopy[z]) break;
|
if (ctrcopy[z]) break;
|
||||||
}
|
}
|
||||||
|
@ -326,7 +326,7 @@
|
|||||||
/* Include Diffie-Hellman support */
|
/* Include Diffie-Hellman support */
|
||||||
#ifndef GMP_DESC
|
#ifndef GMP_DESC
|
||||||
/* is_prime fails for GMP */
|
/* is_prime fails for GMP */
|
||||||
#define MDH
|
#define LTC_MDH
|
||||||
/* Supported Key Sizes */
|
/* Supported Key Sizes */
|
||||||
#define DH768
|
#define DH768
|
||||||
#define DH1024
|
#define DH1024
|
||||||
@ -367,7 +367,7 @@
|
|||||||
|
|
||||||
#endif /* LTC_NO_PK */
|
#endif /* LTC_NO_PK */
|
||||||
|
|
||||||
/* LTC_PKCS #1 (RSA) and #5 (Password Handling) stuff */
|
/* PKCS #1 (RSA) and #5 (Password Handling) stuff */
|
||||||
#ifndef LTC_NO_PKCS
|
#ifndef LTC_NO_PKCS
|
||||||
|
|
||||||
#define LTC_PKCS_1
|
#define LTC_PKCS_1
|
||||||
|
@ -27,7 +27,7 @@ int pk_get_oid(int pk, oid_st *st);
|
|||||||
#define MIN_RSA_SIZE 1024
|
#define MIN_RSA_SIZE 1024
|
||||||
#define MAX_RSA_SIZE 4096
|
#define MAX_RSA_SIZE 4096
|
||||||
|
|
||||||
/** RSA LTC_PKCS style key */
|
/** RSA PKCS style key */
|
||||||
typedef struct Rsa_key {
|
typedef struct Rsa_key {
|
||||||
/** Type of key, PK_PRIVATE or PK_PUBLIC */
|
/** Type of key, PK_PRIVATE or PK_PUBLIC */
|
||||||
int type;
|
int type;
|
||||||
@ -59,7 +59,7 @@ int rsa_exptmod(const unsigned char *in, unsigned long inlen,
|
|||||||
|
|
||||||
void rsa_free(rsa_key *key);
|
void rsa_free(rsa_key *key);
|
||||||
|
|
||||||
/* These use LTC_PKCS #1 v2.0 padding */
|
/* These use PKCS #1 v2.0 padding */
|
||||||
#define rsa_encrypt_key(_in, _inlen, _out, _outlen, _lparam, _lparamlen, _prng, _prng_idx, _hash_idx, _key) \
|
#define rsa_encrypt_key(_in, _inlen, _out, _outlen, _lparam, _lparamlen, _prng, _prng_idx, _hash_idx, _key) \
|
||||||
rsa_encrypt_key_ex(_in, _inlen, _out, _outlen, _lparam, _lparamlen, _prng, _prng_idx, _hash_idx, LTC_PKCS_1_OAEP, _key)
|
rsa_encrypt_key_ex(_in, _inlen, _out, _outlen, _lparam, _lparamlen, _prng, _prng_idx, _hash_idx, LTC_PKCS_1_OAEP, _key)
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ void rsa_free(rsa_key *key);
|
|||||||
#define rsa_sign_saltlen_get_max(_hash_idx, _key) \
|
#define rsa_sign_saltlen_get_max(_hash_idx, _key) \
|
||||||
rsa_sign_saltlen_get_max_ex(LTC_PKCS_1_PSS, _hash_idx, _key)
|
rsa_sign_saltlen_get_max_ex(LTC_PKCS_1_PSS, _hash_idx, _key)
|
||||||
|
|
||||||
/* These can be switched between LTC_PKCS #1 v2.x and LTC_PKCS #1 v1.5 paddings */
|
/* These can be switched between PKCS #1 v2.x and PKCS #1 v1.5 paddings */
|
||||||
int rsa_encrypt_key_ex(const unsigned char *in, unsigned long inlen,
|
int rsa_encrypt_key_ex(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,
|
||||||
@ -102,7 +102,7 @@ int rsa_verify_hash_ex(const unsigned char *sig, unsigned long siglen,
|
|||||||
|
|
||||||
int rsa_sign_saltlen_get_max_ex(int padding, int hash_idx, rsa_key *key);
|
int rsa_sign_saltlen_get_max_ex(int padding, int hash_idx, rsa_key *key);
|
||||||
|
|
||||||
/* LTC_PKCS #1 import/export */
|
/* 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);
|
||||||
|
|
||||||
@ -115,7 +115,7 @@ int rsa_import(const unsigned char *in, unsigned long inlen, rsa_key *key);
|
|||||||
#define MIN_KAT_SIZE 1024
|
#define MIN_KAT_SIZE 1024
|
||||||
#define MAX_KAT_SIZE 4096
|
#define MAX_KAT_SIZE 4096
|
||||||
|
|
||||||
/** Katja LTC_PKCS style key */
|
/** Katja PKCS style key */
|
||||||
typedef struct KAT_key {
|
typedef struct KAT_key {
|
||||||
/** Type of key, PK_PRIVATE or PK_PUBLIC */
|
/** Type of key, PK_PRIVATE or PK_PUBLIC */
|
||||||
int type;
|
int type;
|
||||||
@ -145,7 +145,7 @@ int katja_exptmod(const unsigned char *in, unsigned long inlen,
|
|||||||
|
|
||||||
void katja_free(katja_key *key);
|
void katja_free(katja_key *key);
|
||||||
|
|
||||||
/* These use LTC_PKCS #1 v2.0 padding */
|
/* These use PKCS #1 v2.0 padding */
|
||||||
int katja_encrypt_key(const unsigned char *in, unsigned long inlen,
|
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,
|
||||||
@ -157,7 +157,7 @@ int katja_decrypt_key(const unsigned char *in, unsigned long inlen,
|
|||||||
int hash_idx, int *stat,
|
int hash_idx, int *stat,
|
||||||
katja_key *key);
|
katja_key *key);
|
||||||
|
|
||||||
/* LTC_PKCS #1 import/export */
|
/* 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);
|
||||||
|
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
/* LTC_PKCS Header Info */
|
/* PKCS Header Info */
|
||||||
|
|
||||||
/* ===> LTC_PKCS #1 -- RSA Cryptography <=== */
|
/* ===> PKCS #1 -- RSA Cryptography <=== */
|
||||||
#ifdef LTC_PKCS_1
|
#ifdef LTC_PKCS_1
|
||||||
|
|
||||||
enum ltc_pkcs_1_v1_5_blocks
|
enum ltc_pkcs_1_v1_5_blocks
|
||||||
{
|
{
|
||||||
LTC_PKCS_1_EMSA = 1, /* Block type 1 (LTC_PKCS #1 v1.5 signature padding) */
|
LTC_PKCS_1_EMSA = 1, /* Block type 1 (PKCS #1 v1.5 signature padding) */
|
||||||
LTC_PKCS_1_EME = 2 /* Block type 2 (LTC_PKCS #1 v1.5 encryption padding) */
|
LTC_PKCS_1_EME = 2 /* Block type 2 (PKCS #1 v1.5 encryption padding) */
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ltc_pkcs_1_paddings
|
enum ltc_pkcs_1_paddings
|
||||||
{
|
{
|
||||||
LTC_PKCS_1_V1_5 = 1, /* LTC_PKCS #1 v1.5 padding (\sa ltc_pkcs_1_v1_5_blocks) */
|
LTC_PKCS_1_V1_5 = 1, /* PKCS #1 v1.5 padding (\sa ltc_pkcs_1_v1_5_blocks) */
|
||||||
LTC_PKCS_1_OAEP = 2, /* LTC_PKCS #1 v2.0 encryption padding */
|
LTC_PKCS_1_OAEP = 2, /* PKCS #1 v2.0 encryption padding */
|
||||||
LTC_PKCS_1_PSS = 3 /* LTC_PKCS #1 v2.1 signature padding */
|
LTC_PKCS_1_PSS = 3 /* PKCS #1 v2.1 signature padding */
|
||||||
};
|
};
|
||||||
|
|
||||||
int pkcs_1_mgf1( int hash_idx,
|
int pkcs_1_mgf1( int hash_idx,
|
||||||
@ -67,7 +67,7 @@ int pkcs_1_pss_decode(const unsigned char *msghash, unsigned long msghashlen,
|
|||||||
|
|
||||||
#endif /* LTC_PKCS_1 */
|
#endif /* LTC_PKCS_1 */
|
||||||
|
|
||||||
/* ===> LTC_PKCS #5 -- Password Based Cryptography <=== */
|
/* ===> PKCS #5 -- Password Based Cryptography <=== */
|
||||||
#ifdef LTC_PKCS_5
|
#ifdef LTC_PKCS_5
|
||||||
|
|
||||||
/* Algorithm #1 (old) */
|
/* Algorithm #1 (old) */
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
@file hmac_done.c
|
@file hmac_done.c
|
||||||
LTC_HMAC support, terminate stream, Tom St Denis/Dobes Vandermeer
|
HMAC support, terminate stream, Tom St Denis/Dobes Vandermeer
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef LTC_HMAC
|
#ifdef LTC_HMAC
|
||||||
@ -20,10 +20,10 @@
|
|||||||
#define LTC_HMAC_BLOCKSIZE hash_descriptor[hash].blocksize
|
#define LTC_HMAC_BLOCKSIZE hash_descriptor[hash].blocksize
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Terminate an LTC_HMAC session
|
Terminate an HMAC session
|
||||||
@param hmac The LTC_HMAC state
|
@param hmac The HMAC state
|
||||||
@param out [out] The destination of the LTC_HMAC authentication tag
|
@param out [out] The destination of the HMAC authentication tag
|
||||||
@param outlen [in/out] The max size and resulting size of the LTC_HMAC authentication tag
|
@param outlen [in/out] The max size and resulting size of the HMAC authentication tag
|
||||||
@return CRYPT_OK if successful
|
@return CRYPT_OK if successful
|
||||||
*/
|
*/
|
||||||
int hmac_done(hmac_state *hmac, unsigned char *out, unsigned long *outlen)
|
int hmac_done(hmac_state *hmac, unsigned char *out, unsigned long *outlen)
|
||||||
@ -57,12 +57,12 @@ int hmac_done(hmac_state *hmac, unsigned char *out, unsigned long *outlen)
|
|||||||
return CRYPT_MEM;
|
return CRYPT_MEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the hash of the first LTC_HMAC vector plus the data */
|
/* Get the hash of the first HMAC vector plus the data */
|
||||||
if ((err = hash_descriptor[hash].done(&hmac->md, isha)) != CRYPT_OK) {
|
if ((err = hash_descriptor[hash].done(&hmac->md, isha)) != CRYPT_OK) {
|
||||||
goto LBL_ERR;
|
goto LBL_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create the second LTC_HMAC vector vector for step (3) */
|
/* Create the second HMAC vector vector for step (3) */
|
||||||
for(i=0; i < LTC_HMAC_BLOCKSIZE; i++) {
|
for(i=0; i < LTC_HMAC_BLOCKSIZE; i++) {
|
||||||
buf[i] = hmac->key[i] ^ 0x5C;
|
buf[i] = hmac->key[i] ^ 0x5C;
|
||||||
}
|
}
|
||||||
|
@ -12,18 +12,18 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
@file hmac_file.c
|
@file hmac_file.c
|
||||||
LTC_HMAC support, process a file, Tom St Denis/Dobes Vandermeer
|
HMAC support, process a file, Tom St Denis/Dobes Vandermeer
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef LTC_HMAC
|
#ifdef LTC_HMAC
|
||||||
|
|
||||||
/**
|
/**
|
||||||
LTC_HMAC a file
|
HMAC a file
|
||||||
@param hash The index of the hash you wish to use
|
@param hash The index of the hash you wish to use
|
||||||
@param fname The name of the file you wish to LTC_HMAC
|
@param fname The name of the file you wish to HMAC
|
||||||
@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 out [out] The LTC_HMAC authentication tag
|
@param out [out] The HMAC authentication tag
|
||||||
@param outlen [in/out] The max size and resulting size of the authentication tag
|
@param outlen [in/out] The max size and resulting size of the authentication tag
|
||||||
@return CRYPT_OK if successful, CRYPT_NOP if file support has been disabled
|
@return CRYPT_OK if successful, CRYPT_NOP if file support has been disabled
|
||||||
*/
|
*/
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
@file hmac_init.c
|
@file hmac_init.c
|
||||||
LTC_HMAC support, initialize state, Tom St Denis/Dobes Vandermeer
|
HMAC support, initialize state, Tom St Denis/Dobes Vandermeer
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef LTC_HMAC
|
#ifdef LTC_HMAC
|
||||||
@ -20,8 +20,8 @@
|
|||||||
#define LTC_HMAC_BLOCKSIZE hash_descriptor[hash].blocksize
|
#define LTC_HMAC_BLOCKSIZE hash_descriptor[hash].blocksize
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Initialize an LTC_HMAC context.
|
Initialize an HMAC context.
|
||||||
@param hmac The LTC_HMAC state
|
@param hmac The HMAC state
|
||||||
@param hash The index of the hash you want to use
|
@param hash The index of the hash you want to use
|
||||||
@param key The secret key
|
@param key The secret key
|
||||||
@param keylen The length of the secret key (octets)
|
@param keylen The length of the secret key (octets)
|
||||||
|
@ -12,18 +12,18 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
@file hmac_memory.c
|
@file hmac_memory.c
|
||||||
LTC_HMAC support, process a block of memory, Tom St Denis/Dobes Vandermeer
|
HMAC support, process a block of memory, Tom St Denis/Dobes Vandermeer
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef LTC_HMAC
|
#ifdef LTC_HMAC
|
||||||
|
|
||||||
/**
|
/**
|
||||||
LTC_HMAC a block of memory to produce the authentication tag
|
HMAC a block of memory to produce the authentication tag
|
||||||
@param hash The index of the hash to use
|
@param hash The index of the hash to use
|
||||||
@param key The secret key
|
@param key The secret key
|
||||||
@param keylen The length of the secret key (octets)
|
@param keylen The length of the secret key (octets)
|
||||||
@param in The data to LTC_HMAC
|
@param in The data to HMAC
|
||||||
@param inlen The length of the data to LTC_HMAC (octets)
|
@param inlen The length of the data to HMAC (octets)
|
||||||
@param out [out] Destination of the authentication tag
|
@param out [out] Destination of the authentication tag
|
||||||
@param outlen [in/out] Max size and resulting size of authentication tag
|
@param outlen [in/out] Max size and resulting size of authentication tag
|
||||||
@return CRYPT_OK if successful
|
@return CRYPT_OK if successful
|
||||||
|
@ -13,21 +13,21 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
@file hmac_memory_multi.c
|
@file hmac_memory_multi.c
|
||||||
LTC_HMAC support, process multiple blocks of memory, Tom St Denis/Dobes Vandermeer
|
HMAC support, process multiple blocks of memory, Tom St Denis/Dobes Vandermeer
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef LTC_HMAC
|
#ifdef LTC_HMAC
|
||||||
|
|
||||||
/**
|
/**
|
||||||
LTC_HMAC multiple blocks of memory to produce the authentication tag
|
HMAC multiple blocks of memory to produce the authentication tag
|
||||||
@param hash The index of the hash to use
|
@param hash The index of the hash to use
|
||||||
@param key The secret key
|
@param key The secret key
|
||||||
@param keylen The length of the secret key (octets)
|
@param keylen The length of the secret key (octets)
|
||||||
@param out [out] Destination of the authentication tag
|
@param out [out] Destination of the authentication tag
|
||||||
@param outlen [in/out] Max size and resulting size of authentication tag
|
@param outlen [in/out] Max size and resulting size of authentication tag
|
||||||
@param in The data to LTC_HMAC
|
@param in The data to HMAC
|
||||||
@param inlen The length of the data to LTC_HMAC (octets)
|
@param inlen The length of the data to HMAC (octets)
|
||||||
@param ... tuples of (data,len) pairs to LTC_HMAC, terminated with a (NULL,x) (x=don't care)
|
@param ... tuples of (data,len) pairs to HMAC, terminated with a (NULL,x) (x=don't care)
|
||||||
@return CRYPT_OK if successful
|
@return CRYPT_OK if successful
|
||||||
*/
|
*/
|
||||||
int hmac_memory_multi(int hash,
|
int hmac_memory_multi(int hash,
|
||||||
|
@ -12,16 +12,16 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
@file hmac_process.c
|
@file hmac_process.c
|
||||||
LTC_HMAC support, process data, Tom St Denis/Dobes Vandermeer
|
HMAC support, process data, Tom St Denis/Dobes Vandermeer
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef LTC_HMAC
|
#ifdef LTC_HMAC
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Process data through LTC_HMAC
|
Process data through HMAC
|
||||||
@param hmac The hmac state
|
@param hmac The hmac state
|
||||||
@param in The data to send through LTC_HMAC
|
@param in The data to send through HMAC
|
||||||
@param inlen The length of the data to LTC_HMAC (octets)
|
@param inlen The length of the data to HMAC (octets)
|
||||||
@return CRYPT_OK if successful
|
@return CRYPT_OK if successful
|
||||||
*/
|
*/
|
||||||
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)
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
@file hmac_test.c
|
@file hmac_test.c
|
||||||
LTC_HMAC support, self-test, Tom St Denis/Dobes Vandermeer
|
HMAC support, self-test, Tom St Denis/Dobes Vandermeer
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef LTC_HMAC
|
#ifdef LTC_HMAC
|
||||||
@ -27,11 +27,11 @@ Request for Comments: 2202 IBM
|
|||||||
Category: Informational R. Glenn
|
Category: Informational R. Glenn
|
||||||
NIST
|
NIST
|
||||||
September 1997
|
September 1997
|
||||||
Test Cases for LTC_HMAC-LTC_MD5 and LTC_HMAC-LTC_SHA-1
|
Test Cases for HMAC-MD5 and HMAC-SHA-1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
LTC_HMAC self-test
|
HMAC self-test
|
||||||
@return CRYPT_OK if successful, CRYPT_NOP if tests have been disabled.
|
@return CRYPT_OK if successful, CRYPT_NOP if tests have been disabled.
|
||||||
*/
|
*/
|
||||||
int hmac_test(void)
|
int hmac_test(void)
|
||||||
@ -52,7 +52,7 @@ int hmac_test(void)
|
|||||||
unsigned char digest[MAXBLOCKSIZE];
|
unsigned char digest[MAXBLOCKSIZE];
|
||||||
} cases[] = {
|
} cases[] = {
|
||||||
/*
|
/*
|
||||||
3. Test Cases for LTC_HMAC-LTC_SHA-1
|
3. Test Cases for HMAC-SHA-1
|
||||||
|
|
||||||
test_case = 1
|
test_case = 1
|
||||||
key = 0x0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c
|
key = 0x0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c
|
||||||
@ -118,7 +118,7 @@ int hmac_test(void)
|
|||||||
0x6b, 0xba, 0xa7, 0x96, 0x5c, 0x78, 0x08, 0xbb, 0xff, 0x1a, 0x91} },
|
0x6b, 0xba, 0xa7, 0x96, 0x5c, 0x78, 0x08, 0xbb, 0xff, 0x1a, 0x91} },
|
||||||
|
|
||||||
/*
|
/*
|
||||||
2. Test Cases for LTC_HMAC-LTC_MD5
|
2. Test Cases for HMAC-MD5
|
||||||
|
|
||||||
test_case = 1
|
test_case = 1
|
||||||
key = 0x0b 0b 0b 0b
|
key = 0x0b 0b 0b 0b
|
||||||
@ -272,7 +272,7 @@ Key First"
|
|||||||
outlen = sizeof(digest);
|
outlen = sizeof(digest);
|
||||||
if((err = hmac_memory(hash, cases[i].key, cases[i].keylen, cases[i].data, cases[i].datalen, digest, &outlen)) != CRYPT_OK) {
|
if((err = hmac_memory(hash, cases[i].key, cases[i].keylen, cases[i].data, cases[i].datalen, digest, &outlen)) != CRYPT_OK) {
|
||||||
#if 0
|
#if 0
|
||||||
printf("LTC_HMAC-%s test #%d, %s\n", cases[i].algo, cases[i].num, error_to_string(err));
|
printf("HMAC-%s test #%d, %s\n", cases[i].algo, cases[i].num, error_to_string(err));
|
||||||
#endif
|
#endif
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@ -294,7 +294,7 @@ Key First"
|
|||||||
return CRYPT_ERROR;
|
return CRYPT_ERROR;
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
/* printf("LTC_HMAC-%s test #%d: Passed\n", cases[i].algo, cases[i].num); */
|
/* printf("HMAC-%s test #%d: Passed\n", cases[i].algo, cases[i].num); */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,14 +12,14 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
@file omac_done.c
|
@file omac_done.c
|
||||||
LTC_OMAC1 support, terminate a stream, Tom St Denis
|
OMAC1 support, terminate a stream, Tom St Denis
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef LTC_OMAC
|
#ifdef LTC_OMAC
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Terminate an LTC_OMAC stream
|
Terminate an OMAC stream
|
||||||
@param omac The LTC_OMAC state
|
@param omac The OMAC state
|
||||||
@param out [out] Destination for the authentication tag
|
@param out [out] Destination for the authentication tag
|
||||||
@param outlen [in/out] The max size and resulting size of the authentication tag
|
@param outlen [in/out] The max size and resulting size of the authentication tag
|
||||||
@return CRYPT_OK if successful
|
@return CRYPT_OK if successful
|
||||||
|
@ -12,17 +12,17 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
@file omac_file.c
|
@file omac_file.c
|
||||||
LTC_OMAC1 support, process a file, Tom St Denis
|
OMAC1 support, process a file, Tom St Denis
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef LTC_OMAC
|
#ifdef LTC_OMAC
|
||||||
|
|
||||||
/**
|
/**
|
||||||
LTC_OMAC a file
|
OMAC a file
|
||||||
@param cipher The index of the cipher desired
|
@param cipher The index of the cipher desired
|
||||||
@param key The secret key
|
@param key The secret key
|
||||||
@param keylen The length of the secret key (octets)
|
@param keylen The length of the secret key (octets)
|
||||||
@param filename The name of the file you wish to LTC_OMAC
|
@param filename The name of the file you wish to OMAC
|
||||||
@param out [out] Where the authentication tag is to be stored
|
@param out [out] Where the authentication tag is to be stored
|
||||||
@param outlen [in/out] The max size and resulting size of the authentication tag
|
@param outlen [in/out] The max size and resulting size of the authentication tag
|
||||||
@return CRYPT_OK if successful, CRYPT_NOP if file support has been disabled
|
@return CRYPT_OK if successful, CRYPT_NOP if file support has been disabled
|
||||||
|
@ -12,15 +12,15 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
@file omac_init.c
|
@file omac_init.c
|
||||||
LTC_OMAC1 support, initialize state, by Tom St Denis
|
OMAC1 support, initialize state, by Tom St Denis
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifdef LTC_OMAC
|
#ifdef LTC_OMAC
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Initialize an LTC_OMAC state
|
Initialize an OMAC state
|
||||||
@param omac The LTC_OMAC state to initialize
|
@param omac The OMAC state to initialize
|
||||||
@param cipher The index of the desired cipher
|
@param cipher The index of the desired cipher
|
||||||
@param key The secret key
|
@param key The secret key
|
||||||
@param keylen The length of the secret key (octets)
|
@param keylen The length of the secret key (octets)
|
||||||
|
@ -12,18 +12,18 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
@file omac_memory.c
|
@file omac_memory.c
|
||||||
LTC_OMAC1 support, process a block of memory, Tom St Denis
|
OMAC1 support, process a block of memory, Tom St Denis
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef LTC_OMAC
|
#ifdef LTC_OMAC
|
||||||
|
|
||||||
/**
|
/**
|
||||||
LTC_OMAC a block of memory
|
OMAC a block of memory
|
||||||
@param cipher The index of the desired cipher
|
@param cipher The index of the desired cipher
|
||||||
@param key The secret key
|
@param key The secret key
|
||||||
@param keylen The length of the secret key (octets)
|
@param keylen The length of the secret key (octets)
|
||||||
@param in The data to send through LTC_OMAC
|
@param in The data to send through OMAC
|
||||||
@param inlen The length of the data to send through LTC_OMAC (octets)
|
@param inlen The length of the data to send through OMAC (octets)
|
||||||
@param out [out] The destination of the authentication tag
|
@param out [out] The destination of the authentication tag
|
||||||
@param outlen [in/out] The max size and resulting size of the authentication tag (octets)
|
@param outlen [in/out] The max size and resulting size of the authentication tag (octets)
|
||||||
@return CRYPT_OK if successful
|
@return CRYPT_OK if successful
|
||||||
|
@ -13,21 +13,21 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
@file omac_memory_multi.c
|
@file omac_memory_multi.c
|
||||||
LTC_OMAC1 support, process multiple blocks of memory, Tom St Denis
|
OMAC1 support, process multiple blocks of memory, Tom St Denis
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef LTC_OMAC
|
#ifdef LTC_OMAC
|
||||||
|
|
||||||
/**
|
/**
|
||||||
LTC_OMAC multiple blocks of memory
|
OMAC multiple blocks of memory
|
||||||
@param cipher The index of the desired cipher
|
@param cipher The index of the desired cipher
|
||||||
@param key The secret key
|
@param key The secret key
|
||||||
@param keylen The length of the secret key (octets)
|
@param keylen The length of the secret key (octets)
|
||||||
@param out [out] The destination of the authentication tag
|
@param out [out] The destination of the authentication tag
|
||||||
@param outlen [in/out] The max size and resulting size of the authentication tag (octets)
|
@param outlen [in/out] The max size and resulting size of the authentication tag (octets)
|
||||||
@param in The data to send through LTC_OMAC
|
@param in The data to send through OMAC
|
||||||
@param inlen The length of the data to send through LTC_OMAC (octets)
|
@param inlen The length of the data to send through OMAC (octets)
|
||||||
@param ... tuples of (data,len) pairs to LTC_OMAC, terminated with a (NULL,x) (x=don't care)
|
@param ... tuples of (data,len) pairs to OMAC, terminated with a (NULL,x) (x=don't care)
|
||||||
@return CRYPT_OK if successful
|
@return CRYPT_OK if successful
|
||||||
*/
|
*/
|
||||||
int omac_memory_multi(int cipher,
|
int omac_memory_multi(int cipher,
|
||||||
|
@ -12,22 +12,22 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
@file omac_process.c
|
@file omac_process.c
|
||||||
LTC_OMAC1 support, process data, Tom St Denis
|
OMAC1 support, process data, Tom St Denis
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifdef LTC_OMAC
|
#ifdef LTC_OMAC
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Process data through LTC_OMAC
|
Process data through OMAC
|
||||||
@param omac The LTC_OMAC state
|
@param omac The OMAC state
|
||||||
@param in The input data to send through LTC_OMAC
|
@param in The input data to send through OMAC
|
||||||
@param inlen The length of the input (octets)
|
@param inlen The length of the input (octets)
|
||||||
@return CRYPT_OK if successful
|
@return CRYPT_OK if successful
|
||||||
*/
|
*/
|
||||||
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)
|
||||||
{
|
{
|
||||||
unsigned long n, x;
|
unsigned long n, x, blklen;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
LTC_ARGCHK(omac != NULL);
|
LTC_ARGCHK(omac != NULL);
|
||||||
@ -42,9 +42,6 @@ int omac_process(omac_state *omac, const unsigned char *in, unsigned long inlen)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef LTC_FAST
|
#ifdef LTC_FAST
|
||||||
{
|
|
||||||
unsigned long blklen;
|
|
||||||
|
|
||||||
blklen = cipher_descriptor[omac->cipher_idx].block_length;
|
blklen = cipher_descriptor[omac->cipher_idx].block_length;
|
||||||
if (omac->buflen == 0 && inlen > blklen) {
|
if (omac->buflen == 0 && inlen > blklen) {
|
||||||
unsigned long y;
|
unsigned long y;
|
||||||
@ -59,7 +56,6 @@ int omac_process(omac_state *omac, const unsigned char *in, unsigned long inlen)
|
|||||||
}
|
}
|
||||||
inlen -= x;
|
inlen -= x;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
while (inlen != 0) {
|
while (inlen != 0) {
|
||||||
|
@ -12,13 +12,13 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
@file omac_test.c
|
@file omac_test.c
|
||||||
LTC_OMAC1 support, self-test, by Tom St Denis
|
OMAC1 support, self-test, by Tom St Denis
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef LTC_OMAC
|
#ifdef LTC_OMAC
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Test the LTC_OMAC setup
|
Test the OMAC setup
|
||||||
@return CRYPT_OK if successful, CRYPT_NOP if tests have been disabled
|
@return CRYPT_OK if successful, CRYPT_NOP if tests have been disabled
|
||||||
*/
|
*/
|
||||||
int omac_test(void)
|
int omac_test(void)
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||||
*/
|
*/
|
||||||
#include "tomcrypt.h"
|
#include "tomcrypt.h"
|
||||||
#include <signal.h>
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@file crypt_argchk.c
|
@file crypt_argchk.c
|
||||||
@ -17,6 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#if (ARGTYPE == 0)
|
#if (ARGTYPE == 0)
|
||||||
|
#include <signal.h>
|
||||||
void crypt_argchk(char *v, char *s, int d)
|
void crypt_argchk(char *v, char *s, int d)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "LTC_ARGCHK '%s' failure on line %d of file %s\n",
|
fprintf(stderr, "LTC_ARGCHK '%s' failure on line %d of file %s\n",
|
||||||
|
@ -12,15 +12,15 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
@file pkcs_5_1.c
|
@file pkcs_5_1.c
|
||||||
LTC_PKCS #5, Algorithm #1, Tom St Denis
|
PKCS #5, Algorithm #1, Tom St Denis
|
||||||
*/
|
*/
|
||||||
#ifdef LTC_PKCS_5
|
#ifdef LTC_PKCS_5
|
||||||
/**
|
/**
|
||||||
Execute LTC_PKCS #5 v1
|
Execute PKCS #5 v1
|
||||||
@param password The password (or key)
|
@param password The password (or key)
|
||||||
@param password_len The length of the password (octet)
|
@param password_len The length of the password (octet)
|
||||||
@param salt The salt (or nonce) which is 8 octets long
|
@param salt The salt (or nonce) which is 8 octets long
|
||||||
@param iteration_count The LTC_PKCS #5 v1 iteration count
|
@param iteration_count The PKCS #5 v1 iteration count
|
||||||
@param hash_idx The index of the hash desired
|
@param hash_idx The index of the hash desired
|
||||||
@param out [out] The destination for this algorithm
|
@param out [out] The destination for this algorithm
|
||||||
@param outlen [in/out] The max size and resulting size of the algorithm output
|
@param outlen [in/out] The max size and resulting size of the algorithm output
|
||||||
|
@ -12,17 +12,17 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
@file pkcs_5_2.c
|
@file pkcs_5_2.c
|
||||||
LTC_PKCS #5, Algorithm #2, Tom St Denis
|
PKCS #5, Algorithm #2, Tom St Denis
|
||||||
*/
|
*/
|
||||||
#ifdef LTC_PKCS_5
|
#ifdef LTC_PKCS_5
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Execute LTC_PKCS #5 v2
|
Execute PKCS #5 v2
|
||||||
@param password The input password (or key)
|
@param password The input password (or key)
|
||||||
@param password_len The length of the password (octets)
|
@param password_len The length of the password (octets)
|
||||||
@param salt The salt (or nonce)
|
@param salt The salt (or nonce)
|
||||||
@param salt_len The length of the salt (octets)
|
@param salt_len The length of the salt (octets)
|
||||||
@param iteration_count # of iterations desired for LTC_PKCS #5 v2 [read specs for more]
|
@param iteration_count # of iterations desired for PKCS #5 v2 [read specs for more]
|
||||||
@param hash_idx The index of the hash desired
|
@param hash_idx The index of the hash desired
|
||||||
@param out [out] The destination for this algorithm
|
@param out [out] The destination for this algorithm
|
||||||
@param outlen [in/out] The max size and resulting size of the algorithm output
|
@param outlen [in/out] The max size and resulting size of the algorithm output
|
||||||
|
@ -12,13 +12,13 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
@file katja_decrypt_key.c
|
@file katja_decrypt_key.c
|
||||||
Katja LTC_PKCS #1 OAEP Decryption, Tom St Denis
|
Katja PKCS #1 OAEP Decryption, Tom St Denis
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef MKAT
|
#ifdef MKAT
|
||||||
|
|
||||||
/**
|
/**
|
||||||
(LTC_PKCS #1 v2.0) decrypt then OAEP depad
|
(PKCS #1 v2.0) decrypt then OAEP depad
|
||||||
@param in The ciphertext
|
@param in The ciphertext
|
||||||
@param inlen The length of the ciphertext (octets)
|
@param inlen The length of the ciphertext (octets)
|
||||||
@param out [out] The plaintext
|
@param out [out] The plaintext
|
||||||
|
@ -12,13 +12,13 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
@file katja_encrypt_key.c
|
@file katja_encrypt_key.c
|
||||||
Katja LTC_PKCS-style OAEP encryption, Tom St Denis
|
Katja PKCS-style OAEP encryption, Tom St Denis
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef MKAT
|
#ifdef MKAT
|
||||||
|
|
||||||
/**
|
/**
|
||||||
(LTC_PKCS #1 v2.0) OAEP pad then encrypt
|
(PKCS #1 v2.0) OAEP pad then encrypt
|
||||||
@param in The plaintext
|
@param in The plaintext
|
||||||
@param inlen The length of the plaintext (octets)
|
@param inlen The length of the plaintext (octets)
|
||||||
@param out [out] The ciphertext
|
@param out [out] The ciphertext
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
@file katja_export.c
|
@file katja_export.c
|
||||||
Export Katja LTC_PKCS-style keys, Tom St Denis
|
Export Katja PKCS-style keys, Tom St Denis
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef MKAT
|
#ifdef MKAT
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
@file katja_exptmod.c
|
@file katja_exptmod.c
|
||||||
Katja LTC_PKCS-style exptmod, Tom St Denis
|
Katja PKCS-style exptmod, Tom St Denis
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef MKAT
|
#ifdef MKAT
|
||||||
|
@ -12,13 +12,13 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
@file katja_import.c
|
@file katja_import.c
|
||||||
Import a LTC_PKCS-style Katja key, Tom St Denis
|
Import a PKCS-style Katja key, Tom St Denis
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef MKAT
|
#ifdef MKAT
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Import an KatjaPublicKey or KatjaPrivateKey [two-prime only, only support >= 1024-bit keys, defined in LTC_PKCS #1 v2.1]
|
Import an KatjaPublicKey or KatjaPrivateKey [two-prime only, only support >= 1024-bit keys, defined in PKCS #1 v2.1]
|
||||||
@param in The packet to import from
|
@param in The packet to import from
|
||||||
@param inlen It's length (octets)
|
@param inlen It's length (octets)
|
||||||
@param key [out] Destination for newly imported key
|
@param key [out] Destination for newly imported key
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
LTC_PKCS #1 Integer to binary
|
PKCS #1 Integer to binary
|
||||||
@param n The integer to store
|
@param n The integer to store
|
||||||
@param modulus_len The length of the RSA modulus
|
@param modulus_len The length of the RSA modulus
|
||||||
@param out [out] The destination for the integer
|
@param out [out] The destination for the integer
|
||||||
|
@ -12,13 +12,13 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
@file pkcs_1_mgf1.c
|
@file pkcs_1_mgf1.c
|
||||||
The Mask Generation Function (MGF1) for LTC_PKCS #1, Tom St Denis
|
The Mask Generation Function (MGF1) for PKCS #1, Tom St Denis
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef LTC_PKCS_1
|
#ifdef LTC_PKCS_1
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Perform LTC_PKCS #1 MGF1 (internal)
|
Perform PKCS #1 MGF1 (internal)
|
||||||
@param seed The seed for MGF1
|
@param seed The seed for MGF1
|
||||||
@param seedlen The length of the seed
|
@param seedlen The length of the seed
|
||||||
@param hash_idx The index of the hash desired
|
@param hash_idx The index of the hash desired
|
||||||
|
@ -12,13 +12,13 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
@file pkcs_1_oaep_decode.c
|
@file pkcs_1_oaep_decode.c
|
||||||
OAEP Padding for LTC_PKCS #1, Tom St Denis
|
OAEP Padding for PKCS #1, Tom St Denis
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef LTC_PKCS_1
|
#ifdef LTC_PKCS_1
|
||||||
|
|
||||||
/**
|
/**
|
||||||
LTC_PKCS #1 v2.00 OAEP decode
|
PKCS #1 v2.00 OAEP decode
|
||||||
@param msg The encoded data to decode
|
@param msg The encoded data to decode
|
||||||
@param msglen The length of the encoded data (octets)
|
@param msglen The length of the encoded data (octets)
|
||||||
@param lparam The session or system data (can be NULL)
|
@param lparam The session or system data (can be NULL)
|
||||||
|
@ -12,13 +12,13 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
@file pkcs_1_oaep_encode.c
|
@file pkcs_1_oaep_encode.c
|
||||||
OAEP Padding for LTC_PKCS #1, Tom St Denis
|
OAEP Padding for PKCS #1, Tom St Denis
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef LTC_PKCS_1
|
#ifdef LTC_PKCS_1
|
||||||
|
|
||||||
/**
|
/**
|
||||||
LTC_PKCS #1 v2.00 OAEP encode
|
PKCS #1 v2.00 OAEP encode
|
||||||
@param msg The data to encode
|
@param msg The data to encode
|
||||||
@param msglen The length of the data to encode (octets)
|
@param msglen The length of the data to encode (octets)
|
||||||
@param lparam A session or system parameter (can be NULL)
|
@param lparam A session or system parameter (can be NULL)
|
||||||
|
@ -12,13 +12,13 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
@file pkcs_1_pss_decode.c
|
@file pkcs_1_pss_decode.c
|
||||||
LTC_PKCS #1 PSS Signature Padding, Tom St Denis
|
PKCS #1 PSS Signature Padding, Tom St Denis
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef LTC_PKCS_1
|
#ifdef LTC_PKCS_1
|
||||||
|
|
||||||
/**
|
/**
|
||||||
LTC_PKCS #1 v2.00 PSS decode
|
PKCS #1 v2.00 PSS decode
|
||||||
@param msghash The hash to verify
|
@param msghash The hash to verify
|
||||||
@param msghashlen The length of the hash (octets)
|
@param msghashlen The length of the hash (octets)
|
||||||
@param sig The signature data (encoded data)
|
@param sig The signature data (encoded data)
|
||||||
|
@ -12,13 +12,13 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
@file pkcs_1_pss_encode.c
|
@file pkcs_1_pss_encode.c
|
||||||
LTC_PKCS #1 PSS Signature Padding, Tom St Denis
|
PKCS #1 PSS Signature Padding, Tom St Denis
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef LTC_PKCS_1
|
#ifdef LTC_PKCS_1
|
||||||
|
|
||||||
/**
|
/**
|
||||||
LTC_PKCS #1 v2.00 Signature Encoding
|
PKCS #1 v2.00 Signature Encoding
|
||||||
@param msghash The hash to encode
|
@param msghash The hash to encode
|
||||||
@param msghashlen The length of the hash (octets)
|
@param msghashlen The length of the hash (octets)
|
||||||
@param saltlen The length of the salt desired (octets)
|
@param saltlen The length of the salt desired (octets)
|
||||||
|
@ -12,12 +12,12 @@
|
|||||||
|
|
||||||
/** @file pkcs_1_v1_5_decode.c
|
/** @file pkcs_1_v1_5_decode.c
|
||||||
*
|
*
|
||||||
* LTC_PKCS #1 v1.5 Padding. (Andreas Lange)
|
* PKCS #1 v1.5 Padding. (Andreas Lange)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef LTC_PKCS_1
|
#ifdef LTC_PKCS_1
|
||||||
|
|
||||||
/** @brief LTC_PKCS #1 v1.5 decode.
|
/** @brief PKCS #1 v1.5 decode.
|
||||||
*
|
*
|
||||||
* @param msg The encoded data to decode
|
* @param msg The encoded data to decode
|
||||||
* @param msglen The length of the encoded data (octets)
|
* @param msglen The length of the encoded data (octets)
|
||||||
|
@ -12,12 +12,12 @@
|
|||||||
|
|
||||||
/*! \file pkcs_1_v1_5_encode.c
|
/*! \file pkcs_1_v1_5_encode.c
|
||||||
*
|
*
|
||||||
* LTC_PKCS #1 v1.5 Padding (Andreas Lange)
|
* PKCS #1 v1.5 Padding (Andreas Lange)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef LTC_PKCS_1
|
#ifdef LTC_PKCS_1
|
||||||
|
|
||||||
/*! \brief LTC_PKCS #1 v1.5 encode.
|
/*! \brief PKCS #1 v1.5 encode.
|
||||||
*
|
*
|
||||||
* \param msg The data to encode
|
* \param msg The data to encode
|
||||||
* \param msglen The length of the data to encode (octets)
|
* \param msglen The length of the data to encode (octets)
|
||||||
|
@ -12,13 +12,13 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
@file rsa_decrypt_key.c
|
@file rsa_decrypt_key.c
|
||||||
RSA LTC_PKCS #1 Decryption, Tom St Denis and Andreas Lange
|
RSA PKCS #1 Decryption, Tom St Denis and Andreas Lange
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef LTC_MRSA
|
#ifdef LTC_MRSA
|
||||||
|
|
||||||
/**
|
/**
|
||||||
LTC_PKCS #1 decrypt then v1.5 or OAEP depad
|
PKCS #1 decrypt then v1.5 or OAEP depad
|
||||||
@param in The ciphertext
|
@param in The ciphertext
|
||||||
@param inlen The length of the ciphertext (octets)
|
@param inlen The length of the ciphertext (octets)
|
||||||
@param out [out] The plaintext
|
@param out [out] The plaintext
|
||||||
@ -90,7 +90,7 @@ int rsa_decrypt_key_ex(const unsigned char *in, unsigned long inlen,
|
|||||||
err = pkcs_1_oaep_decode(tmp, x, lparam, lparamlen, modulus_bitlen, hash_idx,
|
err = pkcs_1_oaep_decode(tmp, x, lparam, lparamlen, modulus_bitlen, hash_idx,
|
||||||
out, outlen, stat);
|
out, outlen, stat);
|
||||||
} else {
|
} else {
|
||||||
/* now LTC_PKCS #1 v1.5 depad the packet */
|
/* now PKCS #1 v1.5 depad the packet */
|
||||||
err = pkcs_1_v1_5_decode(tmp, x, LTC_PKCS_1_EME, modulus_bitlen, out, outlen, stat);
|
err = pkcs_1_v1_5_decode(tmp, x, LTC_PKCS_1_EME, modulus_bitlen, out, outlen, stat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,13 +12,13 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
@file rsa_encrypt_key.c
|
@file rsa_encrypt_key.c
|
||||||
RSA LTC_PKCS #1 encryption, Tom St Denis and Andreas Lange
|
RSA PKCS #1 encryption, Tom St Denis and Andreas Lange
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef LTC_MRSA
|
#ifdef LTC_MRSA
|
||||||
|
|
||||||
/**
|
/**
|
||||||
(LTC_PKCS #1 v2.0) OAEP pad then encrypt
|
(PKCS #1 v2.0) OAEP pad then encrypt
|
||||||
@param in The plaintext
|
@param in The plaintext
|
||||||
@param inlen The length of the plaintext (octets)
|
@param inlen The length of the plaintext (octets)
|
||||||
@param out [out] The ciphertext
|
@param out [out] The ciphertext
|
||||||
@ -82,7 +82,7 @@ int rsa_encrypt_key_ex(const unsigned char *in, unsigned long inlen,
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* LTC_PKCS #1 v1.5 pad the key */
|
/* PKCS #1 v1.5 pad the key */
|
||||||
x = *outlen;
|
x = *outlen;
|
||||||
if ((err = pkcs_1_v1_5_encode(in, inlen, LTC_PKCS_1_EME,
|
if ((err = pkcs_1_v1_5_encode(in, inlen, LTC_PKCS_1_EME,
|
||||||
modulus_bitlen, prng, prng_idx,
|
modulus_bitlen, prng, prng_idx,
|
||||||
@ -91,7 +91,7 @@ int rsa_encrypt_key_ex(const unsigned char *in, unsigned long inlen,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* rsa exptmod the OAEP or LTC_PKCS #1 v1.5 pad */
|
/* rsa exptmod the OAEP or PKCS #1 v1.5 pad */
|
||||||
return ltc_mp.rsa_me(out, x, out, outlen, PK_PUBLIC, key);
|
return ltc_mp.rsa_me(out, x, out, outlen, PK_PUBLIC, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,13 +12,13 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
@file rsa_export.c
|
@file rsa_export.c
|
||||||
Export RSA LTC_PKCS keys, Tom St Denis
|
Export RSA PKCS keys, Tom St Denis
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef LTC_MRSA
|
#ifdef LTC_MRSA
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This will export either an RSAPublicKey or RSAPrivateKey [defined in LTC_PKCS #1 v2.1]
|
This will export either an RSAPublicKey or RSAPrivateKey [defined in PKCS #1 v2.1]
|
||||||
@param out [out] Destination of the packet
|
@param out [out] Destination of the packet
|
||||||
@param outlen [in/out] The max size and resulting size of the packet
|
@param outlen [in/out] The max size and resulting size of the packet
|
||||||
@param type The type of exported key (PK_PRIVATE or PK_PUBLIC)
|
@param type The type of exported key (PK_PRIVATE or PK_PUBLIC)
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
@file rsa_exptmod.c
|
@file rsa_exptmod.c
|
||||||
RSA LTC_PKCS exptmod, Tom St Denis
|
RSA PKCS exptmod, Tom St Denis
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef LTC_MRSA
|
#ifdef LTC_MRSA
|
||||||
|
@ -12,13 +12,13 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
@file rsa_import.c
|
@file rsa_import.c
|
||||||
Import a LTC_PKCS RSA key, Tom St Denis
|
Import a PKCS RSA key, Tom St Denis
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef LTC_MRSA
|
#ifdef LTC_MRSA
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Import an RSAPublicKey or RSAPrivateKey [two-prime only, only support >= 1024-bit keys, defined in LTC_PKCS #1 v2.1]
|
Import an RSAPublicKey or RSAPrivateKey [two-prime only, only support >= 1024-bit keys, defined in PKCS #1 v2.1]
|
||||||
@param in The packet to import from
|
@param in The packet to import from
|
||||||
@param inlen It's length (octets)
|
@param inlen It's length (octets)
|
||||||
@param key [out] Destination for newly imported key
|
@param key [out] Destination for newly imported key
|
||||||
@ -67,7 +67,7 @@ int rsa_import(const unsigned char *in, unsigned long inlen, rsa_key *key)
|
|||||||
goto LBL_FREE;
|
goto LBL_FREE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* not SSL public key, try to match against LTC_PKCS #1 standards */
|
/* not SSL public key, try to match against PKCS #1 standards */
|
||||||
if ((err = der_decode_sequence_multi(in, inlen,
|
if ((err = der_decode_sequence_multi(in, inlen,
|
||||||
LTC_ASN1_INTEGER, 1UL, key->N,
|
LTC_ASN1_INTEGER, 1UL, key->N,
|
||||||
LTC_ASN1_EOL, 0UL, NULL)) != CRYPT_OK) {
|
LTC_ASN1_EOL, 0UL, NULL)) != CRYPT_OK) {
|
||||||
|
@ -12,13 +12,13 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
@file rsa_sign_hash.c
|
@file rsa_sign_hash.c
|
||||||
RSA LTC_PKCS #1 v1.5 and v2 PSS sign hash, Tom St Denis and Andreas Lange
|
RSA PKCS #1 v1.5 and v2 PSS sign hash, Tom St Denis and Andreas Lange
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef LTC_MRSA
|
#ifdef LTC_MRSA
|
||||||
|
|
||||||
/**
|
/**
|
||||||
LTC_PKCS #1 pad then sign
|
PKCS #1 pad then sign
|
||||||
@param in The hash to sign
|
@param in The hash to sign
|
||||||
@param inlen The length of the hash to sign (octets)
|
@param inlen The length of the hash to sign (octets)
|
||||||
@param out [out] The signature
|
@param out [out] The signature
|
||||||
@ -79,7 +79,7 @@ int rsa_sign_hash_ex(const unsigned char *in, unsigned long inlen,
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* LTC_PKCS #1 v1.5 pad the hash */
|
/* PKCS #1 v1.5 pad the hash */
|
||||||
unsigned char *tmpin;
|
unsigned char *tmpin;
|
||||||
ltc_asn1_list digestinfo[2], siginfo[2];
|
ltc_asn1_list digestinfo[2], siginfo[2];
|
||||||
|
|
||||||
|
@ -12,13 +12,13 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
@file rsa_verify_hash.c
|
@file rsa_verify_hash.c
|
||||||
RSA LTC_PKCS #1 v1.5 or v2 PSS signature verification, Tom St Denis and Andreas Lange
|
RSA PKCS #1 v1.5 or v2 PSS signature verification, Tom St Denis and Andreas Lange
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef LTC_MRSA
|
#ifdef LTC_MRSA
|
||||||
|
|
||||||
/**
|
/**
|
||||||
LTC_PKCS #1 de-sign then v1.5 or PSS depad
|
PKCS #1 de-sign then v1.5 or PSS depad
|
||||||
@param sig The signature data
|
@param sig The signature data
|
||||||
@param siglen The length of the signature data (octets)
|
@param siglen The length of the signature data (octets)
|
||||||
@param hash The hash of the message that was signed
|
@param hash The hash of the message that was signed
|
||||||
@ -94,7 +94,7 @@ int rsa_verify_hash_ex(const unsigned char *sig, unsigned long siglen,
|
|||||||
/* PSS decode and verify it */
|
/* PSS decode and verify it */
|
||||||
err = pkcs_1_pss_decode(hash, hashlen, tmpbuf, x, saltlen, hash_idx, modulus_bitlen, stat);
|
err = pkcs_1_pss_decode(hash, hashlen, tmpbuf, x, saltlen, hash_idx, modulus_bitlen, stat);
|
||||||
} else {
|
} else {
|
||||||
/* LTC_PKCS #1 v1.5 decode it */
|
/* PKCS #1 v1.5 decode it */
|
||||||
unsigned char *out;
|
unsigned char *out;
|
||||||
unsigned long outlen, loid[16];
|
unsigned long outlen, loid[16];
|
||||||
int decoded;
|
int decoded;
|
||||||
|
@ -14,7 +14,6 @@ int dh_test (void)
|
|||||||
unsigned long x, y, z;
|
unsigned long x, y, z;
|
||||||
int stat, stat2;
|
int stat, stat2;
|
||||||
dh_key usera, userb;
|
dh_key usera, userb;
|
||||||
prng_state yarrow_prng;
|
|
||||||
|
|
||||||
if (register_prng(&yarrow_desc) == -1) {
|
if (register_prng(&yarrow_desc) == -1) {
|
||||||
printf("Error registering yarrow PRNG\n");
|
printf("Error registering yarrow PRNG\n");
|
||||||
|
@ -33,7 +33,7 @@ int pkcs_1_test(void)
|
|||||||
/* pick a random saltlen 0..16 */
|
/* pick a random saltlen 0..16 */
|
||||||
saltlen = abs(rand()) % 17;
|
saltlen = abs(rand()) % 17;
|
||||||
|
|
||||||
/* LTC_PKCS #1 v2.0 supports modlens not multiple of 8 */
|
/* PKCS #1 v2.0 supports modlens not multiple of 8 */
|
||||||
modlen = 800 + (abs(rand()) % 224);
|
modlen = 800 + (abs(rand()) % 224);
|
||||||
|
|
||||||
/* encode it */
|
/* encode it */
|
||||||
|
@ -235,7 +235,7 @@ for (cnt = 0; cnt < len; ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* encrypt the key LTC_PKCS #1 v1.5 (payload from 1 to 117 bytes) */
|
/* encrypt the key PKCS #1 v1.5 (payload from 1 to 117 bytes) */
|
||||||
for (rsa_msgsize = 1; rsa_msgsize <= 117; rsa_msgsize++) {
|
for (rsa_msgsize = 1; rsa_msgsize <= 117; rsa_msgsize++) {
|
||||||
len = sizeof(out);
|
len = sizeof(out);
|
||||||
len2 = rsa_msgsize;
|
len2 = rsa_msgsize;
|
||||||
@ -327,7 +327,7 @@ for (cnt = 0; cnt < len; ) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* sign a message with LTC_PKCS #1 v1.5 */
|
/* sign a message with PKCS #1 v1.5 */
|
||||||
len = sizeof(out);
|
len = sizeof(out);
|
||||||
DO(rsa_sign_hash_ex(in, 20, out, &len, LTC_PKCS_1_V1_5, &yarrow_prng, prng_idx, hash_idx, 8, &privKey));
|
DO(rsa_sign_hash_ex(in, 20, out, &len, LTC_PKCS_1_V1_5, &yarrow_prng, prng_idx, hash_idx, 8, &privKey));
|
||||||
DO(rsa_verify_hash_ex(out, len, in, 20, LTC_PKCS_1_V1_5, hash_idx, 8, &stat, &pubKey));
|
DO(rsa_verify_hash_ex(out, len, in, 20, LTC_PKCS_1_V1_5, hash_idx, 8, &stat, &pubKey));
|
||||||
|
@ -58,6 +58,7 @@ int katja_test(void);
|
|||||||
int ecc_tests(void);
|
int ecc_tests(void);
|
||||||
int dsa_test(void);
|
int dsa_test(void);
|
||||||
int der_tests(void);
|
int der_tests(void);
|
||||||
|
int misc_test(void);
|
||||||
|
|
||||||
/* timing */
|
/* timing */
|
||||||
#define KTIMES 25
|
#define KTIMES 25
|
||||||
|
Loading…
x
Reference in New Issue
Block a user