From 0fef202b37aea232d2600e05f98c3bad968b2074 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Tue, 13 Jan 2015 19:18:50 +0100 Subject: [PATCH] Wipe the last salsa20 block in the reduced rounds versions --- src/libsodium/crypto_stream/salsa2012/ref/stream_salsa2012.c | 3 +++ src/libsodium/crypto_stream/salsa2012/ref/xor_salsa2012.c | 3 +++ src/libsodium/crypto_stream/salsa208/ref/stream_salsa208.c | 3 +++ src/libsodium/crypto_stream/salsa208/ref/xor_salsa208.c | 3 +++ 4 files changed, 12 insertions(+) diff --git a/src/libsodium/crypto_stream/salsa2012/ref/stream_salsa2012.c b/src/libsodium/crypto_stream/salsa2012/ref/stream_salsa2012.c index 793adaa5..286d397b 100644 --- a/src/libsodium/crypto_stream/salsa2012/ref/stream_salsa2012.c +++ b/src/libsodium/crypto_stream/salsa2012/ref/stream_salsa2012.c @@ -6,6 +6,7 @@ Public domain. #include "api.h" #include "crypto_core_salsa2012.h" +#include "utils.h" typedef unsigned int uint32; @@ -47,5 +48,7 @@ int crypto_stream( crypto_core_salsa2012(block,in,k,sigma); for (i = 0;i < clen;++i) c[i] = block[i]; } + sodium_memzero(block, sizeof block); + return 0; } diff --git a/src/libsodium/crypto_stream/salsa2012/ref/xor_salsa2012.c b/src/libsodium/crypto_stream/salsa2012/ref/xor_salsa2012.c index 5970ca46..6a506f1c 100644 --- a/src/libsodium/crypto_stream/salsa2012/ref/xor_salsa2012.c +++ b/src/libsodium/crypto_stream/salsa2012/ref/xor_salsa2012.c @@ -6,6 +6,7 @@ Public domain. #include "api.h" #include "crypto_core_salsa2012.h" +#include "utils.h" typedef unsigned int uint32; @@ -50,5 +51,7 @@ int crypto_stream_xor( crypto_core_salsa2012(block,in,k,sigma); for (i = 0;i < mlen;++i) c[i] = m[i] ^ block[i]; } + sodium_memzero(block, sizeof block); + return 0; } diff --git a/src/libsodium/crypto_stream/salsa208/ref/stream_salsa208.c b/src/libsodium/crypto_stream/salsa208/ref/stream_salsa208.c index 08890021..b7b86ec2 100644 --- a/src/libsodium/crypto_stream/salsa208/ref/stream_salsa208.c +++ b/src/libsodium/crypto_stream/salsa208/ref/stream_salsa208.c @@ -6,6 +6,7 @@ Public domain. #include "api.h" #include "crypto_core_salsa208.h" +#include "utils.h" typedef unsigned int uint32; @@ -47,5 +48,7 @@ int crypto_stream( crypto_core_salsa208(block,in,k,sigma); for (i = 0;i < clen;++i) c[i] = block[i]; } + sodium_memzero(block, sizeof block); + return 0; } diff --git a/src/libsodium/crypto_stream/salsa208/ref/xor_salsa208.c b/src/libsodium/crypto_stream/salsa208/ref/xor_salsa208.c index 9f6dac55..cfe47ebe 100644 --- a/src/libsodium/crypto_stream/salsa208/ref/xor_salsa208.c +++ b/src/libsodium/crypto_stream/salsa208/ref/xor_salsa208.c @@ -6,6 +6,7 @@ Public domain. #include "api.h" #include "crypto_core_salsa208.h" +#include "utils.h" typedef unsigned int uint32; @@ -50,5 +51,7 @@ int crypto_stream_xor( crypto_core_salsa208(block,in,k,sigma); for (i = 0;i < mlen;++i) c[i] = m[i] ^ block[i]; } + sodium_memzero(block, sizeof block); + return 0; }