From e309c92e9bda1f1a525ac4bbcf03a22490737ce0 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Sat, 28 Jun 2014 19:15:25 -0700 Subject: [PATCH] poly1305_finish(): zero the whole state using sodium_memzero() --- .../poly1305/donna/poly1305_donna32.h | 15 +-------------- .../poly1305/donna/poly1305_donna64.h | 9 +-------- 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna32.h b/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna32.h index 0aceb826..a4696632 100644 --- a/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna32.h +++ b/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna32.h @@ -203,19 +203,6 @@ poly1305_finish(poly1305_context *ctx, unsigned char mac[16]) { U32TO8(mac + 12, h3); /* zero out the state */ - st->h[0] = 0; - st->h[1] = 0; - st->h[2] = 0; - st->h[3] = 0; - st->h[4] = 0; - st->r[0] = 0; - st->r[1] = 0; - st->r[2] = 0; - st->r[3] = 0; - st->r[4] = 0; - st->pad[0] = 0; - st->pad[1] = 0; - st->pad[2] = 0; - st->pad[3] = 0; + sodium_memzero((void *)st, sizeof *st); } diff --git a/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna64.h b/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna64.h index d92c3ee5..8b5c764b 100644 --- a/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna64.h +++ b/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna64.h @@ -197,13 +197,6 @@ poly1305_finish(poly1305_context *ctx, unsigned char mac[16]) { U64TO8(&mac[8], h1); /* zero out the state */ - st->h[0] = 0; - st->h[1] = 0; - st->h[2] = 0; - st->r[0] = 0; - st->r[1] = 0; - st->r[2] = 0; - st->pad[0] = 0; - st->pad[1] = 0; + sodium_memzero((void *)st, sizeof *st); }