From c75c56fef73745975a8a82271d6f2e8bde526ca4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Mon, 2 Sep 2013 16:25:37 +0200 Subject: [PATCH] Fix off-by-one error in ecdsa_write_signature() Made some signature fail with 521-bit curve --- library/ecdsa.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/ecdsa.c b/library/ecdsa.c index bbdb5d57b..dc169cefc 100644 --- a/library/ecdsa.c +++ b/library/ecdsa.c @@ -220,8 +220,8 @@ int ecdsa_write_signature( ecdsa_context *ctx, void *p_rng ) { int ret; - unsigned char buf[MAX_SIG_LEN]; - unsigned char *p = buf + MAX_SIG_LEN - 1; + unsigned char buf[MAX_SIG_LEN + 3]; + unsigned char *p = buf + MAX_SIG_LEN; size_t len = 0; if( ( ret = ecdsa_sign( &ctx->grp, &ctx->r, &ctx->s, &ctx->d,