Commit 38f04a78 authored by Niels Möller's avatar Niels Möller
Browse files

New define WITH_PUBLIC_KEY, and new configure flag

--disable-public-key. Updated rsa-files to check for that, rather
than for HAVE_LIBGMP.

Rev: src/nettle/rsa-keygen.c:1.3
Rev: src/nettle/rsa.c:1.8
Rev: src/nettle/rsa2sexp.c:1.2
Rev: src/nettle/rsa_md5.c:1.5
Rev: src/nettle/rsa_sha1.c:1.5
Rev: src/nettle/sexp2rsa.c:1.3
Rev: src/nettle/testsuite/rsa-keygen-test.c:1.4
Rev: src/nettle/testsuite/rsa-test.c:1.5
Rev: src/nettle/testsuite/rsa2sexp-test.c:1.2
Rev: src/nettle/testsuite/sexp2rsa-test.c:1.2
Rev: src/nettle/testsuite/testutils.c:1.13
Rev: src/nettle/testsuite/testutils.h:1.11
parent 5aa8abd0
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
#include "config.h" #include "config.h"
#endif #endif
#if HAVE_LIBGMP #if WITH_PUBLIC_KEY
#include "rsa.h" #include "rsa.h"
#include "bignum.h" #include "bignum.h"
...@@ -350,4 +350,4 @@ rsa_generate_keypair(struct rsa_public_key *pub, ...@@ -350,4 +350,4 @@ rsa_generate_keypair(struct rsa_public_key *pub,
return 1; return 1;
} }
#endif /* HAVE_LIBGMP */ #endif /* WITH_PUBLIC_KEY */
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
#include "config.h" #include "config.h"
#endif #endif
#if HAVE_LIBGMP #if WITH_PUBLIC_KEY
#include "rsa.h" #include "rsa.h"
...@@ -190,4 +190,4 @@ rsa_compute_root(struct rsa_private_key *key, mpz_t x, const mpz_t m) ...@@ -190,4 +190,4 @@ rsa_compute_root(struct rsa_private_key *key, mpz_t x, const mpz_t m)
mpz_clear(xp); mpz_clear(xq); mpz_clear(xp); mpz_clear(xq);
} }
#endif /* HAVE_LIBGMP */ #endif /* WITH_PUBLIC_KEY */
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#include "config.h" #include "config.h"
#endif #endif
#if HAVE_LIBGMP #if WITH_PUBLIC_KEY
#include "rsa.h" #include "rsa.h"
...@@ -49,4 +49,4 @@ rsa_keypair_to_sexp(struct nettle_buffer *buffer, ...@@ -49,4 +49,4 @@ rsa_keypair_to_sexp(struct nettle_buffer *buffer,
"public-key", "rsa", "n", pub->n, "e", pub->e); "public-key", "rsa", "n", pub->n, "e", pub->e);
} }
#endif /* HAVE_LIBGMP */ #endif /* WITH_PUBLIC_KEY */
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
#include "config.h" #include "config.h"
#endif #endif
#if HAVE_LIBGMP #if WITH_PUBLIC_KEY
#include "rsa.h" #include "rsa.h"
...@@ -131,4 +131,4 @@ pkcs1_encode_md5(mpz_t m, unsigned length, struct md5_ctx *hash) ...@@ -131,4 +131,4 @@ pkcs1_encode_md5(mpz_t m, unsigned length, struct md5_ctx *hash)
nettle_mpz_set_str_256(m, length, em); nettle_mpz_set_str_256(m, length, em);
} }
#endif /* HAVE_LIBGMP */ #endif /* WITH_PUBLIC_KEY */
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
#include "config.h" #include "config.h"
#endif #endif
#if HAVE_LIBGMP #if WITH_PUBLIC_KEY
#include "rsa.h" #include "rsa.h"
...@@ -131,4 +131,4 @@ pkcs1_encode_sha1(mpz_t m, unsigned length, struct sha1_ctx *hash) ...@@ -131,4 +131,4 @@ pkcs1_encode_sha1(mpz_t m, unsigned length, struct sha1_ctx *hash)
nettle_mpz_set_str_256(m, length, em); nettle_mpz_set_str_256(m, length, em);
} }
#endif /* HAVE_LIBGMP */ #endif /* WITH_PUBLIC_KEY */
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#include "config.h" #include "config.h"
#endif #endif
#if HAVE_LIBGMP #if WITH_PUBLIC_KEY
#include "rsa.h" #include "rsa.h"
...@@ -119,4 +119,4 @@ rsa_keypair_from_sexp(struct rsa_public_key *pub, ...@@ -119,4 +119,4 @@ rsa_keypair_from_sexp(struct rsa_public_key *pub,
return 1; return 1;
} }
#endif /* HAVE_LIBGMP */ #endif /* WITH_PUBLIC_KEY */
...@@ -17,7 +17,7 @@ progress(void *ctx UNUSED, int c) ...@@ -17,7 +17,7 @@ progress(void *ctx UNUSED, int c)
int int
test_main(void) test_main(void)
{ {
#if HAVE_LIBGMP #if WITH_PUBLIC_KEY
struct rsa_public_key pub; struct rsa_public_key pub;
struct rsa_private_key key; struct rsa_private_key key;
...@@ -85,7 +85,7 @@ test_main(void) ...@@ -85,7 +85,7 @@ test_main(void)
SUCCESS(); SUCCESS();
#else /* !HAVE_LIBGMP */ #else /* !WITH_PUBLIC_KEY */
SKIP(); SKIP();
#endif /* !HAVE_LIBGMP */ #endif /* !WITH_PUBLIC_KEY */
} }
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
int int
test_main(void) test_main(void)
{ {
#if HAVE_LIBGMP #if WITH_PUBLIC_KEY
struct rsa_public_key pub; struct rsa_public_key pub;
struct rsa_private_key key; struct rsa_private_key key;
...@@ -240,7 +240,7 @@ test_main(void) ...@@ -240,7 +240,7 @@ test_main(void)
SUCCESS(); SUCCESS();
#else /* !HAVE_LIBGMP */ #else /* !WITH_PUBLIC_KEY */
SKIP(); SKIP();
#endif /* !HAVE_LIBGMP */ #endif /* !WITH_PUBLIC_KEY */
} }
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
int int
test_main(void) test_main(void)
{ {
#if HAVE_LIBGMP #if WITH_PUBLIC_KEY
struct rsa_public_key pub; struct rsa_public_key pub;
struct rsa_private_key priv; struct rsa_private_key priv;
...@@ -87,7 +87,7 @@ test_main(void) ...@@ -87,7 +87,7 @@ test_main(void)
SUCCESS(); SUCCESS();
#else /* !HAVE_LIBGMP */ #else /* !WITH_PUBLIC_KEY */
SKIP(); SKIP();
#endif /* !HAVE_LIBGMP */ #endif /* !WITH_PUBLIC_KEY */
} }
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
int int
test_main(void) test_main(void)
{ {
#if HAVE_LIBGMP #if WITH_PUBLIC_KEY
struct rsa_public_key pub; struct rsa_public_key pub;
struct rsa_private_key priv; struct rsa_private_key priv;
...@@ -43,8 +43,8 @@ test_main(void) ...@@ -43,8 +43,8 @@ test_main(void)
SUCCESS(); SUCCESS();
#else /* !HAVE_LIBGMP */ #else /* !WITH_PUBLIC_KEY */
SKIP(); SKIP();
#endif /* !HAVE_LIBGMP */ #endif /* !WITH_PUBLIC_KEY */
} }
/* testutils.c */ /* testutils.c */
#include "testutils.h" #include "testutils.h"
#include "cbc.h" #include "cbc.h"
...@@ -269,17 +268,6 @@ test_armor(const struct nettle_armor *armor, ...@@ -269,17 +268,6 @@ test_armor(const struct nettle_armor *armor,
} }
#if HAVE_LIBGMP #if HAVE_LIBGMP
#define SIGN(key, hash, msg, signature) do { \
hash##_update(&hash, LDATA(msg)); \
rsa_##hash##_sign(key, &hash, signature); \
} while(0)
#define VERIFY(key, hash, msg, signature) ( \
hash##_update(&hash, LDATA(msg)), \
rsa_##hash##_verify(key, &hash, signature) \
)
/* Missing in current gmp */ /* Missing in current gmp */
static void static void
mpz_togglebit (mpz_t x, unsigned long int bit) mpz_togglebit (mpz_t x, unsigned long int bit)
...@@ -289,6 +277,18 @@ mpz_togglebit (mpz_t x, unsigned long int bit) ...@@ -289,6 +277,18 @@ mpz_togglebit (mpz_t x, unsigned long int bit)
else else
mpz_setbit(x, bit); mpz_setbit(x, bit);
} }
#endif /* HAVE_LIBGMP */
#if WITH_PUBLIC_KEY
#define SIGN(key, hash, msg, signature) do { \
hash##_update(&hash, LDATA(msg)); \
rsa_##hash##_sign(key, &hash, signature); \
} while(0)
#define VERIFY(key, hash, msg, signature) ( \
hash##_update(&hash, LDATA(msg)), \
rsa_##hash##_verify(key, &hash, signature) \
)
void void
test_rsa_md5(struct rsa_public_key *pub, test_rsa_md5(struct rsa_public_key *pub,
...@@ -376,7 +376,6 @@ test_rsa_sha1(struct rsa_public_key *pub, ...@@ -376,7 +376,6 @@ test_rsa_sha1(struct rsa_public_key *pub,
mpz_clear(signature); mpz_clear(signature);
} }
#if HAVE_LIBGMP
void void
test_rsa_key(struct rsa_public_key *pub, test_rsa_key(struct rsa_public_key *pub,
struct rsa_private_key *key) struct rsa_private_key *key)
...@@ -447,6 +446,5 @@ test_rsa_key(struct rsa_public_key *pub, ...@@ -447,6 +446,5 @@ test_rsa_key(struct rsa_public_key *pub,
mpz_clear(tmp); mpz_clear(phi); mpz_clear(tmp); mpz_clear(phi);
} }
#endif /* HAVE_LIBGMP */ #endif /* WITH_PUBLIC_KEY */
#endif /* HAVE_LIBGMP */
...@@ -12,6 +12,10 @@ ...@@ -12,6 +12,10 @@
#include <stdio.h> #include <stdio.h>
#if HAVE_LIBGMP #if HAVE_LIBGMP
# include "bignum.h"
#endif
#if WITH_PUBLIC_KEY
# include "rsa.h" # include "rsa.h"
#endif #endif
...@@ -67,7 +71,7 @@ test_armor(const struct nettle_armor *armor, ...@@ -67,7 +71,7 @@ test_armor(const struct nettle_armor *armor,
const uint8_t *data, const uint8_t *data,
const uint8_t *ascii); const uint8_t *ascii);
#if HAVE_LIBGMP #if WITH_PUBLIC_KEY
void void
test_rsa_md5(struct rsa_public_key *pub, test_rsa_md5(struct rsa_public_key *pub,
struct rsa_private_key *key, struct rsa_private_key *key,
...@@ -82,7 +86,7 @@ void ...@@ -82,7 +86,7 @@ void
test_rsa_key(struct rsa_public_key *pub, test_rsa_key(struct rsa_public_key *pub,
struct rsa_private_key *key); struct rsa_private_key *key);
#endif /* HAVE_LIBGMP */ #endif /* WITH_PUBLIC_KEY */
#define H2(d, s) decode_hex((d), (s)) #define H2(d, s) decode_hex((d), (s))
#define H(x) decode_hex_dup(x) #define H(x) decode_hex_dup(x)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment