From c1d9655f18e23bace3535b9cbbc0e5faa47eb6f4 Mon Sep 17 00:00:00 2001 From: miod <> Date: Sun, 9 Nov 2014 19:28:44 +0000 Subject: Remove DEBUG_SIGN code. Make sure gost_key_unwrap_crypto_pro() returns failure instead of a printf and a success return, when the operation fails. --- src/lib/libcrypto/gost/gost89_keywrap.c | 7 +++---- src/lib/libcrypto/gost/gostr341001_pmeth.c | 16 +--------------- src/lib/libssl/src/crypto/gost/gost89_keywrap.c | 7 +++---- src/lib/libssl/src/crypto/gost/gostr341001_pmeth.c | 16 +--------------- 4 files changed, 8 insertions(+), 38 deletions(-) (limited to 'src') diff --git a/src/lib/libcrypto/gost/gost89_keywrap.c b/src/lib/libcrypto/gost/gost89_keywrap.c index fa7698d3f7..a754c4d56e 100644 --- a/src/lib/libcrypto/gost/gost89_keywrap.c +++ b/src/lib/libcrypto/gost/gost89_keywrap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gost89_keywrap.c,v 1.2 2014/11/09 19:27:29 miod Exp $ */ +/* $OpenBSD: gost89_keywrap.c,v 1.3 2014/11/09 19:28:44 miod Exp $ */ /* * Copyright (c) 2014 Dmitry Eremin-Solenikov * Copyright (c) 2005-2006 Cryptocom LTD @@ -129,10 +129,9 @@ gost_key_unwrap_crypto_pro(int nid, const unsigned char *keyExchangeKey, Gost2814789_decrypt(wrappedKey + 8 + 24, sessionKey + 24, &ctx); GOST2814789IMIT(sessionKey, 32, cek_mac, nid, kek_ukm, wrappedKey); - if (memcmp(cek_mac, wrappedKey + 40, 4)) { - printf("IMIT Missmatch!\n"); + if (memcmp(cek_mac, wrappedKey + 40, 4)) return 0; - } + return 1; } diff --git a/src/lib/libcrypto/gost/gostr341001_pmeth.c b/src/lib/libcrypto/gost/gostr341001_pmeth.c index c7001fc1fa..77a84a3657 100644 --- a/src/lib/libcrypto/gost/gostr341001_pmeth.c +++ b/src/lib/libcrypto/gost/gostr341001_pmeth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gostr341001_pmeth.c,v 1.3 2014/11/09 19:27:29 miod Exp $ */ +/* $OpenBSD: gostr341001_pmeth.c,v 1.4 2014/11/09 19:28:44 miod Exp $ */ /* * Copyright (c) 2014 Dmitry Eremin-Solenikov * Copyright (c) 2005-2006 Cryptocom LTD @@ -235,13 +235,6 @@ static int pkey_gost01_sign(EVP_PKEY_CTX * ctx, unsigned char *sig, OPENSSL_assert(tbs_len == 32 || tbs_len == 64); md = GOST_le2bn(tbs, tbs_len, NULL); unpacked_sig = gost2001_do_sign(md, pkey->pkey.gost); -#ifdef DEBUG_SIGN - fprintf(stderr, "S.R="); - BN_print_fp(stderr, unpacked_sig->r); - fprintf(stderr, "\nS.S="); - BN_print_fp(stderr, unpacked_sig->s); - fprintf(stderr, "\n"); -#endif if (!unpacked_sig) { return 0; } @@ -281,13 +274,6 @@ static int pkey_gost01_verify(EVP_PKEY_CTX * ctx, const unsigned char *sig, md = GOST_le2bn(tbs, tbs_len, NULL); if (!md) goto err; -#ifdef DEBUG_SIGN - fprintf(stderr, "V.R="); - BN_print_fp(stderr, s->r); - fprintf(stderr, "\nV.S="); - BN_print_fp(stderr, s->s); - fprintf(stderr, "\n"); -#endif ok = gost2001_do_verify(md, s, pub_key->pkey.gost); err: diff --git a/src/lib/libssl/src/crypto/gost/gost89_keywrap.c b/src/lib/libssl/src/crypto/gost/gost89_keywrap.c index fa7698d3f7..a754c4d56e 100644 --- a/src/lib/libssl/src/crypto/gost/gost89_keywrap.c +++ b/src/lib/libssl/src/crypto/gost/gost89_keywrap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gost89_keywrap.c,v 1.2 2014/11/09 19:27:29 miod Exp $ */ +/* $OpenBSD: gost89_keywrap.c,v 1.3 2014/11/09 19:28:44 miod Exp $ */ /* * Copyright (c) 2014 Dmitry Eremin-Solenikov * Copyright (c) 2005-2006 Cryptocom LTD @@ -129,10 +129,9 @@ gost_key_unwrap_crypto_pro(int nid, const unsigned char *keyExchangeKey, Gost2814789_decrypt(wrappedKey + 8 + 24, sessionKey + 24, &ctx); GOST2814789IMIT(sessionKey, 32, cek_mac, nid, kek_ukm, wrappedKey); - if (memcmp(cek_mac, wrappedKey + 40, 4)) { - printf("IMIT Missmatch!\n"); + if (memcmp(cek_mac, wrappedKey + 40, 4)) return 0; - } + return 1; } diff --git a/src/lib/libssl/src/crypto/gost/gostr341001_pmeth.c b/src/lib/libssl/src/crypto/gost/gostr341001_pmeth.c index c7001fc1fa..77a84a3657 100644 --- a/src/lib/libssl/src/crypto/gost/gostr341001_pmeth.c +++ b/src/lib/libssl/src/crypto/gost/gostr341001_pmeth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gostr341001_pmeth.c,v 1.3 2014/11/09 19:27:29 miod Exp $ */ +/* $OpenBSD: gostr341001_pmeth.c,v 1.4 2014/11/09 19:28:44 miod Exp $ */ /* * Copyright (c) 2014 Dmitry Eremin-Solenikov * Copyright (c) 2005-2006 Cryptocom LTD @@ -235,13 +235,6 @@ static int pkey_gost01_sign(EVP_PKEY_CTX * ctx, unsigned char *sig, OPENSSL_assert(tbs_len == 32 || tbs_len == 64); md = GOST_le2bn(tbs, tbs_len, NULL); unpacked_sig = gost2001_do_sign(md, pkey->pkey.gost); -#ifdef DEBUG_SIGN - fprintf(stderr, "S.R="); - BN_print_fp(stderr, unpacked_sig->r); - fprintf(stderr, "\nS.S="); - BN_print_fp(stderr, unpacked_sig->s); - fprintf(stderr, "\n"); -#endif if (!unpacked_sig) { return 0; } @@ -281,13 +274,6 @@ static int pkey_gost01_verify(EVP_PKEY_CTX * ctx, const unsigned char *sig, md = GOST_le2bn(tbs, tbs_len, NULL); if (!md) goto err; -#ifdef DEBUG_SIGN - fprintf(stderr, "V.R="); - BN_print_fp(stderr, s->r); - fprintf(stderr, "\nV.S="); - BN_print_fp(stderr, s->s); - fprintf(stderr, "\n"); -#endif ok = gost2001_do_verify(md, s, pub_key->pkey.gost); err: -- cgit v1.2.3-55-g6feb