summaryrefslogtreecommitdiff
path: root/rsa.c
diff options
context:
space:
mode:
authorNiels Möller <nisse@lysator.liu.se>2002-01-12 15:34:53 +0100
committerNiels Möller <nisse@lysator.liu.se>2002-01-12 15:34:53 +0100
commit0fb4bd32b45970d50e0b21b40a5c21fdb4639739 (patch)
treec93261419a576a7a832f390584ea4aadc6cb7bb3 /rsa.c
parent87e63ab1bcbfd380946172e1a3980cc13e02f7c2 (diff)
downloadnettle-0fb4bd32b45970d50e0b21b40a5c21fdb4639739.tar.gz
(rsa_init_public_key): New function.
(rsa_clear_public_key): Likewise. (rsa_init_private_key): Likewise. (rsa_clear_private_key): Likewise. Rev: src/nettle/rsa.c:1.3 Rev: src/nettle/rsa.h:1.4
Diffstat (limited to 'rsa.c')
-rw-r--r--rsa.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/rsa.c b/rsa.c
index 6c69eb02..87e81111 100644
--- a/rsa.c
+++ b/rsa.c
@@ -37,6 +37,24 @@
* one can link in the signature functions without also getting the
* verify functions. */
+void
+rsa_init_public_key(struct rsa_public_key *key)
+{
+ mpz_init(key->n);
+ mpz_init(key->e);
+
+ /* Not really necessary, but it seems cleaner to initialize all the
+ * storage. */
+ key->size = 0;
+}
+
+void
+rsa_clear_public_key(struct rsa_public_key *key)
+{
+ mpz_clear(key->n);
+ mpz_clear(key->e);
+}
+
int
rsa_prepare_public_key(struct rsa_public_key *key)
{
@@ -63,12 +81,39 @@ rsa_prepare_public_key(struct rsa_public_key *key)
}
}
+void
+rsa_init_private_key(struct rsa_private_key *key)
+{
+ rsa_init_public_key(&key->pub);
+
+ mpz_init(key->d);
+ mpz_init(key->p);
+ mpz_init(key->q);
+ mpz_init(key->a);
+ mpz_init(key->b);
+ mpz_init(key->c);
+}
+
+void
+rsa_clear_private_key(struct rsa_private_key *key)
+{
+ rsa_clear_public_key(&key->pub);
+
+ mpz_clear(key->d);
+ mpz_clear(key->p);
+ mpz_clear(key->q);
+ mpz_clear(key->a);
+ mpz_clear(key->b);
+ mpz_clear(key->c);
+}
+
int
rsa_prepare_private_key(struct rsa_private_key *key)
{
return rsa_prepare_public_key(&key->pub);
}
+
#ifndef RSA_CRT
#define RSA_CRT 1
#endif