propagate from branch 'au.asn.ucc.matt.ltc.dropbear' (head 2af22fb4e878750b88f80f90d439b316d229796f)

to branch 'au.asn.ucc.matt.dropbear' (head 02c413252c90e9de8e03d91e9939dde3029f5c0a)

--HG--
extra : convert_revision : 52ccb0ad0587a62bc64aecb939adbb76546aac16
This commit is contained in:
Matt Johnston
2007-01-11 02:41:05 +00:00
368 changed files with 25592 additions and 10166 deletions

View File

@@ -6,7 +6,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
*/
#include "tomcrypt.h"
@@ -100,5 +100,5 @@ int base64_decode(const unsigned char *in, unsigned long inlen,
/* $Source: /cvs/libtom/libtomcrypt/src/misc/base64/base64_decode.c,v $ */
/* $Revision: 1.3 $ */
/* $Date: 2005/05/05 14:35:59 $ */
/* $Revision: 1.4 $ */
/* $Date: 2006/03/31 14:15:35 $ */

View File

@@ -6,7 +6,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
*/
#include "tomcrypt.h"
@@ -42,6 +42,7 @@ int base64_encode(const unsigned char *in, unsigned long inlen,
/* valid output size ? */
len2 = 4 * ((inlen + 2) / 3);
if (*outlen < len2 + 1) {
*outlen = len2 + 1;
return CRYPT_BUFFER_OVERFLOW;
}
p = out;
@@ -76,5 +77,5 @@ int base64_encode(const unsigned char *in, unsigned long inlen,
/* $Source: /cvs/libtom/libtomcrypt/src/misc/base64/base64_encode.c,v $ */
/* $Revision: 1.3 $ */
/* $Date: 2005/05/05 14:35:59 $ */
/* $Revision: 1.5 $ */
/* $Date: 2006/06/16 21:53:41 $ */

View File

@@ -6,7 +6,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
*/
#include "tomcrypt.h"
@@ -30,5 +30,5 @@ void burn_stack(unsigned long len)
/* $Source: /cvs/libtom/libtomcrypt/src/misc/burn_stack.c,v $ */
/* $Revision: 1.3 $ */
/* $Date: 2005/05/05 14:35:59 $ */
/* $Revision: 1.4 $ */
/* $Date: 2006/03/31 14:15:35 $ */

View File

@@ -6,7 +6,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
*/
#include "tomcrypt.h"
@@ -111,6 +111,12 @@ const char *crypt_build_settings =
" (tweaked)"
#endif
"\n"
#if defined(KSEED)
" KSEED\n"
#endif
#if defined(LTC_KASUMI)
" KASUMI\n"
#endif
"\nHashes built-in:\n"
#if defined(SHA512)
@@ -154,35 +160,55 @@ const char *crypt_build_settings =
#endif
"\nBlock Chaining Modes:\n"
#if defined(CFB)
#if defined(LTC_CFB_MODE)
" CFB\n"
#endif
#if defined(OFB)
#if defined(LTC_OFB_MODE)
" OFB\n"
#endif
#if defined(ECB)
#if defined(LTC_ECB_MODE)
" ECB\n"
#endif
#if defined(CBC)
#if defined(LTC_CBC_MODE)
" CBC\n"
#endif
#if defined(CTR)
" CTR\n"
#if defined(LTC_CTR_MODE)
" CTR "
#endif
#if defined(LTC_CTR_OLD)
" (CTR_OLD) "
#endif
"\n"
#if defined(LRW_MODE)
" LRW_MODE"
#if defined(LRW_TABLES)
" (LRW_TABLES) "
#endif
"\n"
#endif
#if defined(LTC_F8_MODE)
" F8 MODE\n"
#endif
"\nMACs:\n"
#if defined(HMAC)
#if defined(LTC_HMAC)
" HMAC\n"
#endif
#if defined(OMAC)
#if defined(LTC_OMAC)
" OMAC\n"
#endif
#if defined(PMAC)
#if defined(LTC_PMAC)
" PMAC\n"
#endif
#if defined(PELICAN)
" PELICAN\n"
#endif
#if defined(LTC_XCBC)
" XCBC-MAC\n"
#endif
#if defined(LTC_F9_MODE)
" F9-MAC\n"
#endif
"\nENC + AUTH modes:\n"
#if defined(EAX_MODE)
@@ -202,7 +228,6 @@ const char *crypt_build_settings =
#endif
"\n"
"\nPRNG:\n"
#if defined(YARROW)
" Yarrow\n"
@@ -224,24 +249,24 @@ const char *crypt_build_settings =
#if defined(MRSA)
" RSA \n"
#endif
#if defined(MDH)
" DH\n"
#endif
#if defined(MECC)
" ECC\n"
#endif
#if defined(MDSA)
" DSA\n"
#endif
#if defined(MKAT)
" Katja\n"
#endif
"\nCompiler:\n"
#if defined(WIN32)
" WIN32 platform detected.\n"
#endif
#if defined(LBL_CYGWIN__)
#if defined(__CYGWIN__)
" CYGWIN Detected.\n"
#endif
#if defined(LBL_DJGPP__)
#if defined(__DJGPP__)
" DJGPP Detected.\n"
#endif
#if defined(_MSC_VER)
@@ -253,9 +278,12 @@ const char *crypt_build_settings =
#if defined(INTEL_CC)
" Intel C Compiler detected.\n"
#endif
#if defined(LBL_x86_64__)
#if defined(__x86_64__)
" x86-64 detected.\n"
#endif
#if defined(LTC_PPC32)
" LTC_PPC32 defined \n"
#endif
"\nVarious others: "
#if defined(BASE64)
@@ -305,6 +333,27 @@ const char *crypt_build_settings =
#endif
#if defined(LTC_PTHREAD)
" LTC_PTHREAD "
#endif
#if defined(LTM_DESC)
" LTM_DESC "
#endif
#if defined(TFM_DESC)
" TFM_DESC "
#endif
#if defined(MECC_ACCEL)
" MECC_ACCEL "
#endif
#if defined(GMP_DESC)
" GMP_DESC "
#endif
#if defined(LTC_EASY)
" (easy) "
#endif
#if defined(MECC_FP)
" MECC_FP "
#endif
#if defined(LTC_ECC_SHAMIR)
" LTC_ECC_SHAMIR "
#endif
"\n"
"\n\n\n"
@@ -313,5 +362,5 @@ const char *crypt_build_settings =
/* $Source: /cvs/libtom/libtomcrypt/src/misc/crypt/crypt.c,v $ */
/* $Revision: 1.11 $ */
/* $Date: 2005/06/19 18:00:28 $ */
/* $Revision: 1.27 $ */
/* $Date: 2006/12/03 03:50:45 $ */

View File

@@ -6,7 +6,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
*/
#include "tomcrypt.h"
#include <signal.h>
@@ -26,5 +26,5 @@ void crypt_argchk(char *v, char *s, int d)
#endif
/* $Source: /cvs/libtom/libtomcrypt/src/misc/crypt/crypt_argchk.c,v $ */
/* $Revision: 1.3 $ */
/* $Date: 2005/05/05 14:35:59 $ */
/* $Revision: 1.4 $ */
/* $Date: 2006/03/31 14:15:35 $ */

View File

@@ -6,7 +6,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
*/
#include "tomcrypt.h"
@@ -16,12 +16,12 @@
*/
struct ltc_cipher_descriptor cipher_descriptor[TAB_SIZE] = {
{ NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }
{ NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }
};
LTC_MUTEX_GLOBAL(ltc_cipher_mutex);
LTC_MUTEX_GLOBAL(ltc_cipher_mutex)
/* $Source: /cvs/libtom/libtomcrypt/src/misc/crypt/crypt_cipher_descriptor.c,v $ */
/* $Revision: 1.8 $ */
/* $Date: 2005/06/19 18:00:28 $ */
/* $Revision: 1.12 $ */
/* $Date: 2006/11/08 23:01:06 $ */

View File

@@ -6,7 +6,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
*/
#include "tomcrypt.h"
@@ -32,5 +32,5 @@ int cipher_is_valid(int idx)
}
/* $Source: /cvs/libtom/libtomcrypt/src/misc/crypt/crypt_cipher_is_valid.c,v $ */
/* $Revision: 1.4 $ */
/* $Date: 2005/06/19 18:00:28 $ */
/* $Revision: 1.5 $ */
/* $Date: 2006/03/31 14:15:35 $ */

View File

@@ -6,7 +6,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
*/
#include "tomcrypt.h"
@@ -26,7 +26,7 @@ int find_cipher(const char *name)
LTC_ARGCHK(name != NULL);
LTC_MUTEX_LOCK(&ltc_cipher_mutex);
for (x = 0; x < TAB_SIZE; x++) {
if (cipher_descriptor[x].name != NULL && !strcmp(cipher_descriptor[x].name, name)) {
if (cipher_descriptor[x].name != NULL && !XSTRCMP(cipher_descriptor[x].name, name)) {
LTC_MUTEX_UNLOCK(&ltc_cipher_mutex);
return x;
}
@@ -37,5 +37,5 @@ int find_cipher(const char *name)
/* $Source: /cvs/libtom/libtomcrypt/src/misc/crypt/crypt_find_cipher.c,v $ */
/* $Revision: 1.4 $ */
/* $Date: 2005/06/19 18:00:28 $ */
/* $Revision: 1.6 $ */
/* $Date: 2006/11/29 23:43:57 $ */

View File

@@ -6,7 +6,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
*/
#include "tomcrypt.h"
@@ -46,5 +46,5 @@ int find_cipher_any(const char *name, int blocklen, int keylen)
}
/* $Source: /cvs/libtom/libtomcrypt/src/misc/crypt/crypt_find_cipher_any.c,v $ */
/* $Revision: 1.4 $ */
/* $Date: 2005/06/19 18:00:28 $ */
/* $Revision: 1.5 $ */
/* $Date: 2006/03/31 14:15:35 $ */

View File

@@ -6,7 +6,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
*/
#include "tomcrypt.h"
@@ -36,5 +36,5 @@ int find_cipher_id(unsigned char ID)
}
/* $Source: /cvs/libtom/libtomcrypt/src/misc/crypt/crypt_find_cipher_id.c,v $ */
/* $Revision: 1.4 $ */
/* $Date: 2005/06/19 18:00:28 $ */
/* $Revision: 1.5 $ */
/* $Date: 2006/03/31 14:15:35 $ */

View File

@@ -6,7 +6,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
*/
#include "tomcrypt.h"
@@ -26,7 +26,7 @@ int find_hash(const char *name)
LTC_ARGCHK(name != NULL);
LTC_MUTEX_LOCK(&ltc_hash_mutex);
for (x = 0; x < TAB_SIZE; x++) {
if (hash_descriptor[x].name != NULL && strcmp(hash_descriptor[x].name, name) == 0) {
if (hash_descriptor[x].name != NULL && XSTRCMP(hash_descriptor[x].name, name) == 0) {
LTC_MUTEX_UNLOCK(&ltc_hash_mutex);
return x;
}
@@ -36,5 +36,5 @@ int find_hash(const char *name)
}
/* $Source: /cvs/libtom/libtomcrypt/src/misc/crypt/crypt_find_hash.c,v $ */
/* $Revision: 1.4 $ */
/* $Date: 2005/06/19 18:00:28 $ */
/* $Revision: 1.6 $ */
/* $Date: 2006/11/29 23:43:57 $ */

View File

@@ -6,7 +6,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
*/
#include "tomcrypt.h"
@@ -45,5 +45,5 @@
}
/* $Source: /cvs/libtom/libtomcrypt/src/misc/crypt/crypt_find_hash_any.c,v $ */
/* $Revision: 1.4 $ */
/* $Date: 2005/06/19 18:00:28 $ */
/* $Revision: 1.5 $ */
/* $Date: 2006/03/31 14:15:35 $ */

View File

@@ -6,7 +6,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
*/
#include "tomcrypt.h"
@@ -36,5 +36,5 @@ int find_hash_id(unsigned char ID)
}
/* $Source: /cvs/libtom/libtomcrypt/src/misc/crypt/crypt_find_hash_id.c,v $ */
/* $Revision: 1.5 $ */
/* $Date: 2005/06/19 18:03:25 $ */
/* $Revision: 1.6 $ */
/* $Date: 2006/03/31 14:15:35 $ */

View File

@@ -0,0 +1,35 @@
/* LibTomCrypt, modular cryptographic library -- Tom St Denis
*
* LibTomCrypt is a library that provides various cryptographic
* algorithms in a highly modular and flexible manner.
*
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
*/
#include "tomcrypt.h"
/**
@file crypt_find_hash_oid.c
Find a hash, Tom St Denis
*/
int find_hash_oid(const unsigned long *ID, unsigned long IDlen)
{
int x;
LTC_ARGCHK(ID != NULL);
LTC_MUTEX_LOCK(&ltc_hash_mutex);
for (x = 0; x < TAB_SIZE; x++) {
if (hash_descriptor[x].name != NULL && hash_descriptor[x].OIDlen == IDlen && !XMEMCMP(hash_descriptor[x].OID, ID, sizeof(unsigned long) * IDlen)) {
LTC_MUTEX_UNLOCK(&ltc_hash_mutex);
return x;
}
}
LTC_MUTEX_UNLOCK(&ltc_hash_mutex);
return -1;
}
/* $Source: /cvs/libtom/libtomcrypt/src/misc/crypt/crypt_find_hash_oid.c,v $ */
/* $Revision: 1.4 $ */
/* $Date: 2006/11/01 09:28:17 $ */

View File

@@ -6,7 +6,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
*/
#include "tomcrypt.h"
@@ -26,7 +26,7 @@ int find_prng(const char *name)
LTC_ARGCHK(name != NULL);
LTC_MUTEX_LOCK(&ltc_prng_mutex);
for (x = 0; x < TAB_SIZE; x++) {
if ((prng_descriptor[x].name != NULL) && strcmp(prng_descriptor[x].name, name) == 0) {
if ((prng_descriptor[x].name != NULL) && XSTRCMP(prng_descriptor[x].name, name) == 0) {
LTC_MUTEX_UNLOCK(&ltc_prng_mutex);
return x;
}
@@ -37,5 +37,5 @@ int find_prng(const char *name)
/* $Source: /cvs/libtom/libtomcrypt/src/misc/crypt/crypt_find_prng.c,v $ */
/* $Revision: 1.4 $ */
/* $Date: 2005/06/19 18:00:28 $ */
/* $Revision: 1.6 $ */
/* $Date: 2006/11/29 23:43:57 $ */

View File

@@ -0,0 +1,59 @@
/* LibTomCrypt, modular cryptographic library -- Tom St Denis
*
* LibTomCrypt is a library that provides various cryptographic
* algorithms in a highly modular and flexible manner.
*
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
*/
#include "tomcrypt.h"
#include <stdarg.h>
/**
@file crypt_fsa.c
LibTomCrypt FULL SPEED AHEAD!, Tom St Denis
*/
/* format is ltc_mp, cipher_desc, [cipher_desc], NULL, hash_desc, [hash_desc], NULL, prng_desc, [prng_desc], NULL */
int crypt_fsa(void *mp, ...)
{
int err;
va_list args;
void *p;
va_start(args, mp);
if (mp != NULL) {
XMEMCPY(&ltc_mp, mp, sizeof(ltc_mp));
}
while ((p = va_arg(args, void*)) != NULL) {
if ((err = register_cipher(p)) != CRYPT_OK) {
va_end(args);
return err;
}
}
while ((p = va_arg(args, void*)) != NULL) {
if ((err = register_hash(p)) != CRYPT_OK) {
va_end(args);
return err;
}
}
while ((p = va_arg(args, void*)) != NULL) {
if ((err = register_prng(p)) != CRYPT_OK) {
va_end(args);
return err;
}
}
va_end(args);
return CRYPT_OK;
}
/* $Source: /cvs/libtom/libtomcrypt/src/misc/crypt/crypt_fsa.c,v $ */
/* $Revision: 1.4 $ */
/* $Date: 2006/11/13 23:14:33 $ */

View File

@@ -6,7 +6,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
*/
#include "tomcrypt.h"
@@ -16,12 +16,12 @@
*/
struct ltc_hash_descriptor hash_descriptor[TAB_SIZE] = {
{ NULL, 0, 0, 0, { 0 }, 0, NULL, NULL, NULL, NULL }
{ NULL, 0, 0, 0, { 0 }, 0, NULL, NULL, NULL, NULL, NULL }
};
LTC_MUTEX_GLOBAL(ltc_hash_mutex);
LTC_MUTEX_GLOBAL(ltc_hash_mutex)
/* $Source: /cvs/libtom/libtomcrypt/src/misc/crypt/crypt_hash_descriptor.c,v $ */
/* $Revision: 1.6 $ */
/* $Date: 2005/06/19 18:00:28 $ */
/* $Revision: 1.9 $ */
/* $Date: 2006/03/31 14:15:35 $ */

View File

@@ -6,7 +6,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
*/
#include "tomcrypt.h"
@@ -32,5 +32,5 @@ int hash_is_valid(int idx)
}
/* $Source: /cvs/libtom/libtomcrypt/src/misc/crypt/crypt_hash_is_valid.c,v $ */
/* $Revision: 1.4 $ */
/* $Date: 2005/06/19 18:00:28 $ */
/* $Revision: 1.5 $ */
/* $Date: 2006/03/31 14:15:35 $ */

View File

@@ -0,0 +1,13 @@
/* LibTomCrypt, modular cryptographic library -- Tom St Denis
*
* LibTomCrypt is a library that provides various cryptographic
* algorithms in a highly modular and flexible manner.
*
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
*/
#include "tomcrypt.h"
ltc_math_descriptor ltc_mp;

View File

@@ -6,7 +6,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
*/
#include "tomcrypt.h"
@@ -18,9 +18,9 @@ struct ltc_prng_descriptor prng_descriptor[TAB_SIZE] = {
{ NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }
};
LTC_MUTEX_GLOBAL(ltc_prng_mutex);
LTC_MUTEX_GLOBAL(ltc_prng_mutex)
/* $Source: /cvs/libtom/libtomcrypt/src/misc/crypt/crypt_prng_descriptor.c,v $ */
/* $Revision: 1.5 $ */
/* $Date: 2005/06/19 18:00:28 $ */
/* $Revision: 1.7 $ */
/* $Date: 2006/03/31 14:15:35 $ */

View File

@@ -6,7 +6,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
*/
#include "tomcrypt.h"
@@ -32,5 +32,5 @@ int prng_is_valid(int idx)
}
/* $Source: /cvs/libtom/libtomcrypt/src/misc/crypt/crypt_prng_is_valid.c,v $ */
/* $Revision: 1.4 $ */
/* $Date: 2005/06/19 18:00:28 $ */
/* $Revision: 1.5 $ */
/* $Date: 2006/03/31 14:15:35 $ */

View File

@@ -6,7 +6,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
*/
#include "tomcrypt.h"
@@ -50,5 +50,5 @@ int register_cipher(const struct ltc_cipher_descriptor *cipher)
}
/* $Source: /cvs/libtom/libtomcrypt/src/misc/crypt/crypt_register_cipher.c,v $ */
/* $Revision: 1.4 $ */
/* $Date: 2005/06/19 18:00:28 $ */
/* $Revision: 1.5 $ */
/* $Date: 2006/03/31 14:15:35 $ */

View File

@@ -6,7 +6,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
*/
#include "tomcrypt.h"
@@ -29,7 +29,7 @@ int register_hash(const struct ltc_hash_descriptor *hash)
/* is it already registered? */
LTC_MUTEX_LOCK(&ltc_hash_mutex);
for (x = 0; x < TAB_SIZE; x++) {
if (memcmp(&hash_descriptor[x], hash, sizeof(struct ltc_hash_descriptor)) == 0) {
if (XMEMCMP(&hash_descriptor[x], hash, sizeof(struct ltc_hash_descriptor)) == 0) {
LTC_MUTEX_UNLOCK(&ltc_hash_mutex);
return x;
}
@@ -50,5 +50,5 @@ int register_hash(const struct ltc_hash_descriptor *hash)
}
/* $Source: /cvs/libtom/libtomcrypt/src/misc/crypt/crypt_register_hash.c,v $ */
/* $Revision: 1.4 $ */
/* $Date: 2005/06/19 18:00:28 $ */
/* $Revision: 1.6 $ */
/* $Date: 2006/11/01 09:28:17 $ */

View File

@@ -6,7 +6,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
*/
#include "tomcrypt.h"
@@ -29,7 +29,7 @@ int register_prng(const struct ltc_prng_descriptor *prng)
/* is it already registered? */
LTC_MUTEX_LOCK(&ltc_prng_mutex);
for (x = 0; x < TAB_SIZE; x++) {
if (memcmp(&prng_descriptor[x], prng, sizeof(struct ltc_prng_descriptor)) == 0) {
if (XMEMCMP(&prng_descriptor[x], prng, sizeof(struct ltc_prng_descriptor)) == 0) {
LTC_MUTEX_UNLOCK(&ltc_prng_mutex);
return x;
}
@@ -50,5 +50,5 @@ int register_prng(const struct ltc_prng_descriptor *prng)
}
/* $Source: /cvs/libtom/libtomcrypt/src/misc/crypt/crypt_register_prng.c,v $ */
/* $Revision: 1.5 $ */
/* $Date: 2005/06/19 18:00:28 $ */
/* $Revision: 1.7 $ */
/* $Date: 2006/11/01 09:28:17 $ */

View File

@@ -6,7 +6,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
*/
#include "tomcrypt.h"
@@ -29,7 +29,7 @@ int unregister_cipher(const struct ltc_cipher_descriptor *cipher)
/* is it already registered? */
LTC_MUTEX_LOCK(&ltc_cipher_mutex);
for (x = 0; x < TAB_SIZE; x++) {
if (memcmp(&cipher_descriptor[x], cipher, sizeof(struct ltc_cipher_descriptor)) == 0) {
if (XMEMCMP(&cipher_descriptor[x], cipher, sizeof(struct ltc_cipher_descriptor)) == 0) {
cipher_descriptor[x].name = NULL;
cipher_descriptor[x].ID = 255;
LTC_MUTEX_UNLOCK(&ltc_cipher_mutex);
@@ -41,5 +41,5 @@ int unregister_cipher(const struct ltc_cipher_descriptor *cipher)
}
/* $Source: /cvs/libtom/libtomcrypt/src/misc/crypt/crypt_unregister_cipher.c,v $ */
/* $Revision: 1.4 $ */
/* $Date: 2005/06/19 18:00:28 $ */
/* $Revision: 1.6 $ */
/* $Date: 2006/11/01 09:28:17 $ */

View File

@@ -6,7 +6,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
*/
#include "tomcrypt.h"
@@ -29,7 +29,7 @@ int unregister_hash(const struct ltc_hash_descriptor *hash)
/* is it already registered? */
LTC_MUTEX_LOCK(&ltc_hash_mutex);
for (x = 0; x < TAB_SIZE; x++) {
if (memcmp(&hash_descriptor[x], hash, sizeof(struct ltc_hash_descriptor)) == 0) {
if (XMEMCMP(&hash_descriptor[x], hash, sizeof(struct ltc_hash_descriptor)) == 0) {
hash_descriptor[x].name = NULL;
LTC_MUTEX_UNLOCK(&ltc_hash_mutex);
return CRYPT_OK;
@@ -40,5 +40,5 @@ int unregister_hash(const struct ltc_hash_descriptor *hash)
}
/* $Source: /cvs/libtom/libtomcrypt/src/misc/crypt/crypt_unregister_hash.c,v $ */
/* $Revision: 1.4 $ */
/* $Date: 2005/06/19 18:00:28 $ */
/* $Revision: 1.6 $ */
/* $Date: 2006/11/01 09:28:17 $ */

View File

@@ -6,7 +6,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
*/
#include "tomcrypt.h"
@@ -29,7 +29,7 @@ int unregister_prng(const struct ltc_prng_descriptor *prng)
/* is it already registered? */
LTC_MUTEX_LOCK(&ltc_prng_mutex);
for (x = 0; x < TAB_SIZE; x++) {
if (memcmp(&prng_descriptor[x], prng, sizeof(struct ltc_prng_descriptor)) != 0) {
if (XMEMCMP(&prng_descriptor[x], prng, sizeof(struct ltc_prng_descriptor)) != 0) {
prng_descriptor[x].name = NULL;
LTC_MUTEX_UNLOCK(&ltc_prng_mutex);
return CRYPT_OK;
@@ -40,5 +40,5 @@ int unregister_prng(const struct ltc_prng_descriptor *prng)
}
/* $Source: /cvs/libtom/libtomcrypt/src/misc/crypt/crypt_unregister_prng.c,v $ */
/* $Revision: 1.4 $ */
/* $Date: 2005/06/19 18:00:28 $ */
/* $Revision: 1.6 $ */
/* $Date: 2006/11/01 09:28:17 $ */

View File

@@ -6,7 +6,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
*/
#include "tomcrypt.h"
@@ -70,5 +70,5 @@ const char *error_to_string(int err)
/* $Source: /cvs/libtom/libtomcrypt/src/misc/error_to_string.c,v $ */
/* $Revision: 1.3 $ */
/* $Date: 2005/05/05 14:35:59 $ */
/* $Revision: 1.4 $ */
/* $Date: 2006/03/31 14:15:35 $ */

View File

@@ -1,36 +0,0 @@
/* LibTomCrypt, modular cryptographic library -- Tom St Denis
*
* LibTomCrypt is a library that provides various cryptographic
* algorithms in a highly modular and flexible manner.
*
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
*/
#include "tomcrypt.h"
/**
@file is_prime.c
Determines if integer is prime for LTC, Tom St Denis
*/
#ifdef MPI
/* figures out if a number is prime (MR test) */
int is_prime(mp_int *N, int *result)
{
int err;
LTC_ARGCHK(N != NULL);
LTC_ARGCHK(result != NULL);
if ((err = mp_prime_is_prime(N, mp_prime_rabin_miller_trials(mp_count_bits(N)), result)) != MP_OKAY) {
return mpi_to_ltc_error(err);
}
return CRYPT_OK;
}
#endif
/* $Source: /cvs/libtom/libtomcrypt/src/misc/mpi/is_prime.c,v $ */
/* $Revision: 1.3 $ */
/* $Date: 2005/05/05 14:35:59 $ */

View File

@@ -1,48 +0,0 @@
/* LibTomCrypt, modular cryptographic library -- Tom St Denis
*
* LibTomCrypt is a library that provides various cryptographic
* algorithms in a highly modular and flexible manner.
*
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
*/
#include "tomcrypt.h"
/**
@file mpi_to_ltc_error.c
Convert MPI errors to LTC, Tom St Denis
*/
#ifdef MPI
static const struct {
int mpi_code, ltc_code;
} mpi_to_ltc_codes[] = {
{ MP_OKAY , CRYPT_OK},
{ MP_MEM , CRYPT_MEM},
{ MP_VAL , CRYPT_INVALID_ARG},
};
/**
Convert a MPI error to a LTC error (Possibly the most powerful function ever! Oh wait... no)
@param err The error to convert
@return The equivalent LTC error code or CRYPT_ERROR if none found
*/
int mpi_to_ltc_error(int err)
{
int x;
for (x = 0; x < (int)(sizeof(mpi_to_ltc_codes)/sizeof(mpi_to_ltc_codes[0])); x++) {
if (err == mpi_to_ltc_codes[x].mpi_code) {
return mpi_to_ltc_codes[x].ltc_code;
}
}
return CRYPT_ERROR;
}
#endif
/* $Source: /cvs/libtom/libtomcrypt/src/misc/mpi/mpi_to_ltc_error.c,v $ */
/* $Revision: 1.3 $ */
/* $Date: 2005/05/05 14:35:59 $ */

View File

@@ -1,70 +0,0 @@
/* LibTomCrypt, modular cryptographic library -- Tom St Denis
*
* LibTomCrypt is a library that provides various cryptographic
* algorithms in a highly modular and flexible manner.
*
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
*/
#include "tomcrypt.h"
/**
@file rand_prime.c
Generate a random prime, Tom St Denis
*/
#ifdef MPI
struct rng_data {
prng_state *prng;
int wprng;
};
static int rand_prime_helper(unsigned char *dst, int len, void *dat)
{
return (int)prng_descriptor[((struct rng_data *)dat)->wprng].read(dst, len, ((struct rng_data *)dat)->prng);
}
int rand_prime(mp_int *N, long len, prng_state *prng, int wprng)
{
struct rng_data rng;
int type, err;
LTC_ARGCHK(N != NULL);
/* allow sizes between 2 and 256 bytes for a prime size */
if (len < 16 || len > 4096) {
return CRYPT_INVALID_PRIME_SIZE;
}
/* valid PRNG? Better be! */
if ((err = prng_is_valid(wprng)) != CRYPT_OK) {
return err;
}
/* setup our callback data, then world domination! */
rng.prng = prng;
rng.wprng = wprng;
/* get type */
if (len < 0) {
type = LTM_PRIME_BBS;
len = -len;
} else {
type = 0;
}
type |= LTM_PRIME_2MSB_ON;
/* New prime generation makes the code even more cryptoish-insane. Do you know what this means!!!
-- Gir: Yeah, oh wait, er, no.
*/
return mpi_to_ltc_error(mp_prime_random_ex(N, mp_prime_rabin_miller_trials(len), len, type, rand_prime_helper, &rng));
}
#endif
/* $Source: /cvs/libtom/libtomcrypt/src/misc/mpi/rand_prime.c,v $ */
/* $Revision: 1.3 $ */
/* $Date: 2005/05/05 14:35:59 $ */

View File

@@ -6,7 +6,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
*/
#include <tomcrypt.h>
@@ -102,5 +102,5 @@ LBL_ERR:
#endif
/* $Source: /cvs/libtom/libtomcrypt/src/misc/pkcs5/pkcs_5_1.c,v $ */
/* $Revision: 1.4 $ */
/* $Date: 2005/05/05 14:35:59 $ */
/* $Revision: 1.5 $ */
/* $Date: 2006/03/31 14:15:35 $ */

View File

@@ -6,7 +6,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
*/
#include <tomcrypt.h>
@@ -125,5 +125,5 @@ LBL_ERR:
/* $Source: /cvs/libtom/libtomcrypt/src/misc/pkcs5/pkcs_5_2.c,v $ */
/* $Revision: 1.4 $ */
/* $Date: 2005/05/05 14:35:59 $ */
/* $Revision: 1.5 $ */
/* $Date: 2006/03/31 14:15:35 $ */

View File

@@ -6,7 +6,7 @@
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
*/
#include "tomcrypt.h"
@@ -23,12 +23,12 @@
void zeromem(void *out, size_t outlen)
{
unsigned char *mem = out;
LTC_ARGCHK(out != NULL);
LTC_ARGCHKVD(out != NULL);
while (outlen-- > 0) {
*mem++ = 0;
}
}
/* $Source: /cvs/libtom/libtomcrypt/src/misc/zeromem.c,v $ */
/* $Revision: 1.4 $ */
/* $Date: 2005/05/05 14:35:59 $ */
/* $Revision: 1.6 $ */
/* $Date: 2006/06/09 01:38:13 $ */