aboutsummaryrefslogtreecommitdiffstats
path: root/src/mac
diff options
context:
space:
mode:
Diffstat (limited to 'src/mac')
-rw-r--r--src/mac/mac.cpp10
-rw-r--r--src/mac/mac.h2
2 files changed, 6 insertions, 6 deletions
diff --git a/src/mac/mac.cpp b/src/mac/mac.cpp
index cb89e872a..2ef4ab64c 100644
--- a/src/mac/mac.cpp
+++ b/src/mac/mac.cpp
@@ -6,21 +6,21 @@
*/
#include <botan/mac.h>
+#include <botan/mem_ops.h>
namespace Botan {
/*
* Default (deterministic) MAC verification operation
*/
-bool MessageAuthenticationCode::verify_mac(const byte mac[], u32bit length)
+bool MessageAuthenticationCode::verify_mac(const byte mac[], size_t length)
{
SecureVector<byte> our_mac = final();
+
if(our_mac.size() != length)
return false;
- for(u32bit j = 0; j != length; ++j)
- if(mac[j] != our_mac[j])
- return false;
- return true;
+
+ return same_mem(&our_mac[0], &mac[0], length);
}
}
diff --git a/src/mac/mac.h b/src/mac/mac.h
index 4518d91ad..1350c7d7a 100644
--- a/src/mac/mac.h
+++ b/src/mac/mac.h
@@ -27,7 +27,7 @@ class BOTAN_DLL MessageAuthenticationCode : public BufferedComputation,
* @param length the length of param in
* @return true if the MAC is valid, false otherwise
*/
- virtual bool verify_mac(const byte in[], u32bit length);
+ virtual bool verify_mac(const byte in[], size_t length);
/**
* Get a new object representing the same algorithm as *this