Commit 1c59c3c9 authored by Niels Möller's avatar Niels Möller

* src/abstract_crypto.h, src/dsa.c, src/dsa.h, src/rsa.c: Cleanup.

Rev: src/abstract_crypto.h:1.33
Rev: src/dsa.c:1.24
Rev: src/dsa.h:1.4
Rev: src/rsa.c:1.11
parent 26151351
......@@ -124,26 +124,6 @@
#define MAKE_MAC(m, l, key) ((m)->make_mac((m), (l), (key)))
/* GABA:
(class
(name signer)
(vars
; Returns a non-spki signature
(sign method (string)
"int algorithm" "UINT32 length" "const UINT8 *data")
; Returns a <sig-val> sexp
(sign_spki method (object sexp)
;; "struct sexp *hash" "struct sexp *principal"
"UINT32 length" "const UINT8 *data")
(get_verifier method (object verifier))))
*/
#define SIGN(signer, algorithm, length, data) \
((signer)->sign((signer), (algorithm), (length), (data)))
#define SIGN_SPKI(signer, length, data) ((signer)->sign_spki((signer), (length), (data)))
#define SIGNER_GET_VERIFIER(signer) ((signer)->get_verifier((signer)))
/* GABA:
(class
(name verifier)
......@@ -174,6 +154,28 @@
#define PUBLIC_KEY(signer) ((signer)->public_key((signer)))
#define PUBLIC_SPKI_KEY(signer) ((signer)->public_spki_key((signer)))
/* GABA:
(class
(name signer)
(vars
; Returns a non-spki signature
(sign method (string)
"int algorithm" "UINT32 length" "const UINT8 *data")
; Returns a <sig-val> sexp
(sign_spki method (object sexp)
;; "struct sexp *hash" "struct sexp *principal"
"UINT32 length" "const UINT8 *data")
(get_verifier method (object verifier))))
*/
#define SIGN(signer, algorithm, length, data) \
((signer)->sign((signer), (algorithm), (length), (data)))
#define SIGN_SPKI(signer, length, data) ((signer)->sign_spki((signer), (length), (data)))
#define SIGNER_GET_VERIFIER(signer) ((signer)->get_verifier((signer)))
/* GABA:
(class
(name signature_algorithm)
......
This diff is collapsed.
......@@ -30,51 +30,6 @@
/* DSA signatures */
/* NOTE: These definitions should not really be public. But the
* structures are needed for both plain ssh-dss and spki-style dsa. */
/* DSA definitions */
/* ;; GABA:
(struct
(name dsa_public)
(vars
;; ; Original sexp or a hash thereof.
;; (principal object sexp)
(p bignum)
(q bignum)
(g bignum)
(y bignum)))
*/
/* ;; GABA:
(class
(name dsa_signer)
(super signer)
(vars
(random object randomness)
(public struct dsa_public)
(a bignum)))
*/
/* ;; GABA:
(class
(name dsa_verifier)
(super verifier)
(vars
(public struct dsa_public)))
*/
#if 0
void init_dsa_public(struct dsa_public *public);
/* parse an ssh keyblob */
int parse_dsa_public(struct simple_buffer *buffer,
struct dsa_public *public);
struct sexp *
make_dsa_public_key(struct dsa_public *dsa);
#endif
struct signature_algorithm *
make_dsa_algorithm(struct randomness *random);
......@@ -86,12 +41,6 @@ struct verifier *
make_ssh_dss_verifier(UINT32 public_length,
const UINT8 *public);
#if 0
struct lsh_string *
ssh_dss_public_key(struct signer *s);
#endif
void dsa_nist_gen(mpz_t p, mpz_t q, struct randomness *r, unsigned l);
void dsa_find_generator(mpz_t g, struct randomness *r, mpz_t p, mpz_t q);
......
......@@ -44,6 +44,46 @@
#define SA(x) sexp_a(ATOM_##x)
#define RSA_CRT 1
/* GABA:
(class
(name rsa_verifier)
(super verifier)
(vars
(params object rsa_algorithm)
(size . unsigned)
(n bignum)
(e bignum)))
*/
/* GABA:
(class
(name rsa_signer)
(super signer)
(vars
(verifier object rsa_verifier)
; Secret exponent
(d bignum)
; The two factors
(p bignum)
(q bignum)
; d % (p-1), i.e. a e = 1 (mod p)
(a bignum)
; d % (q-1), i.e. b e = 1 (mod q)
(b bignum)
; modular inverse of q , i.e. c q = 1 (mod p)
(c bignum)))
*/
/* Utility functions */
static void
pkcs1_encode(mpz_t m,
struct rsa_algorithm *params,
......@@ -80,26 +120,6 @@ pkcs1_encode(mpz_t m,
debug("pkcs1_encode: m = %xn\n", m);
}
/* ;; GABA:
(struct
(name rsa_public)
(vars
(params object rsa_algorithm)
(size . unsigned)
(n bignum)
(e bignum)))
*/
/* FIXME: The allocator could do this kind of initialization
* automatically. */
static void
init_rsa_verifier(struct rsa_verifier *public, struct rsa_algorithm *params)
{
public->params = params;
mpz_init(public->n);
mpz_init(public->e);
}
static int
rsa_check_size(struct rsa_verifier *key)
{
......@@ -135,16 +155,6 @@ spki_init_rsa_verifier(struct rsa_verifier *key,
&& rsa_check_size(key));
}
/* GABA:
(class
(name rsa_verifier)
(super verifier)
(vars
(params object rsa_algorithm)
(size . unsigned)
(n bignum)
(e bignum)))
*/
/* Signature verification */
static int
......@@ -274,6 +284,22 @@ do_rsa_public_spki_key(struct verifier *s)
-1);
}
static void
init_rsa_verifier(struct rsa_verifier *self, struct rsa_algorithm *params)
{
self->params = params;
/* FIXME: The allocator could do this kind of initialization
* automatically. */
mpz_init(self->n);
mpz_init(self->e);
self->super.verify = do_rsa_verify;
self->super.verify_spki = do_rsa_verify_spki;
self->super.public_key = do_rsa_public_key;
self->super.public_spki_key = do_rsa_public_spki_key;
}
static struct rsa_verifier *
make_rsa_verifier_internal(struct rsa_algorithm *params,
struct sexp_iterator *i)
......@@ -285,11 +311,6 @@ make_rsa_verifier_internal(struct rsa_algorithm *params,
if (spki_init_rsa_verifier(res, i))
{
res->super.verify = do_rsa_verify;
res->super.verify_spki = do_rsa_verify_spki;
res->super.public_key = do_rsa_public_key;
res->super.public_spki_key = do_rsa_public_spki_key;
return res;
}
else
......@@ -299,43 +320,8 @@ make_rsa_verifier_internal(struct rsa_algorithm *params,
}
}
static struct verifier *
make_rsa_verifier(struct signature_algorithm *s,
struct sexp_iterator *i)
{
CAST(rsa_algorithm, self, s);
return ( (SEXP_LEFT(i) == 2)
? &make_rsa_verifier_internal(self, i)->super
: NULL);
}
/* GABA:
(class
(name rsa_signer)
(super signer)
(vars
(verifier object rsa_verifier)
; Secret exponent
(d bignum)
; The two factors
(p bignum)
(q bignum)
; d % (p-1), i.e. a e = 1 (mod p)
(a bignum)
; d % (q-1), i.e. b e = 1 (mod q)
(b bignum)
; modular inverse of q , i.e. c q = 1 (mod p)
(c bignum)))
*/
#define RSA_CRT 1
/* Signature creation */
/* Compute x, the d:th root of m. Calling it with x == m is allowed. */
static void
......@@ -508,6 +494,18 @@ do_rsa_get_verifier(struct signer *s)
}
static struct verifier *
make_rsa_verifier(struct signature_algorithm *s,
struct sexp_iterator *i)
{
CAST(rsa_algorithm, self, s);
return ( (SEXP_LEFT(i) == 2)
? &make_rsa_verifier_internal(self, i)->super
: NULL);
}
static struct signer *
make_rsa_signer(struct signature_algorithm *s,
struct sexp_iterator *i)
......
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