From 530fcd5aaf841210a9d2d189f551c309970916e9 Mon Sep 17 00:00:00 2001 From: Benedict Date: Mon, 19 Dec 2016 20:06:52 +0100 Subject: set6: challenge 46: completed --- lib/lib6.c | 18 +++++++++++++----- lib/lib6.h | 1 + 2 files changed, 14 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/lib6.c b/lib/lib6.c index 432c959..5999e91 100644 --- a/lib/lib6.c +++ b/lib/lib6.c @@ -228,12 +228,20 @@ void dsa_recover_k_from_repeated_nonce(BIGNUM *mess1_hash, BIGNUM *mess2_hash, void dsa_generate_magic_signature(struct dsa_public_params *pub, struct dsa_per_user_param *priv, BIGNUM *mess_hash) { - BIGNUM *tmp = BN_new(); + BIGNUM *tmp = BN_new(); - BN_mod_exp(tmp, priv->public, mess_hash, pub->p, ctx); - BN_mod(priv->r, tmp, pub->q, ctx); + BN_mod_exp(tmp, priv->public, mess_hash, pub->p, ctx); + BN_mod(priv->r, tmp, pub->q, ctx); - BN_mod_inverse(tmp, mess_hash, pub->q, ctx); - BN_mod_mul(priv->s, priv->r, tmp, pub->q, ctx); + BN_mod_inverse(tmp, mess_hash, pub->q, ctx); + BN_mod_mul(priv->s, priv->r, tmp, pub->q, ctx); + +} +int rsa_parity_orcale(BIGNUM *message, struct rsa_key_bignum *private) +{ + BIGNUM *decrypted = BN_new(); + // decrypt and check last bit + rsa_decrypt_bignum(message, decrypted, private); + return BN_is_odd(decrypted); } diff --git a/lib/lib6.h b/lib/lib6.h index d4578df..a1cfa15 100644 --- a/lib/lib6.h +++ b/lib/lib6.h @@ -42,4 +42,5 @@ void dsa_recover_k_from_repeated_nonce(BIGNUM *mess1_hash, BIGNUM *mess2_hash, struct dsa_per_user_param *priv, BIGNUM *k); void dsa_generate_magic_signature(struct dsa_public_params *pub, struct dsa_per_user_param *priv, BIGNUM *mess_hash); +int rsa_parity_orcale(BIGNUM *message, struct rsa_key_bignum *private); #endif /* __LIB_6_H__ */ -- cgit v1.2.3-70-g09d2