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

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 @@
#include "config.h"
#endif
#if HAVE_LIBGMP
#if WITH_PUBLIC_KEY
#include "rsa.h"
#include "bignum.h"
......@@ -350,4 +350,4 @@ rsa_generate_keypair(struct rsa_public_key *pub,
return 1;
}
#endif /* HAVE_LIBGMP */
#endif /* WITH_PUBLIC_KEY */
......@@ -27,7 +27,7 @@
#include "config.h"
#endif
#if HAVE_LIBGMP
#if WITH_PUBLIC_KEY
#include "rsa.h"
......@@ -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);
}
#endif /* HAVE_LIBGMP */
#endif /* WITH_PUBLIC_KEY */
......@@ -26,7 +26,7 @@
#include "config.h"
#endif
#if HAVE_LIBGMP
#if WITH_PUBLIC_KEY
#include "rsa.h"
......@@ -49,4 +49,4 @@ rsa_keypair_to_sexp(struct nettle_buffer *buffer,
"public-key", "rsa", "n", pub->n, "e", pub->e);
}
#endif /* HAVE_LIBGMP */
#endif /* WITH_PUBLIC_KEY */
......@@ -27,7 +27,7 @@
#include "config.h"
#endif
#if HAVE_LIBGMP
#if WITH_PUBLIC_KEY
#include "rsa.h"
......@@ -131,4 +131,4 @@ pkcs1_encode_md5(mpz_t m, unsigned length, struct md5_ctx *hash)
nettle_mpz_set_str_256(m, length, em);
}
#endif /* HAVE_LIBGMP */
#endif /* WITH_PUBLIC_KEY */
......@@ -27,7 +27,7 @@
#include "config.h"
#endif
#if HAVE_LIBGMP
#if WITH_PUBLIC_KEY
#include "rsa.h"
......@@ -131,4 +131,4 @@ pkcs1_encode_sha1(mpz_t m, unsigned length, struct sha1_ctx *hash)
nettle_mpz_set_str_256(m, length, em);
}
#endif /* HAVE_LIBGMP */
#endif /* WITH_PUBLIC_KEY */
......@@ -26,7 +26,7 @@
#include "config.h"
#endif
#if HAVE_LIBGMP
#if WITH_PUBLIC_KEY
#include "rsa.h"
......@@ -119,4 +119,4 @@ rsa_keypair_from_sexp(struct rsa_public_key *pub,
return 1;
}
#endif /* HAVE_LIBGMP */
#endif /* WITH_PUBLIC_KEY */
......@@ -17,7 +17,7 @@ progress(void *ctx UNUSED, int c)
int
test_main(void)
{
#if HAVE_LIBGMP
#if WITH_PUBLIC_KEY
struct rsa_public_key pub;
struct rsa_private_key key;
......@@ -85,7 +85,7 @@ test_main(void)
SUCCESS();
#else /* !HAVE_LIBGMP */
#else /* !WITH_PUBLIC_KEY */
SKIP();
#endif /* !HAVE_LIBGMP */
#endif /* !WITH_PUBLIC_KEY */
}
......@@ -3,7 +3,7 @@
int
test_main(void)
{
#if HAVE_LIBGMP
#if WITH_PUBLIC_KEY
struct rsa_public_key pub;
struct rsa_private_key key;
......@@ -240,7 +240,7 @@ test_main(void)
SUCCESS();
#else /* !HAVE_LIBGMP */
#else /* !WITH_PUBLIC_KEY */
SKIP();
#endif /* !HAVE_LIBGMP */
#endif /* !WITH_PUBLIC_KEY */
}
......@@ -6,7 +6,7 @@
int
test_main(void)
{
#if HAVE_LIBGMP
#if WITH_PUBLIC_KEY
struct rsa_public_key pub;
struct rsa_private_key priv;
......@@ -87,7 +87,7 @@ test_main(void)
SUCCESS();
#else /* !HAVE_LIBGMP */
#else /* !WITH_PUBLIC_KEY */
SKIP();
#endif /* !HAVE_LIBGMP */
#endif /* !WITH_PUBLIC_KEY */
}
......@@ -5,7 +5,7 @@
int
test_main(void)
{
#if HAVE_LIBGMP
#if WITH_PUBLIC_KEY
struct rsa_public_key pub;
struct rsa_private_key priv;
......@@ -43,8 +43,8 @@ test_main(void)
SUCCESS();
#else /* !HAVE_LIBGMP */
#else /* !WITH_PUBLIC_KEY */
SKIP();
#endif /* !HAVE_LIBGMP */
#endif /* !WITH_PUBLIC_KEY */
}
/* testutils.c */
#include "testutils.h"
#include "cbc.h"
......@@ -269,17 +268,6 @@ test_armor(const struct nettle_armor *armor,
}
#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 */
static void
mpz_togglebit (mpz_t x, unsigned long int bit)
......@@ -289,6 +277,18 @@ mpz_togglebit (mpz_t x, unsigned long int bit)
else
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
test_rsa_md5(struct rsa_public_key *pub,
......@@ -376,7 +376,6 @@ test_rsa_sha1(struct rsa_public_key *pub,
mpz_clear(signature);
}
#if HAVE_LIBGMP
void
test_rsa_key(struct rsa_public_key *pub,
struct rsa_private_key *key)
......@@ -447,6 +446,5 @@ test_rsa_key(struct rsa_public_key *pub,
mpz_clear(tmp); mpz_clear(phi);
}
#endif /* HAVE_LIBGMP */
#endif /* WITH_PUBLIC_KEY */
#endif /* HAVE_LIBGMP */
......@@ -12,6 +12,10 @@
#include <stdio.h>
#if HAVE_LIBGMP
# include "bignum.h"
#endif
#if WITH_PUBLIC_KEY
# include "rsa.h"
#endif
......@@ -67,7 +71,7 @@ test_armor(const struct nettle_armor *armor,
const uint8_t *data,
const uint8_t *ascii);
#if HAVE_LIBGMP
#if WITH_PUBLIC_KEY
void
test_rsa_md5(struct rsa_public_key *pub,
struct rsa_private_key *key,
......@@ -82,7 +86,7 @@ void
test_rsa_key(struct rsa_public_key *pub,
struct rsa_private_key *key);
#endif /* HAVE_LIBGMP */
#endif /* WITH_PUBLIC_KEY */
#define H2(d, s) decode_hex((d), (s))
#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