added libtomcrypt-1.17
This commit is contained in:
committed by
Steffen Jaeckel
parent
e24b01d392
commit
bbc52b9e1b
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
#include <stdarg.h>
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
#include <stdarg.h>
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
#include <stdarg.h>
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
#include <stdarg.h>
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
@@ -65,19 +65,19 @@ int der_encode_utf8_string(const wchar_t *in, unsigned long inlen,
|
||||
x = 0;
|
||||
out[x++] = 0x0C;
|
||||
if (len < 128) {
|
||||
out[x++] = len;
|
||||
out[x++] = (unsigned char)len;
|
||||
} else if (len < 256) {
|
||||
out[x++] = 0x81;
|
||||
out[x++] = len;
|
||||
out[x++] = (unsigned char)len;
|
||||
} else if (len < 65536UL) {
|
||||
out[x++] = 0x82;
|
||||
out[x++] = (len>>8)&255;
|
||||
out[x++] = len&255;
|
||||
out[x++] = (unsigned char)((len>>8)&255);
|
||||
out[x++] = (unsigned char)(len&255);
|
||||
} else if (len < 16777216UL) {
|
||||
out[x++] = 0x83;
|
||||
out[x++] = (len>>16)&255;
|
||||
out[x++] = (len>>8)&255;
|
||||
out[x++] = len&255;
|
||||
out[x++] = (unsigned char)((len>>16)&255);
|
||||
out[x++] = (unsigned char)((len>>8)&255);
|
||||
out[x++] = (unsigned char)(len&255);
|
||||
} else {
|
||||
return CRYPT_INVALID_ARG;
|
||||
}
|
||||
@@ -85,7 +85,7 @@ int der_encode_utf8_string(const wchar_t *in, unsigned long inlen,
|
||||
/* store UTF8 */
|
||||
for (y = 0; y < inlen; y++) {
|
||||
switch (der_utf8_charsize(in[y])) {
|
||||
case 1: out[x++] = in[y]; break;
|
||||
case 1: out[x++] = (unsigned char)in[y]; break;
|
||||
case 2: out[x++] = 0xC0 | ((in[y] >> 6) & 0x1F); out[x++] = 0x80 | (in[y] & 0x3F); break;
|
||||
case 3: out[x++] = 0xE0 | ((in[y] >> 12) & 0x0F); out[x++] = 0x80 | ((in[y] >> 6) & 0x3F); out[x++] = 0x80 | (in[y] & 0x3F); break;
|
||||
case 4: out[x++] = 0xF0 | ((in[y] >> 18) & 0x07); out[x++] = 0x80 | ((in[y] >> 12) & 0x3F); out[x++] = 0x80 | ((in[y] >> 6) & 0x3F); out[x++] = 0x80 | (in[y] & 0x3F); break;
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
DSA Crypto, Tom St Denis
|
||||
*/
|
||||
|
||||
#ifdef MDSA
|
||||
#ifdef LTC_MDSA
|
||||
|
||||
/**
|
||||
Decrypt an DSA encrypted key
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
DSA Crypto, Tom St Denis
|
||||
*/
|
||||
|
||||
#ifdef MDSA
|
||||
#ifdef LTC_MDSA
|
||||
|
||||
/**
|
||||
Encrypt a symmetric key with DSA
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
DSA implementation, export key, Tom St Denis
|
||||
*/
|
||||
|
||||
#ifdef MDSA
|
||||
#ifdef LTC_MDSA
|
||||
|
||||
/**
|
||||
Export a DSA key to a binary packet
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
DSA implementation, free a DSA key, Tom St Denis
|
||||
*/
|
||||
|
||||
#ifdef MDSA
|
||||
#ifdef LTC_MDSA
|
||||
|
||||
/**
|
||||
Free a DSA key
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
DSA implementation, import a DSA key, Tom St Denis
|
||||
*/
|
||||
|
||||
#ifdef MDSA
|
||||
#ifdef LTC_MDSA
|
||||
|
||||
/**
|
||||
Import a DSA key
|
||||
@@ -71,8 +71,8 @@ int dsa_import(const unsigned char *in, unsigned long inlen, dsa_key *key)
|
||||
}
|
||||
key->qord = mp_unsigned_bin_size(key->q);
|
||||
|
||||
if (key->qord >= MDSA_MAX_GROUP || key->qord <= 15 ||
|
||||
(unsigned long)key->qord >= mp_unsigned_bin_size(key->p) || (mp_unsigned_bin_size(key->p) - key->qord) >= MDSA_DELTA) {
|
||||
if (key->qord >= LTC_MDSA_MAX_GROUP || key->qord <= 15 ||
|
||||
(unsigned long)key->qord >= mp_unsigned_bin_size(key->p) || (mp_unsigned_bin_size(key->p) - key->qord) >= LTC_MDSA_DELTA) {
|
||||
err = CRYPT_INVALID_PACKET;
|
||||
goto error;
|
||||
}
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
DSA implementation, generate a DSA key, Tom St Denis
|
||||
*/
|
||||
|
||||
#ifdef MDSA
|
||||
#ifdef LTC_MDSA
|
||||
|
||||
/**
|
||||
Create a DSA key
|
||||
@@ -41,13 +41,13 @@ int dsa_make_key(prng_state *prng, int wprng, int group_size, int modulus_size,
|
||||
}
|
||||
|
||||
/* check size */
|
||||
if (group_size >= MDSA_MAX_GROUP || group_size <= 15 ||
|
||||
group_size >= modulus_size || (modulus_size - group_size) >= MDSA_DELTA) {
|
||||
if (group_size >= LTC_MDSA_MAX_GROUP || group_size <= 15 ||
|
||||
group_size >= modulus_size || (modulus_size - group_size) >= LTC_MDSA_DELTA) {
|
||||
return CRYPT_INVALID_ARG;
|
||||
}
|
||||
|
||||
/* allocate ram */
|
||||
buf = XMALLOC(MDSA_DELTA);
|
||||
buf = XMALLOC(LTC_MDSA_DELTA);
|
||||
if (buf == NULL) {
|
||||
return CRYPT_MEM;
|
||||
}
|
||||
@@ -117,7 +117,7 @@ int dsa_make_key(prng_state *prng, int wprng, int group_size, int modulus_size,
|
||||
key->qord = group_size;
|
||||
|
||||
#ifdef LTC_CLEAN_STACK
|
||||
zeromem(buf, MDSA_DELTA);
|
||||
zeromem(buf, LTC_MDSA_DELTA);
|
||||
#endif
|
||||
|
||||
err = CRYPT_OK;
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
DSA Crypto, Tom St Denis
|
||||
*/
|
||||
|
||||
#ifdef MDSA
|
||||
#ifdef LTC_MDSA
|
||||
|
||||
/**
|
||||
Create a DSA shared secret between two keys
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
DSA implementation, sign a hash, Tom St Denis
|
||||
*/
|
||||
|
||||
#ifdef MDSA
|
||||
#ifdef LTC_MDSA
|
||||
|
||||
/**
|
||||
Sign a hash with DSA
|
||||
@@ -49,11 +49,11 @@ int dsa_sign_hash_raw(const unsigned char *in, unsigned long inlen,
|
||||
}
|
||||
|
||||
/* check group order size */
|
||||
if (key->qord >= MDSA_MAX_GROUP) {
|
||||
if (key->qord >= LTC_MDSA_MAX_GROUP) {
|
||||
return CRYPT_INVALID_ARG;
|
||||
}
|
||||
|
||||
buf = XMALLOC(MDSA_MAX_GROUP);
|
||||
buf = XMALLOC(LTC_MDSA_MAX_GROUP);
|
||||
if (buf == NULL) {
|
||||
return CRYPT_MEM;
|
||||
}
|
||||
@@ -102,7 +102,7 @@ error:
|
||||
mp_clear_multi(k, kinv, tmp, NULL);
|
||||
ERRBUF:
|
||||
#ifdef LTC_CLEAN_STACK
|
||||
zeromem(buf, MDSA_MAX_GROUP);
|
||||
zeromem(buf, LTC_MDSA_MAX_GROUP);
|
||||
#endif
|
||||
XFREE(buf);
|
||||
return err;
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
|
||||
#ifdef MDSA
|
||||
#ifdef LTC_MDSA
|
||||
|
||||
/**
|
||||
Verify a DSA signature
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
DSA implementation, verify a key, Tom St Denis
|
||||
*/
|
||||
|
||||
#ifdef MDSA
|
||||
#ifdef LTC_MDSA
|
||||
|
||||
/**
|
||||
Verify a DSA key for validity
|
||||
|
||||
+2
-2
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
|
||||
/* Implements ECC over Z/pZ for curve y^2 = x^3 - 3x + b
|
||||
@@ -21,7 +21,7 @@
|
||||
ECC Crypto, Tom St Denis
|
||||
*/
|
||||
|
||||
#ifdef MECC
|
||||
#ifdef LTC_MECC
|
||||
|
||||
/* This holds the key settings. ***MUST*** be organized by size from smallest to largest. */
|
||||
const ltc_ecc_set_type ltc_ecc_sets[] = {
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
|
||||
/* Implements ECC over Z/pZ for curve y^2 = x^3 - 3x + b
|
||||
@@ -21,7 +21,7 @@
|
||||
ECC Crypto, Tom St Denis
|
||||
*/
|
||||
|
||||
#ifdef MECC
|
||||
#ifdef LTC_MECC
|
||||
|
||||
/** ECC X9.63 (Sec. 4.3.6) uncompressed export
|
||||
@param key Key to export
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
|
||||
/* Implements ECC over Z/pZ for curve y^2 = x^3 - 3x + b
|
||||
@@ -21,7 +21,7 @@
|
||||
ECC Crypto, Tom St Denis
|
||||
*/
|
||||
|
||||
#ifdef MECC
|
||||
#ifdef LTC_MECC
|
||||
|
||||
/** Import an ANSI X9.63 format public key
|
||||
@param in The input data to read
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
|
||||
/* Implements ECC over Z/pZ for curve y^2 = x^3 - 3x + b
|
||||
@@ -21,7 +21,7 @@
|
||||
ECC Crypto, Tom St Denis
|
||||
*/
|
||||
|
||||
#ifdef MECC
|
||||
#ifdef LTC_MECC
|
||||
|
||||
/**
|
||||
Decrypt an ECC encrypted key
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
|
||||
/* Implements ECC over Z/pZ for curve y^2 = x^3 - 3x + b
|
||||
@@ -21,7 +21,7 @@
|
||||
ECC Crypto, Tom St Denis
|
||||
*/
|
||||
|
||||
#ifdef MECC
|
||||
#ifdef LTC_MECC
|
||||
|
||||
/**
|
||||
Encrypt a symmetric key with ECC
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
|
||||
/* Implements ECC over Z/pZ for curve y^2 = x^3 - 3x + b
|
||||
@@ -21,7 +21,7 @@
|
||||
ECC Crypto, Tom St Denis
|
||||
*/
|
||||
|
||||
#ifdef MECC
|
||||
#ifdef LTC_MECC
|
||||
|
||||
/**
|
||||
Export an ECC key as a binary packet
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
|
||||
/* Implements ECC over Z/pZ for curve y^2 = x^3 - 3x + b
|
||||
@@ -21,7 +21,7 @@
|
||||
ECC Crypto, Tom St Denis
|
||||
*/
|
||||
|
||||
#ifdef MECC
|
||||
#ifdef LTC_MECC
|
||||
|
||||
/**
|
||||
Free an ECC key from memory
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
|
||||
/* Implements ECC over Z/pZ for curve y^2 = x^3 - 3x + b
|
||||
@@ -21,7 +21,7 @@
|
||||
ECC Crypto, Tom St Denis
|
||||
*/
|
||||
|
||||
#ifdef MECC
|
||||
#ifdef LTC_MECC
|
||||
|
||||
/**
|
||||
Get the size of an ECC key
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
|
||||
/* Implements ECC over Z/pZ for curve y^2 = x^3 - 3x + b
|
||||
@@ -21,7 +21,7 @@
|
||||
ECC Crypto, Tom St Denis
|
||||
*/
|
||||
|
||||
#ifdef MECC
|
||||
#ifdef LTC_MECC
|
||||
|
||||
static int is_point(ecc_key *key)
|
||||
{
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
|
||||
/* Implements ECC over Z/pZ for curve y^2 = x^3 - 3x + b
|
||||
@@ -21,7 +21,7 @@
|
||||
ECC Crypto, Tom St Denis
|
||||
*/
|
||||
|
||||
#ifdef MECC
|
||||
#ifdef LTC_MECC
|
||||
|
||||
/**
|
||||
Make a new ECC key
|
||||
@@ -51,7 +51,7 @@ int ecc_make_key_ex(prng_state *prng, int wprng, ecc_key *key, const ltc_ecc_set
|
||||
{
|
||||
int err;
|
||||
ecc_point *base;
|
||||
void *prime;
|
||||
void *prime, *order;
|
||||
unsigned char *buf;
|
||||
int keysize;
|
||||
|
||||
@@ -82,7 +82,7 @@ int ecc_make_key_ex(prng_state *prng, int wprng, ecc_key *key, const ltc_ecc_set
|
||||
}
|
||||
|
||||
/* setup the key variables */
|
||||
if ((err = mp_init_multi(&key->pubkey.x, &key->pubkey.y, &key->pubkey.z, &key->k, &prime, NULL)) != CRYPT_OK) {
|
||||
if ((err = mp_init_multi(&key->pubkey.x, &key->pubkey.y, &key->pubkey.z, &key->k, &prime, &order, NULL)) != CRYPT_OK) {
|
||||
goto ERR_BUF;
|
||||
}
|
||||
base = ltc_ecc_new_point();
|
||||
@@ -93,11 +93,16 @@ int ecc_make_key_ex(prng_state *prng, int wprng, ecc_key *key, const ltc_ecc_set
|
||||
|
||||
/* read in the specs for this key */
|
||||
if ((err = mp_read_radix(prime, (char *)key->dp->prime, 16)) != CRYPT_OK) { goto errkey; }
|
||||
if ((err = mp_read_radix(order, (char *)key->dp->order, 16)) != CRYPT_OK) { goto errkey; }
|
||||
if ((err = mp_read_radix(base->x, (char *)key->dp->Gx, 16)) != CRYPT_OK) { goto errkey; }
|
||||
if ((err = mp_read_radix(base->y, (char *)key->dp->Gy, 16)) != CRYPT_OK) { goto errkey; }
|
||||
if ((err = mp_set(base->z, 1)) != CRYPT_OK) { goto errkey; }
|
||||
if ((err = mp_read_unsigned_bin(key->k, (unsigned char *)buf, keysize)) != CRYPT_OK) { goto errkey; }
|
||||
|
||||
/* the key should be smaller than the order of base point */
|
||||
if (mp_cmp(key->k, order) != LTC_MP_LT) {
|
||||
if((err = mp_mod(key->k, order, key->k)) != CRYPT_OK) { goto errkey; }
|
||||
}
|
||||
/* make the public key */
|
||||
if ((err = ltc_mp.ecc_ptmul(key->k, base, &key->pubkey, prime, 1)) != CRYPT_OK) { goto errkey; }
|
||||
key->type = PK_PRIVATE;
|
||||
@@ -109,7 +114,7 @@ errkey:
|
||||
mp_clear_multi(key->pubkey.x, key->pubkey.y, key->pubkey.z, key->k, NULL);
|
||||
cleanup:
|
||||
ltc_ecc_del_point(base);
|
||||
mp_clear(prime);
|
||||
mp_clear_multi(prime, order, NULL);
|
||||
ERR_BUF:
|
||||
#ifdef LTC_CLEAN_STACK
|
||||
zeromem(buf, ECC_MAXSIZE);
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
|
||||
/* Implements ECC over Z/pZ for curve y^2 = x^3 - 3x + b
|
||||
@@ -21,7 +21,7 @@
|
||||
ECC Crypto, Tom St Denis
|
||||
*/
|
||||
|
||||
#ifdef MECC
|
||||
#ifdef LTC_MECC
|
||||
|
||||
/**
|
||||
Create an ECC shared secret between two keys
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
|
||||
/* Implements ECC over Z/pZ for curve y^2 = x^3 - 3x + b
|
||||
@@ -21,7 +21,7 @@
|
||||
ECC Crypto, Tom St Denis
|
||||
*/
|
||||
|
||||
#ifdef MECC
|
||||
#ifdef LTC_MECC
|
||||
|
||||
/**
|
||||
Sign a message digest
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
|
||||
/* Implements ECC over Z/pZ for curve y^2 = x^3 - 3x + b
|
||||
@@ -21,7 +21,7 @@
|
||||
ECC Crypto, Tom St Denis
|
||||
*/
|
||||
|
||||
#ifdef MECC
|
||||
#ifdef LTC_MECC
|
||||
|
||||
void ecc_sizes(int *low, int *high)
|
||||
{
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
|
||||
/* Implements ECC over Z/pZ for curve y^2 = x^3 - 3x + b
|
||||
@@ -21,7 +21,7 @@
|
||||
ECC Crypto, Tom St Denis
|
||||
*/
|
||||
|
||||
#ifdef MECC
|
||||
#ifdef LTC_MECC
|
||||
|
||||
/**
|
||||
Perform on the ECC system
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
|
||||
/* Implements ECC over Z/pZ for curve y^2 = x^3 - 3x + b
|
||||
@@ -21,7 +21,7 @@
|
||||
ECC Crypto, Tom St Denis
|
||||
*/
|
||||
|
||||
#ifdef MECC
|
||||
#ifdef LTC_MECC
|
||||
|
||||
/* verify
|
||||
*
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
|
||||
/* Implements ECC over Z/pZ for curve y^2 = x^3 - 3x + b
|
||||
@@ -21,7 +21,7 @@
|
||||
ECC Crypto, Tom St Denis
|
||||
*/
|
||||
|
||||
#ifdef MECC
|
||||
#ifdef LTC_MECC
|
||||
|
||||
/** Returns whether an ECC idx is valid or not
|
||||
@param n The idx number to check
|
||||
@@ -33,7 +33,7 @@ int ltc_ecc_is_valid_idx(int n)
|
||||
|
||||
for (x = 0; ltc_ecc_sets[x].size != 0; x++);
|
||||
/* -1 is a valid index --- indicating that the domain params were supplied by the user */
|
||||
if ((n >= -1) || (n < x)) {
|
||||
if ((n >= -1) && (n < x)) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
|
||||
/* Implements ECC over Z/pZ for curve y^2 = x^3 - 3x + b
|
||||
@@ -21,7 +21,7 @@
|
||||
ECC Crypto, Tom St Denis
|
||||
*/
|
||||
|
||||
#ifdef MECC
|
||||
#ifdef LTC_MECC
|
||||
|
||||
/**
|
||||
Map a projective jacbobian point back to affine space
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
|
||||
/* Implements ECC over Z/pZ for curve y^2 = x^3 - 3x + b
|
||||
@@ -21,7 +21,7 @@
|
||||
ECC Crypto, Shamir's Trick, Tom St Denis
|
||||
*/
|
||||
|
||||
#ifdef MECC
|
||||
#ifdef LTC_MECC
|
||||
|
||||
#ifdef LTC_ECC_SHAMIR
|
||||
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
|
||||
/* Implements ECC over Z/pZ for curve y^2 = x^3 - 3x + b
|
||||
@@ -21,7 +21,7 @@
|
||||
ECC Crypto, Tom St Denis
|
||||
*/
|
||||
|
||||
#ifdef MECC
|
||||
#ifdef LTC_MECC
|
||||
#ifndef LTC_ECC_TIMING_RESISTANT
|
||||
|
||||
/* size of sliding window, don't change this! */
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
|
||||
/* Implements ECC over Z/pZ for curve y^2 = x^3 - 3x + b
|
||||
@@ -21,7 +21,7 @@
|
||||
ECC Crypto, Tom St Denis
|
||||
*/
|
||||
|
||||
#ifdef MECC
|
||||
#ifdef LTC_MECC
|
||||
|
||||
#ifdef LTC_ECC_TIMING_RESISTANT
|
||||
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
|
||||
/* Implements ECC over Z/pZ for curve y^2 = x^3 - 3x + b
|
||||
@@ -21,7 +21,7 @@
|
||||
ECC Crypto, Tom St Denis
|
||||
*/
|
||||
|
||||
#ifdef MECC
|
||||
#ifdef LTC_MECC
|
||||
|
||||
/**
|
||||
Allocate a new ECC point
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
|
||||
/* Implements ECC over Z/pZ for curve y^2 = x^3 - 3x + b
|
||||
@@ -21,7 +21,7 @@
|
||||
ECC Crypto, Tom St Denis
|
||||
*/
|
||||
|
||||
#if defined(MECC) && (!defined(MECC_ACCEL) || defined(LTM_DESC))
|
||||
#if defined(LTC_MECC) && (!defined(LTC_MECC_ACCEL) || defined(LTM_LTC_DESC))
|
||||
|
||||
/**
|
||||
Add two ECC points
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
|
||||
/* Implements ECC over Z/pZ for curve y^2 = x^3 - 3x + b
|
||||
@@ -21,7 +21,7 @@
|
||||
ECC Crypto, Tom St Denis
|
||||
*/
|
||||
|
||||
#if defined(MECC) && (!defined(MECC_ACCEL) || defined(LTM_DESC))
|
||||
#if defined(LTC_MECC) && (!defined(LTC_MECC_ACCEL) || defined(LTM_LTC_DESC))
|
||||
|
||||
/**
|
||||
Double an ECC point
|
||||
|
||||
@@ -6,19 +6,19 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
/**
|
||||
@file katja_decrypt_key.c
|
||||
Katja PKCS #1 OAEP Decryption, Tom St Denis
|
||||
Katja LTC_PKCS #1 OAEP Decryption, Tom St Denis
|
||||
*/
|
||||
|
||||
#ifdef MKAT
|
||||
|
||||
/**
|
||||
(PKCS #1 v2.0) decrypt then OAEP depad
|
||||
(LTC_PKCS #1 v2.0) decrypt then OAEP depad
|
||||
@param in The ciphertext
|
||||
@param inlen The length of the ciphertext (octets)
|
||||
@param out [out] The plaintext
|
||||
@@ -94,7 +94,7 @@ int katja_decrypt_key(const unsigned char *in, unsigned long inlen,
|
||||
return err;
|
||||
}
|
||||
|
||||
#endif /* MRSA */
|
||||
#endif /* LTC_MRSA */
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -6,19 +6,19 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
/**
|
||||
@file katja_encrypt_key.c
|
||||
Katja PKCS-style OAEP encryption, Tom St Denis
|
||||
Katja LTC_PKCS-style OAEP encryption, Tom St Denis
|
||||
*/
|
||||
|
||||
#ifdef MKAT
|
||||
|
||||
/**
|
||||
(PKCS #1 v2.0) OAEP pad then encrypt
|
||||
(LTC_PKCS #1 v2.0) OAEP pad then encrypt
|
||||
@param in The plaintext
|
||||
@param inlen The length of the plaintext (octets)
|
||||
@param out [out] The ciphertext
|
||||
@@ -80,7 +80,7 @@ int katja_encrypt_key(const unsigned char *in, unsigned long inlen,
|
||||
return katja_exptmod(out, x, out, outlen, PK_PUBLIC, key);
|
||||
}
|
||||
|
||||
#endif /* MRSA */
|
||||
#endif /* LTC_MRSA */
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
|
||||
@@ -6,13 +6,13 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
/**
|
||||
@file katja_export.c
|
||||
Export Katja PKCS-style keys, Tom St Denis
|
||||
Export Katja LTC_PKCS-style keys, Tom St Denis
|
||||
*/
|
||||
|
||||
#ifdef MKAT
|
||||
@@ -68,7 +68,7 @@ int katja_export(unsigned char *out, unsigned long *outlen, int type, katja_key
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* MRSA */
|
||||
#endif /* LTC_MRSA */
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
|
||||
@@ -6,13 +6,13 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
/**
|
||||
@file katja_exptmod.c
|
||||
Katja PKCS-style exptmod, Tom St Denis
|
||||
Katja LTC_PKCS-style exptmod, Tom St Denis
|
||||
*/
|
||||
|
||||
#ifdef MKAT
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
|
||||
@@ -6,19 +6,19 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
/**
|
||||
@file katja_import.c
|
||||
Import a PKCS-style Katja key, Tom St Denis
|
||||
Import a LTC_PKCS-style Katja key, Tom St Denis
|
||||
*/
|
||||
|
||||
#ifdef MKAT
|
||||
|
||||
/**
|
||||
Import an KatjaPublicKey or KatjaPrivateKey [two-prime only, only support >= 1024-bit keys, defined in PKCS #1 v2.1]
|
||||
Import an KatjaPublicKey or KatjaPrivateKey [two-prime only, only support >= 1024-bit keys, defined in LTC_PKCS #1 v2.1]
|
||||
@param in The packet to import from
|
||||
@param inlen It's length (octets)
|
||||
@param key [out] Destination for newly imported key
|
||||
@@ -73,7 +73,7 @@ LBL_ERR:
|
||||
return err;
|
||||
}
|
||||
|
||||
#endif /* MRSA */
|
||||
#endif /* LTC_MRSA */
|
||||
|
||||
|
||||
/* $Source$ */
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
@@ -15,14 +15,14 @@
|
||||
Integer to Octet I2OSP, Tom St Denis
|
||||
*/
|
||||
|
||||
#ifdef PKCS_1
|
||||
#ifdef LTC_PKCS_1
|
||||
|
||||
/* always stores the same # of bytes, pads with leading zero bytes
|
||||
as required
|
||||
*/
|
||||
|
||||
/**
|
||||
PKCS #1 Integer to binary
|
||||
LTC_PKCS #1 Integer to binary
|
||||
@param n The integer to store
|
||||
@param modulus_len The length of the RSA modulus
|
||||
@param out [out] The destination for the integer
|
||||
@@ -43,7 +43,7 @@ int pkcs_1_i2osp(void *n, unsigned long modulus_len, unsigned char *out)
|
||||
return mp_to_unsigned_bin(n, out+(modulus_len-size));
|
||||
}
|
||||
|
||||
#endif /* PKCS_1 */
|
||||
#endif /* LTC_PKCS_1 */
|
||||
|
||||
|
||||
/* $Source$ */
|
||||
|
||||
@@ -6,19 +6,19 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
/**
|
||||
@file pkcs_1_mgf1.c
|
||||
The Mask Generation Function (MGF1) for PKCS #1, Tom St Denis
|
||||
The Mask Generation Function (MGF1) for LTC_PKCS #1, Tom St Denis
|
||||
*/
|
||||
|
||||
#ifdef PKCS_1
|
||||
#ifdef LTC_PKCS_1
|
||||
|
||||
/**
|
||||
Perform PKCS #1 MGF1 (internal)
|
||||
Perform LTC_PKCS #1 MGF1 (internal)
|
||||
@param seed The seed for MGF1
|
||||
@param seedlen The length of the seed
|
||||
@param hash_idx The index of the hash desired
|
||||
@@ -101,7 +101,7 @@ LBL_ERR:
|
||||
return err;
|
||||
}
|
||||
|
||||
#endif /* PKCS_1 */
|
||||
#endif /* LTC_PKCS_1 */
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
|
||||
@@ -6,19 +6,19 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
/**
|
||||
@file pkcs_1_oaep_decode.c
|
||||
OAEP Padding for PKCS #1, Tom St Denis
|
||||
OAEP Padding for LTC_PKCS #1, Tom St Denis
|
||||
*/
|
||||
|
||||
#ifdef PKCS_1
|
||||
#ifdef LTC_PKCS_1
|
||||
|
||||
/**
|
||||
PKCS #1 v2.00 OAEP decode
|
||||
LTC_PKCS #1 v2.00 OAEP decode
|
||||
@param msg The encoded data to decode
|
||||
@param msglen The length of the encoded data (octets)
|
||||
@param lparam The session or system data (can be NULL)
|
||||
@@ -182,7 +182,7 @@ LBL_ERR:
|
||||
return err;
|
||||
}
|
||||
|
||||
#endif /* PKCS_1 */
|
||||
#endif /* LTC_PKCS_1 */
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
|
||||
@@ -6,19 +6,19 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
/**
|
||||
@file pkcs_1_oaep_encode.c
|
||||
OAEP Padding for PKCS #1, Tom St Denis
|
||||
OAEP Padding for LTC_PKCS #1, Tom St Denis
|
||||
*/
|
||||
|
||||
#ifdef PKCS_1
|
||||
#ifdef LTC_PKCS_1
|
||||
|
||||
/**
|
||||
PKCS #1 v2.00 OAEP encode
|
||||
LTC_PKCS #1 v2.00 OAEP encode
|
||||
@param msg The data to encode
|
||||
@param msglen The length of the data to encode (octets)
|
||||
@param lparam A session or system parameter (can be NULL)
|
||||
@@ -165,7 +165,7 @@ LBL_ERR:
|
||||
return err;
|
||||
}
|
||||
|
||||
#endif /* PKCS_1 */
|
||||
#endif /* LTC_PKCS_1 */
|
||||
|
||||
|
||||
/* $Source$ */
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
@file pkcs_1_os2ip.c
|
||||
Octet to Integer OS2IP, Tom St Denis
|
||||
*/
|
||||
#ifdef PKCS_1
|
||||
#ifdef LTC_PKCS_1
|
||||
|
||||
/**
|
||||
Read a binary string into an mp_int
|
||||
@@ -28,7 +28,7 @@ int pkcs_1_os2ip(void *n, unsigned char *in, unsigned long inlen)
|
||||
return mp_read_unsigned_bin(n, in, inlen);
|
||||
}
|
||||
|
||||
#endif /* PKCS_1 */
|
||||
#endif /* LTC_PKCS_1 */
|
||||
|
||||
|
||||
/* $Source$ */
|
||||
|
||||
@@ -6,19 +6,19 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
/**
|
||||
@file pkcs_1_pss_decode.c
|
||||
PKCS #1 PSS Signature Padding, Tom St Denis
|
||||
LTC_PKCS #1 PSS Signature Padding, Tom St Denis
|
||||
*/
|
||||
|
||||
#ifdef PKCS_1
|
||||
#ifdef LTC_PKCS_1
|
||||
|
||||
/**
|
||||
PKCS #1 v2.00 PSS decode
|
||||
LTC_PKCS #1 v2.00 PSS decode
|
||||
@param msghash The hash to verify
|
||||
@param msghashlen The length of the hash (octets)
|
||||
@param sig The signature data (encoded data)
|
||||
@@ -170,7 +170,7 @@ LBL_ERR:
|
||||
return err;
|
||||
}
|
||||
|
||||
#endif /* PKCS_1 */
|
||||
#endif /* LTC_PKCS_1 */
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
|
||||
@@ -6,19 +6,19 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
/**
|
||||
@file pkcs_1_pss_encode.c
|
||||
PKCS #1 PSS Signature Padding, Tom St Denis
|
||||
LTC_PKCS #1 PSS Signature Padding, Tom St Denis
|
||||
*/
|
||||
|
||||
#ifdef PKCS_1
|
||||
#ifdef LTC_PKCS_1
|
||||
|
||||
/**
|
||||
PKCS #1 v2.00 Signature Encoding
|
||||
LTC_PKCS #1 v2.00 Signature Encoding
|
||||
@param msghash The hash to encode
|
||||
@param msghashlen The length of the hash (octets)
|
||||
@param saltlen The length of the salt desired (octets)
|
||||
@@ -168,7 +168,7 @@ LBL_ERR:
|
||||
return err;
|
||||
}
|
||||
|
||||
#endif /* PKCS_1 */
|
||||
#endif /* LTC_PKCS_1 */
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
|
||||
@@ -6,18 +6,18 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
/** @file pkcs_1_v1_5_decode.c
|
||||
*
|
||||
* PKCS #1 v1.5 Padding. (Andreas Lange)
|
||||
* LTC_PKCS #1 v1.5 Padding. (Andreas Lange)
|
||||
*/
|
||||
|
||||
#ifdef PKCS_1
|
||||
#ifdef LTC_PKCS_1
|
||||
|
||||
/** @brief PKCS #1 v1.5 decode.
|
||||
/** @brief LTC_PKCS #1 v1.5 decode.
|
||||
*
|
||||
* @param msg The encoded data to decode
|
||||
* @param msglen The length of the encoded data (octets)
|
||||
@@ -58,7 +58,7 @@ int pkcs_1_v1_5_decode(const unsigned char *msg,
|
||||
goto bail;
|
||||
}
|
||||
|
||||
if (block_type == LTC_PKCS_1_EME) {
|
||||
if (block_type == LTC_LTC_PKCS_1_EME) {
|
||||
for (i = 2; i < modulus_len; i++) {
|
||||
/* separator */
|
||||
if (msg[i] == 0x00) { break; }
|
||||
@@ -103,7 +103,7 @@ bail:
|
||||
return result;
|
||||
} /* pkcs_1_v1_5_decode */
|
||||
|
||||
#endif /* #ifdef PKCS_1 */
|
||||
#endif /* #ifdef LTC_PKCS_1 */
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
|
||||
@@ -6,25 +6,25 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
/*! \file pkcs_1_v1_5_encode.c
|
||||
*
|
||||
* PKCS #1 v1.5 Padding (Andreas Lange)
|
||||
* LTC_PKCS #1 v1.5 Padding (Andreas Lange)
|
||||
*/
|
||||
|
||||
#ifdef PKCS_1
|
||||
#ifdef LTC_PKCS_1
|
||||
|
||||
/*! \brief PKCS #1 v1.5 encode.
|
||||
/*! \brief LTC_PKCS #1 v1.5 encode.
|
||||
*
|
||||
* \param msg The data to encode
|
||||
* \param msglen The length of the data to encode (octets)
|
||||
* \param block_type Block type to use in padding (\sa ltc_pkcs_1_v1_5_blocks)
|
||||
* \param modulus_bitlen The bit length of the RSA modulus
|
||||
* \param prng An active PRNG state (only for LTC_PKCS_1_EME)
|
||||
* \param prng_idx The index of the PRNG desired (only for LTC_PKCS_1_EME)
|
||||
* \param prng An active PRNG state (only for LTC_LTC_PKCS_1_EME)
|
||||
* \param prng_idx The index of the PRNG desired (only for LTC_LTC_PKCS_1_EME)
|
||||
* \param out [out] The destination for the encoded data
|
||||
* \param outlen [in/out] The max size and resulting size of the encoded data
|
||||
*
|
||||
@@ -44,12 +44,12 @@ int pkcs_1_v1_5_encode(const unsigned char *msg,
|
||||
int result;
|
||||
|
||||
/* valid block_type? */
|
||||
if ((block_type != LTC_PKCS_1_EMSA) &&
|
||||
(block_type != LTC_PKCS_1_EME)) {
|
||||
if ((block_type != LTC_LTC_PKCS_1_EMSA) &&
|
||||
(block_type != LTC_LTC_PKCS_1_EME)) {
|
||||
return CRYPT_PK_INVALID_PADDING;
|
||||
}
|
||||
|
||||
if (block_type == LTC_PKCS_1_EME) { /* encryption padding, we need a valid PRNG */
|
||||
if (block_type == LTC_LTC_PKCS_1_EME) { /* encryption padding, we need a valid PRNG */
|
||||
if ((result = prng_is_valid(prng_idx)) != CRYPT_OK) {
|
||||
return result;
|
||||
}
|
||||
@@ -72,7 +72,7 @@ int pkcs_1_v1_5_encode(const unsigned char *msg,
|
||||
ps = &out[2];
|
||||
ps_len = modulus_len - msglen - 3;
|
||||
|
||||
if (block_type == LTC_PKCS_1_EME) {
|
||||
if (block_type == LTC_LTC_PKCS_1_EME) {
|
||||
/* now choose a random ps */
|
||||
if (prng_descriptor[prng_idx].read(ps, ps_len, prng) != ps_len) {
|
||||
result = CRYPT_ERROR_READPRNG;
|
||||
@@ -104,7 +104,7 @@ bail:
|
||||
return result;
|
||||
} /* pkcs_1_v1_5_encode */
|
||||
|
||||
#endif /* #ifdef PKCS_1 */
|
||||
#endif /* #ifdef LTC_PKCS_1 */
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
|
||||
@@ -6,19 +6,19 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
/**
|
||||
@file rsa_decrypt_key.c
|
||||
RSA PKCS #1 Decryption, Tom St Denis and Andreas Lange
|
||||
RSA LTC_PKCS #1 Decryption, Tom St Denis and Andreas Lange
|
||||
*/
|
||||
|
||||
#ifdef MRSA
|
||||
#ifdef LTC_MRSA
|
||||
|
||||
/**
|
||||
PKCS #1 decrypt then v1.5 or OAEP depad
|
||||
LTC_PKCS #1 decrypt then v1.5 or OAEP depad
|
||||
@param in The ciphertext
|
||||
@param inlen The length of the ciphertext (octets)
|
||||
@param out [out] The plaintext
|
||||
@@ -26,7 +26,7 @@
|
||||
@param lparam The system "lparam" value
|
||||
@param lparamlen The length of the lparam value (octets)
|
||||
@param hash_idx The index of the hash desired
|
||||
@param padding Type of padding (LTC_PKCS_1_OAEP or LTC_PKCS_1_V1_5)
|
||||
@param padding Type of padding (LTC_LTC_PKCS_1_OAEP or LTC_LTC_PKCS_1_V1_5)
|
||||
@param stat [out] Result of the decryption, 1==valid, 0==invalid
|
||||
@param key The corresponding private RSA key
|
||||
@return CRYPT_OK if succcessul (even if invalid)
|
||||
@@ -51,12 +51,12 @@ int rsa_decrypt_key_ex(const unsigned char *in, unsigned long inlen,
|
||||
|
||||
/* valid padding? */
|
||||
|
||||
if ((padding != LTC_PKCS_1_V1_5) &&
|
||||
(padding != LTC_PKCS_1_OAEP)) {
|
||||
if ((padding != LTC_LTC_PKCS_1_V1_5) &&
|
||||
(padding != LTC_LTC_PKCS_1_OAEP)) {
|
||||
return CRYPT_PK_INVALID_PADDING;
|
||||
}
|
||||
|
||||
if (padding == LTC_PKCS_1_OAEP) {
|
||||
if (padding == LTC_LTC_PKCS_1_OAEP) {
|
||||
/* valid hash ? */
|
||||
if ((err = hash_is_valid(hash_idx)) != CRYPT_OK) {
|
||||
return err;
|
||||
@@ -85,20 +85,20 @@ int rsa_decrypt_key_ex(const unsigned char *in, unsigned long inlen,
|
||||
return err;
|
||||
}
|
||||
|
||||
if (padding == LTC_PKCS_1_OAEP) {
|
||||
if (padding == LTC_LTC_PKCS_1_OAEP) {
|
||||
/* now OAEP decode the packet */
|
||||
err = pkcs_1_oaep_decode(tmp, x, lparam, lparamlen, modulus_bitlen, hash_idx,
|
||||
out, outlen, stat);
|
||||
} else {
|
||||
/* 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);
|
||||
/* now LTC_PKCS #1 v1.5 depad the packet */
|
||||
err = pkcs_1_v1_5_decode(tmp, x, LTC_LTC_PKCS_1_EME, modulus_bitlen, out, outlen, stat);
|
||||
}
|
||||
|
||||
XFREE(tmp);
|
||||
return err;
|
||||
}
|
||||
|
||||
#endif /* MRSA */
|
||||
#endif /* LTC_MRSA */
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
|
||||
@@ -6,19 +6,19 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
/**
|
||||
@file rsa_encrypt_key.c
|
||||
RSA PKCS #1 encryption, Tom St Denis and Andreas Lange
|
||||
RSA LTC_PKCS #1 encryption, Tom St Denis and Andreas Lange
|
||||
*/
|
||||
|
||||
#ifdef MRSA
|
||||
#ifdef LTC_MRSA
|
||||
|
||||
/**
|
||||
(PKCS #1 v2.0) OAEP pad then encrypt
|
||||
(LTC_PKCS #1 v2.0) OAEP pad then encrypt
|
||||
@param in The plaintext
|
||||
@param inlen The length of the plaintext (octets)
|
||||
@param out [out] The ciphertext
|
||||
@@ -28,7 +28,7 @@
|
||||
@param prng An active PRNG
|
||||
@param prng_idx The index of the desired prng
|
||||
@param hash_idx The index of the desired hash
|
||||
@param padding Type of padding (LTC_PKCS_1_OAEP or LTC_PKCS_1_V1_5)
|
||||
@param padding Type of padding (LTC_LTC_PKCS_1_OAEP or LTC_LTC_PKCS_1_V1_5)
|
||||
@param key The RSA key to encrypt to
|
||||
@return CRYPT_OK if successful
|
||||
*/
|
||||
@@ -46,8 +46,8 @@ int rsa_encrypt_key_ex(const unsigned char *in, unsigned long inlen,
|
||||
LTC_ARGCHK(key != NULL);
|
||||
|
||||
/* valid padding? */
|
||||
if ((padding != LTC_PKCS_1_V1_5) &&
|
||||
(padding != LTC_PKCS_1_OAEP)) {
|
||||
if ((padding != LTC_LTC_PKCS_1_V1_5) &&
|
||||
(padding != LTC_LTC_PKCS_1_OAEP)) {
|
||||
return CRYPT_PK_INVALID_PADDING;
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ int rsa_encrypt_key_ex(const unsigned char *in, unsigned long inlen,
|
||||
return err;
|
||||
}
|
||||
|
||||
if (padding == LTC_PKCS_1_OAEP) {
|
||||
if (padding == LTC_LTC_PKCS_1_OAEP) {
|
||||
/* valid hash? */
|
||||
if ((err = hash_is_valid(hash_idx)) != CRYPT_OK) {
|
||||
return err;
|
||||
@@ -73,7 +73,7 @@ int rsa_encrypt_key_ex(const unsigned char *in, unsigned long inlen,
|
||||
return CRYPT_BUFFER_OVERFLOW;
|
||||
}
|
||||
|
||||
if (padding == LTC_PKCS_1_OAEP) {
|
||||
if (padding == LTC_LTC_PKCS_1_OAEP) {
|
||||
/* OAEP pad the key */
|
||||
x = *outlen;
|
||||
if ((err = pkcs_1_oaep_encode(in, inlen, lparam,
|
||||
@@ -82,20 +82,20 @@ int rsa_encrypt_key_ex(const unsigned char *in, unsigned long inlen,
|
||||
return err;
|
||||
}
|
||||
} else {
|
||||
/* PKCS #1 v1.5 pad the key */
|
||||
/* LTC_PKCS #1 v1.5 pad the key */
|
||||
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_LTC_PKCS_1_EME,
|
||||
modulus_bitlen, prng, prng_idx,
|
||||
out, &x)) != CRYPT_OK) {
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
/* rsa exptmod the OAEP or PKCS #1 v1.5 pad */
|
||||
/* rsa exptmod the OAEP or LTC_PKCS #1 v1.5 pad */
|
||||
return ltc_mp.rsa_me(out, x, out, outlen, PK_PUBLIC, key);
|
||||
}
|
||||
|
||||
#endif /* MRSA */
|
||||
#endif /* LTC_MRSA */
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
|
||||
@@ -6,19 +6,19 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
/**
|
||||
@file rsa_export.c
|
||||
Export RSA PKCS keys, Tom St Denis
|
||||
Export RSA LTC_PKCS keys, Tom St Denis
|
||||
*/
|
||||
|
||||
#ifdef MRSA
|
||||
#ifdef LTC_MRSA
|
||||
|
||||
/**
|
||||
This will export either an RSAPublicKey or RSAPrivateKey [defined in PKCS #1 v2.1]
|
||||
This will export either an RSAPublicKey or RSAPrivateKey [defined in LTC_PKCS #1 v2.1]
|
||||
@param out [out] Destination 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)
|
||||
@@ -62,7 +62,7 @@ int rsa_export(unsigned char *out, unsigned long *outlen, int type, rsa_key *key
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* MRSA */
|
||||
#endif /* LTC_MRSA */
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
|
||||
@@ -6,16 +6,16 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
/**
|
||||
@file rsa_exptmod.c
|
||||
RSA PKCS exptmod, Tom St Denis
|
||||
RSA LTC_PKCS exptmod, Tom St Denis
|
||||
*/
|
||||
|
||||
#ifdef MRSA
|
||||
#ifdef LTC_MRSA
|
||||
|
||||
/**
|
||||
Compute an RSA modular exponentiation
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
Free an RSA key, Tom St Denis
|
||||
*/
|
||||
|
||||
#ifdef MRSA
|
||||
#ifdef LTC_MRSA
|
||||
|
||||
/**
|
||||
Free an RSA key from memory
|
||||
|
||||
@@ -6,19 +6,19 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
/**
|
||||
@file rsa_import.c
|
||||
Import a PKCS RSA key, Tom St Denis
|
||||
Import a LTC_PKCS RSA key, Tom St Denis
|
||||
*/
|
||||
|
||||
#ifdef MRSA
|
||||
#ifdef LTC_MRSA
|
||||
|
||||
/**
|
||||
Import an RSAPublicKey or RSAPrivateKey [two-prime only, only support >= 1024-bit keys, defined in PKCS #1 v2.1]
|
||||
Import an RSAPublicKey or RSAPrivateKey [two-prime only, only support >= 1024-bit keys, defined in LTC_PKCS #1 v2.1]
|
||||
@param in The packet to import from
|
||||
@param inlen It's length (octets)
|
||||
@param key [out] Destination for newly imported key
|
||||
@@ -87,7 +87,7 @@ int rsa_import(const unsigned char *in, unsigned long inlen, rsa_key *key)
|
||||
}
|
||||
XFREE(tmpbuf);
|
||||
|
||||
/* not SSL public key, try to match against PKCS #1 standards */
|
||||
/* not SSL public key, try to match against LTC_PKCS #1 standards */
|
||||
if ((err = der_decode_sequence_multi(in, inlen,
|
||||
LTC_ASN1_INTEGER, 1UL, key->N,
|
||||
LTC_ASN1_EOL, 0UL, NULL)) != CRYPT_OK) {
|
||||
@@ -135,7 +135,7 @@ LBL_ERR:
|
||||
return err;
|
||||
}
|
||||
|
||||
#endif /* MRSA */
|
||||
#endif /* LTC_MRSA */
|
||||
|
||||
|
||||
/* $Source$ */
|
||||
|
||||
@@ -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.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
RSA key generation, Tom St Denis
|
||||
*/
|
||||
|
||||
#ifdef MRSA
|
||||
#ifdef LTC_MRSA
|
||||
|
||||
/**
|
||||
Create an RSA key
|
||||
|
||||
+11
-11
@@ -6,24 +6,24 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
/**
|
||||
@file rsa_sign_hash.c
|
||||
RSA PKCS #1 v1.5 and v2 PSS sign hash, Tom St Denis and Andreas Lange
|
||||
RSA LTC_PKCS #1 v1.5 and v2 PSS sign hash, Tom St Denis and Andreas Lange
|
||||
*/
|
||||
|
||||
#ifdef MRSA
|
||||
#ifdef LTC_MRSA
|
||||
|
||||
/**
|
||||
PKCS #1 pad then sign
|
||||
LTC_PKCS #1 pad then sign
|
||||
@param in The hash to sign
|
||||
@param inlen The length of the hash to sign (octets)
|
||||
@param out [out] The signature
|
||||
@param outlen [in/out] The max size and resulting size of the signature
|
||||
@param padding Type of padding (LTC_PKCS_1_PSS or LTC_PKCS_1_V1_5)
|
||||
@param padding Type of padding (LTC_LTC_PKCS_1_PSS or LTC_LTC_PKCS_1_V1_5)
|
||||
@param prng An active PRNG state
|
||||
@param prng_idx The index of the PRNG desired
|
||||
@param hash_idx The index of the hash desired
|
||||
@@ -47,11 +47,11 @@ int rsa_sign_hash_ex(const unsigned char *in, unsigned long inlen,
|
||||
LTC_ARGCHK(key != NULL);
|
||||
|
||||
/* valid padding? */
|
||||
if ((padding != LTC_PKCS_1_V1_5) && (padding != LTC_PKCS_1_PSS)) {
|
||||
if ((padding != LTC_LTC_PKCS_1_V1_5) && (padding != LTC_LTC_PKCS_1_PSS)) {
|
||||
return CRYPT_PK_INVALID_PADDING;
|
||||
}
|
||||
|
||||
if (padding == LTC_PKCS_1_PSS) {
|
||||
if (padding == LTC_LTC_PKCS_1_PSS) {
|
||||
/* valid prng and hash ? */
|
||||
if ((err = prng_is_valid(prng_idx)) != CRYPT_OK) {
|
||||
return err;
|
||||
@@ -71,7 +71,7 @@ int rsa_sign_hash_ex(const unsigned char *in, unsigned long inlen,
|
||||
return CRYPT_BUFFER_OVERFLOW;
|
||||
}
|
||||
|
||||
if (padding == LTC_PKCS_1_PSS) {
|
||||
if (padding == LTC_LTC_PKCS_1_PSS) {
|
||||
/* PSS pad the key */
|
||||
x = *outlen;
|
||||
if ((err = pkcs_1_pss_encode(in, inlen, saltlen, prng, prng_idx,
|
||||
@@ -79,7 +79,7 @@ int rsa_sign_hash_ex(const unsigned char *in, unsigned long inlen,
|
||||
return err;
|
||||
}
|
||||
} else {
|
||||
/* PKCS #1 v1.5 pad the hash */
|
||||
/* LTC_PKCS #1 v1.5 pad the hash */
|
||||
unsigned char *tmpin;
|
||||
ltc_asn1_list digestinfo[2], siginfo[2];
|
||||
|
||||
@@ -114,7 +114,7 @@ int rsa_sign_hash_ex(const unsigned char *in, unsigned long inlen,
|
||||
}
|
||||
|
||||
x = *outlen;
|
||||
if ((err = pkcs_1_v1_5_encode(tmpin, y, LTC_PKCS_1_EMSA,
|
||||
if ((err = pkcs_1_v1_5_encode(tmpin, y, LTC_LTC_PKCS_1_EMSA,
|
||||
modulus_bitlen, NULL, 0,
|
||||
out, &x)) != CRYPT_OK) {
|
||||
XFREE(tmpin);
|
||||
@@ -127,7 +127,7 @@ int rsa_sign_hash_ex(const unsigned char *in, unsigned long inlen,
|
||||
return ltc_mp.rsa_me(out, x, out, outlen, PK_PRIVATE, key);
|
||||
}
|
||||
|
||||
#endif /* MRSA */
|
||||
#endif /* LTC_MRSA */
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
|
||||
@@ -6,24 +6,24 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
/**
|
||||
@file rsa_verify_hash.c
|
||||
RSA PKCS #1 v1.5 or v2 PSS signature verification, Tom St Denis and Andreas Lange
|
||||
RSA LTC_PKCS #1 v1.5 or v2 PSS signature verification, Tom St Denis and Andreas Lange
|
||||
*/
|
||||
|
||||
#ifdef MRSA
|
||||
#ifdef LTC_MRSA
|
||||
|
||||
/**
|
||||
PKCS #1 de-sign then v1.5 or PSS depad
|
||||
LTC_PKCS #1 de-sign then v1.5 or PSS depad
|
||||
@param sig The signature data
|
||||
@param siglen The length of the signature data (octets)
|
||||
@param hash The hash of the message that was signed
|
||||
@param hashlen The length of the hash of the message that was signed (octets)
|
||||
@param padding Type of padding (LTC_PKCS_1_PSS or LTC_PKCS_1_V1_5)
|
||||
@param padding Type of padding (LTC_LTC_PKCS_1_PSS or LTC_LTC_PKCS_1_V1_5)
|
||||
@param hash_idx The index of the desired hash
|
||||
@param saltlen The length of the salt used during signature
|
||||
@param stat [out] The result of the signature comparison, 1==valid, 0==invalid
|
||||
@@ -50,12 +50,12 @@ int rsa_verify_hash_ex(const unsigned char *sig, unsigned long siglen,
|
||||
|
||||
/* valid padding? */
|
||||
|
||||
if ((padding != LTC_PKCS_1_V1_5) &&
|
||||
(padding != LTC_PKCS_1_PSS)) {
|
||||
if ((padding != LTC_LTC_PKCS_1_V1_5) &&
|
||||
(padding != LTC_LTC_PKCS_1_PSS)) {
|
||||
return CRYPT_PK_INVALID_PADDING;
|
||||
}
|
||||
|
||||
if (padding == LTC_PKCS_1_PSS) {
|
||||
if (padding == LTC_LTC_PKCS_1_PSS) {
|
||||
/* valid hash ? */
|
||||
if ((err = hash_is_valid(hash_idx)) != CRYPT_OK) {
|
||||
return err;
|
||||
@@ -90,11 +90,11 @@ int rsa_verify_hash_ex(const unsigned char *sig, unsigned long siglen,
|
||||
return CRYPT_INVALID_PACKET;
|
||||
}
|
||||
|
||||
if (padding == LTC_PKCS_1_PSS) {
|
||||
if (padding == LTC_LTC_PKCS_1_PSS) {
|
||||
/* PSS decode and verify it */
|
||||
err = pkcs_1_pss_decode(hash, hashlen, tmpbuf, x, saltlen, hash_idx, modulus_bitlen, stat);
|
||||
} else {
|
||||
/* PKCS #1 v1.5 decode it */
|
||||
/* LTC_PKCS #1 v1.5 decode it */
|
||||
unsigned char *out;
|
||||
unsigned long outlen, loid[16];
|
||||
int decoded;
|
||||
@@ -114,7 +114,7 @@ int rsa_verify_hash_ex(const unsigned char *sig, unsigned long siglen,
|
||||
goto bail_2;
|
||||
}
|
||||
|
||||
if ((err = pkcs_1_v1_5_decode(tmpbuf, x, LTC_PKCS_1_EMSA, modulus_bitlen, out, &outlen, &decoded)) != CRYPT_OK) {
|
||||
if ((err = pkcs_1_v1_5_decode(tmpbuf, x, LTC_LTC_PKCS_1_EMSA, modulus_bitlen, out, &outlen, &decoded)) != CRYPT_OK) {
|
||||
XFREE(out);
|
||||
goto bail_2;
|
||||
}
|
||||
@@ -160,7 +160,7 @@ bail_2:
|
||||
return err;
|
||||
}
|
||||
|
||||
#endif /* MRSA */
|
||||
#endif /* LTC_MRSA */
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
|
||||
Reference in New Issue
Block a user