From 931ce38f61ef912347489d8329a66c2971788ce1 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Thu, 10 Jul 2014 23:31:10 -0700 Subject: [PATCH] A double verification of 32 bytes is fast; so is comparing 2 pointers --- src/libsodium/crypto_sign/ed25519/ref10/open.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/libsodium/crypto_sign/ed25519/ref10/open.c b/src/libsodium/crypto_sign/ed25519/ref10/open.c index 220665d3..36eb0844 100644 --- a/src/libsodium/crypto_sign/ed25519/ref10/open.c +++ b/src/libsodium/crypto_sign/ed25519/ref10/open.c @@ -7,6 +7,7 @@ #include "crypto_verify_32.h" #include "ge.h" #include "sc.h" +#include "utils.h" int crypto_sign_verify_detached(const unsigned char *sig, const unsigned char *m, @@ -45,6 +46,12 @@ crypto_sign_verify_detached(const unsigned char *sig, const unsigned char *m, if (crypto_verify_32(rcheck, sig) != 0) { return -1; } + if (sig == rcheck) { + return -1; + } + if (sodium_memcmp(sig, rcheck, 32) != 0) { + return -1; + } return 0; }