added libtomcrypt-1.08

This commit is contained in:
Tom St Denis
2005-11-24 11:57:58 +00:00
committed by Steffen Jaeckel
parent 4a1a5796de
commit 1eeff0bfb4
34 changed files with 754 additions and 187 deletions
+2 -2
View File
@@ -16,8 +16,8 @@ extern "C" {
#endif
/* version */
#define CRYPT 0x0107
#define SCRYPT "1.07"
#define CRYPT 0x0108
#define SCRYPT "1.08"
/* max size of either a cipher/hash block or symmetric key [largest of the two] */
#define MAXBLOCKSIZE 128
+5 -1
View File
@@ -13,12 +13,16 @@ void *XREALLOC(void *p, size_t n);
void *XCALLOC(size_t n, size_t s);
void XFREE(void *p);
void XQSORT(void *base, size_t nmemb, size_t size, int(*compar)(const void *, const void *));
/* change the clock function too */
clock_t XCLOCK(void);
clock_t XCLOCK(void);
/* various other functions */
void *XMEMCPY(void *dest, const void *src, size_t n);
int XMEMCMP(const void *s1, const void *s2, size_t n);
void *XMEMSET(void *s, int c, size_t n);
/* type of argument checking, 0=default, 1=fatal and 2=error+continue, 3=nothing */
#ifndef ARGTYPE
+54 -24
View File
@@ -2,16 +2,39 @@
#define TOMCRYPT_CUSTOM_H_
/* macros for various libc functions you can change for embedded targets */
#ifndef XMALLOC
#define XMALLOC malloc
#endif
#ifndef XREALLOC
#define XREALLOC realloc
#endif
#ifndef XCALLOC
#define XCALLOC calloc
#endif
#ifndef XFREE
#define XFREE free
#endif
#ifndef XMEMSET
#define XMEMSET memset
#endif
#ifndef XMEMCPY
#define XMEMCPY memcpy
#endif
#ifndef XMEMCMP
#define XMEMCMP memcmp
#endif
#ifndef XCLOCK
#define XCLOCK clock
#endif
#ifndef XCLOCKS_PER_SEC
#define XCLOCKS_PER_SEC CLOCKS_PER_SEC
#endif
#ifndef XQSORT
#define XQSORT qsort
#endif
/* Use small code where possible */
/* #define LTC_SMALL_CODE */
@@ -186,15 +209,11 @@
/* Include RSA support */
#define MRSA
/* Include Katja (an Rabin variant like RSA) */
/* Include Katja (a Rabin variant like RSA) */
// #define MKAT
/* Digital Signature Algorithm */
#define MDSA
/* Max diff between group and modulus size in bytes */
#define MDSA_DELTA 512
/* Max DSA group size in bytes (default allows 4k-bit groups) */
#define MDSA_MAX_GROUP 512
/* ECC */
#define MECC
@@ -202,18 +221,6 @@
/* Timing Resistant? */
/* #define LTC_ECC_TIMING_RESISTANT */
/* Supported ECC Key Sizes */
#ifndef LTC_NO_CURVES
#define ECC192
#define ECC224
#define ECC256
#define ECC384
#define ECC521
#endif
/* Include the MPI functionality? (required by the PK algorithms) */
#define MPI
#endif /* LTC_NO_PK */
/* PKCS #1 (RSA) and #5 (Password Handling) stuff */
@@ -224,19 +231,39 @@
/* Include ASN.1 DER (required by DSA/RSA) */
#define LTC_DER
#endif /* LTC_NO_PKCS */
/* cleanup */
#ifdef MECC
/* Supported ECC Key Sizes */
#ifndef LTC_NO_CURVES
#define ECC192
#define ECC224
#define ECC256
#define ECC384
#define ECC521
#endif
#endif
#if defined(MECC) || defined(MRSA) || defined(MDSA) || defined(MKATJA)
/* Include the MPI functionality? (required by the PK algorithms) */
#define MPI
#endif
#ifdef MRSA
#define PKCS_1
#endif
#if defined(LTC_DER) && !defined(MPI)
#error ASN.1 DER requires MPI functionality
#endif
#if (defined(MDSA) || defined(MRSA)) && !defined(LTC_DER)
#error RSA/DSA requires ASN.1 DER functionality, make sure LTC_DER is enabled
#if (defined(MDSA) || defined(MRSA) || defined(MECC) || defined(MKATJA)) && !defined(LTC_DER)
#error PK requires ASN.1 DER functionality, make sure LTC_DER is enabled
#endif
#endif /* LTC_NO_PKCS */
#endif
/* THREAD management */
#ifdef LTC_PTHREAD
@@ -262,6 +289,9 @@
#endif
#endif
/* $Source$ */
/* $Revision$ */
+27 -10
View File
@@ -244,6 +244,12 @@ int ltc_ecc_map(ecc_point *P, void *modulus, void *mp);
#ifdef MDSA
/* Max diff between group and modulus size in bytes */
#define MDSA_DELTA 512
/* Max DSA group size in bytes (default allows 4k-bit groups) */
#define MDSA_MAX_GROUP 512
/** DSA key structure */
typedef struct {
/** The key type, PK_PRIVATE or PK_PUBLIC */
@@ -300,8 +306,6 @@ 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);
int dsa_shared_secret(void *private_key, void *base,
dsa_key *public_key,
unsigned char *out, unsigned long *outlen);
@@ -321,9 +325,10 @@ enum {
LTC_ASN1_IA5_STRING,
LTC_ASN1_PRINTABLE_STRING,
LTC_ASN1_UTCTIME,
LTC_ASN1_CHOICE,
LTC_ASN1_SEQUENCE
LTC_ASN1_SEQUENCE,
LTC_ASN1_SET,
LTC_ASN1_SETOF
};
/** A LTC ASN.1 list type */
@@ -351,23 +356,35 @@ typedef struct ltc_asn1_list_ {
} while (0);
/* SEQUENCE */
int der_encode_sequence(ltc_asn1_list *list, unsigned long inlen,
unsigned char *out, unsigned long *outlen);
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)
int der_decode_sequence(const unsigned char *in, unsigned long inlen,
ltc_asn1_list *list, unsigned long outlen);
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,
unsigned long *outlen);
/* SET */
#define der_decode_set(in, inlen, list, outlen) der_decode_sequence_ex(in, inlen, list, outlen, 0)
#define der_length_set der_length_sequence
int der_encode_set(ltc_asn1_list *list, unsigned long inlen,
unsigned char *out, unsigned long *outlen);
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, ...);
/* handle unknown list decoder */
/* FLEXI DECODER handle unknown list decoder */
int der_decode_sequence_flexi(const unsigned char *in, unsigned long *inlen, ltc_asn1_list **out);
void der_free_sequence_flexi(ltc_asn1_list *list);
void der_sequence_free(ltc_asn1_list *in);
/* INTEGER */