[svn-commits] tilghman: branch tilghman/tomcrypt r89423 - in /team/tilghman/tomcrypt: inclu...
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Mon Nov 19 12:17:47 CST 2007
Author: tilghman
Date: Mon Nov 19 12:17:47 2007
New Revision: 89423
URL: http://svn.digium.com/view/asterisk?view=rev&rev=89423
Log:
Doesn't all work yet, but I need these changes synched between computers
Added:
team/tilghman/tomcrypt/include/tomcrypt (with props)
Modified:
team/tilghman/tomcrypt/include/asterisk/crypto.h
team/tilghman/tomcrypt/res/res_crypto.c
Modified: team/tilghman/tomcrypt/include/asterisk/crypto.h
URL: http://svn.digium.com/view/asterisk/team/tilghman/tomcrypt/include/asterisk/crypto.h?view=diff&rev=89423&r1=89422&r2=89423
==============================================================================
--- team/tilghman/tomcrypt/include/asterisk/crypto.h (original)
+++ team/tilghman/tomcrypt/include/asterisk/crypto.h Mon Nov 19 12:17:47 2007
@@ -59,6 +59,28 @@
struct md5_state md5;
void *data;
} ltc_hash_state;
+
+/** RSA LTC_PKCS style key */
+typedef struct Rsa_key {
+ /** Type of key, PK_PRIVATE or PK_PUBLIC */
+ int type;
+ /** The public exponent */
+ void *e;
+ /** The private exponent */
+ void *d;
+ /** The modulus */
+ void *N;
+ /** The p factor of N */
+ void *p;
+ /** The q factor of N */
+ void *q;
+ /** The 1/q mod p CRT param */
+ void *qP;
+ /** The d mod (p - 1) CRT param */
+ void *dP;
+ /** The d mod (q - 1) CRT param */
+ void *dQ;
+} ltc_rsa_key;
/*!
* \brief Retrieve a key
@@ -163,6 +185,10 @@
int ltc_sha512_process(ltc_hash_state * md, const unsigned char *in, unsigned long inlen);
int ltc_sha512_done(ltc_hash_state * md, unsigned char *hash);
+/*! \brief LTC_PKCS #1 import/export */
+int ltc_rsa_export(unsigned char *out, unsigned long *outlen, int type, ltc_rsa_key *key);
+int ltc_rsa_import(const unsigned char *in, unsigned long inlen, ltc_rsa_key *key);
+
#if defined(__cplusplus) || defined(c_plusplus)
}
#endif
Added: team/tilghman/tomcrypt/include/tomcrypt
URL: http://svn.digium.com/view/asterisk/team/tilghman/tomcrypt/include/tomcrypt?view=auto&rev=89423
==============================================================================
--- team/tilghman/tomcrypt/include/tomcrypt (added)
+++ team/tilghman/tomcrypt/include/tomcrypt Mon Nov 19 12:17:47 2007
@@ -1,0 +1,1 @@
+link ../main/tomcrypt/src/headers/
Propchange: team/tilghman/tomcrypt/include/tomcrypt
------------------------------------------------------------------------------
svn:special = *
Modified: team/tilghman/tomcrypt/res/res_crypto.c
URL: http://svn.digium.com/view/asterisk/team/tilghman/tomcrypt/res/res_crypto.c?view=diff&rev=89423&r1=89422&r2=89423
==============================================================================
--- team/tilghman/tomcrypt/res/res_crypto.c (original)
+++ team/tilghman/tomcrypt/res/res_crypto.c Mon Nov 19 12:17:47 2007
@@ -51,7 +51,6 @@
#include "asterisk/module.h"
#include "asterisk/options.h"
#include "asterisk/crypto.h"
-#include "asterisk/md5.h"
#include "asterisk/cli.h"
#include "asterisk/io.h"
#include "asterisk/lock.h"
@@ -80,7 +79,7 @@
/*! Key type (AST_KEY_PUB or AST_KEY_PRIV, along with flags from above) */
int ktype;
/*! RSA structure (if successfully loaded) */
- RSA *rsa;
+ ltc_rsa_key rsa;
/*! Whether we should be deleted */
int delme;
/*! FD for input (or -1 if no input allowed, or -2 if we needed input) */
@@ -158,8 +157,8 @@
*/
static struct ast_key *try_load_key(char *dir, char *fname, int ifd, int ofd, int *not2)
{
- int ktype = 0, found = 0;
- char *c = NULL, ffname[256];
+ int ktype = 0, found = 0, keyinlen;
+ char *c = NULL, ffname[256], keyin[8192];
unsigned char digest[16];
FILE *f;
ltc_hash_state md;
@@ -237,21 +236,15 @@
key->outfd = ofd;
/* Reset the file back to the beginning */
rewind(f);
- /* Now load the key with the right method */
- if (ktype == AST_KEY_PUBLIC)
- key->rsa = PEM_read_RSA_PUBKEY(f, NULL, pw_cb, key);
- else
- key->rsa = PEM_read_RSAPrivateKey(f, NULL, pw_cb, key);
+ /* Now load the key */
+ keyinlen = read(f, keyin, sizeof(keyin));
fclose(f);
- if (key->rsa) {
- if (RSA_size(key->rsa) == 128) {
- /* Key loaded okay */
- key->ktype &= ~KEY_NEEDS_PASSCODE;
- ast_verb(3, "Loaded %s key '%s'\n", key->ktype == AST_KEY_PUBLIC ? "PUBLIC" : "PRIVATE", key->name);
- ast_debug(1, "Key '%s' loaded OK\n", key->name);
- key->delme = 0;
- } else
- ast_log(LOG_NOTICE, "Key '%s' is not expected size.\n", key->name);
+ if (ltc_rsa_import(keyin, keyinlen, &key->rsa) == LTC_CRYPT_OK) {
+ /* Key loaded okay */
+ key->ktype &= ~KEY_NEEDS_PASSCODE;
+ ast_verb(3, "Loaded %s key '%s'\n", key->ktype == AST_KEY_PUBLIC ? "PUBLIC" : "PRIVATE", key->name);
+ ast_debug(1, "Key '%s' loaded OK\n", key->name);
+ key->delme = 0;
} else if (key->infd != -2) {
ast_log(LOG_WARNING, "Key load %s '%s' failed\n",key->ktype == AST_KEY_PUBLIC ? "PUBLIC" : "PRIVATE", key->name);
if (ofd > -1)
More information about the svn-commits
mailing list