diff options
author | Johannes Berg <johannes@sipsolutions.net> | 2009-04-17 23:26:17 +0200 |
---|---|---|
committer | Johannes Berg <johannes@sipsolutions.net> | 2009-04-17 23:36:23 +0200 |
commit | b7172255c545ee6784947e138df52100d7ac6364 (patch) | |
tree | 2fe1f3dfa0e8dfc7cb5e08021754effa95dd908c | |
parent | 1ea7f65712bb94eae7a0a606e859ff498d32761e (diff) | |
download | crda-b7172255c545ee6784947e138df52100d7ac6364.tar.gz crda-b7172255c545ee6784947e138df52100d7ac6364.tar.bz2 crda-b7172255c545ee6784947e138df52100d7ac6364.zip |
make openssl verification safe for multiple keys
it seems openssl caches some things in there and subsequent
uses of the same key struct fail or something -- since this
fixes it I'm not bothering trying to figure out what's wrong
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
-rw-r--r-- | reglib.c | 24 |
1 files changed, 10 insertions, 14 deletions
@@ -49,32 +49,28 @@ int crda_verify_db_signature(__u8 *db, int dblen, int siglen) unsigned int i; int ok = 0; - rsa = RSA_new(); - if (!rsa) { - fprintf(stderr, "Failed to create RSA key.\n"); - goto out; - } - if (SHA1(db, dblen, hash) != hash) { fprintf(stderr, "Failed to calculate SHA1 sum.\n"); - RSA_free(rsa); goto out; } for (i = 0; (i < sizeof(keys)/sizeof(keys[0])) && (!ok); i++) { + rsa = RSA_new(); + if (!rsa) { + fprintf(stderr, "Failed to create RSA key.\n"); + goto out; + } + rsa->e = &keys[i].e; rsa->n = &keys[i].n; - if (RSA_size(rsa) != siglen) - continue; - ok = RSA_verify(NID_sha1, hash, SHA_DIGEST_LENGTH, db + dblen, siglen, rsa) == 1; - } - rsa->e = NULL; - rsa->n = NULL; - RSA_free(rsa); + rsa->e = NULL; + rsa->n = NULL; + RSA_free(rsa); + } #endif #ifdef USE_GCRYPT |