summaryrefslogtreecommitdiff
path: root/schnorr.c
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2013-09-14 15:43:03 +0100
committerColin Watson <cjwatson@debian.org>2013-09-14 15:43:03 +0100
commit8faf8c84430cf3c19705b1d9f8889d256e7fd1fd (patch)
treee6cb74192adb00fda5e4d1457547851d7e0d86af /schnorr.c
parent328b60656f29db6306994d7498dede386ec2d1c3 (diff)
parentc41345ad7ee5a22689e2c009595e85fa27b4b39a (diff)
merge 6.3p1
Diffstat (limited to 'schnorr.c')
-rw-r--r--schnorr.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/schnorr.c b/schnorr.c
index 4d54d6881..9549dcf0e 100644
--- a/schnorr.c
+++ b/schnorr.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: schnorr.c,v 1.5 2010/12/03 23:49:26 djm Exp $ */ 1/* $OpenBSD: schnorr.c,v 1.7 2013/05/17 00:13:14 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2008 Damien Miller. All rights reserved. 3 * Copyright (c) 2008 Damien Miller. All rights reserved.
4 * 4 *
@@ -102,7 +102,7 @@ schnorr_hash(const BIGNUM *p, const BIGNUM *q, const BIGNUM *g,
102 out: 102 out:
103 buffer_free(&b); 103 buffer_free(&b);
104 bzero(digest, digest_len); 104 bzero(digest, digest_len);
105 xfree(digest); 105 free(digest);
106 digest_len = 0; 106 digest_len = 0;
107 if (success == 0) 107 if (success == 0)
108 return h; 108 return h;
@@ -488,12 +488,13 @@ debug3_bn(const BIGNUM *n, const char *fmt, ...)
488{ 488{
489 char *out, *h; 489 char *out, *h;
490 va_list args; 490 va_list args;
491 int ret;
491 492
492 out = NULL; 493 out = NULL;
493 va_start(args, fmt); 494 va_start(args, fmt);
494 vasprintf(&out, fmt, args); 495 ret = vasprintf(&out, fmt, args);
495 va_end(args); 496 va_end(args);
496 if (out == NULL) 497 if (ret == -1 || out == NULL)
497 fatal("%s: vasprintf failed", __func__); 498 fatal("%s: vasprintf failed", __func__);
498 499
499 if (n == NULL) 500 if (n == NULL)
@@ -513,12 +514,13 @@ debug3_buf(const u_char *buf, u_int len, const char *fmt, ...)
513 char *out, h[65]; 514 char *out, h[65];
514 u_int i, j; 515 u_int i, j;
515 va_list args; 516 va_list args;
517 int ret;
516 518
517 out = NULL; 519 out = NULL;
518 va_start(args, fmt); 520 va_start(args, fmt);
519 vasprintf(&out, fmt, args); 521 ret = vasprintf(&out, fmt, args);
520 va_end(args); 522 va_end(args);
521 if (out == NULL) 523 if (ret == -1 || out == NULL)
522 fatal("%s: vasprintf failed", __func__); 524 fatal("%s: vasprintf failed", __func__);
523 525
524 debug3("%s length %u%s", out, len, buf == NULL ? " (null)" : ""); 526 debug3("%s length %u%s", out, len, buf == NULL ? " (null)" : "");
@@ -571,7 +573,7 @@ modp_group_free(struct modp_group *grp)
571 if (grp->q != NULL) 573 if (grp->q != NULL)
572 BN_clear_free(grp->q); 574 BN_clear_free(grp->q);
573 bzero(grp, sizeof(*grp)); 575 bzero(grp, sizeof(*grp));
574 xfree(grp); 576 free(grp);
575} 577}
576 578
577/* main() function for self-test */ 579/* main() function for self-test */
@@ -606,7 +608,7 @@ schnorr_selftest_one(const BIGNUM *grp_p, const BIGNUM *grp_q,
606 if (schnorr_verify_buf(grp_p, grp_q, grp_g, g_x, "junk", 4, 608 if (schnorr_verify_buf(grp_p, grp_q, grp_g, g_x, "junk", 4,
607 sig, siglen) != 0) 609 sig, siglen) != 0)
608 fatal("%s: verify should have failed (bit error)", __func__); 610 fatal("%s: verify should have failed (bit error)", __func__);
609 xfree(sig); 611 free(sig);
610 BN_free(g_x); 612 BN_free(g_x);
611 BN_CTX_free(bn_ctx); 613 BN_CTX_free(bn_ctx);
612} 614}