Commit 9ae51bb5 authored by David Benjamin's avatar David Benjamin Committed by Commit Bot

Implement crypto::SecureMemEqual with BoringSSL.

It's the exact same code, but no sense in implementing it twice.

Bug: none
Change-Id: Ie3688b2d56c80b1d513fc5eab37b04aa365417ee
Reviewed-on: https://chromium-review.googlesource.com/1246271Reviewed-by: default avatarRyan Sleevi <rsleevi@chromium.org>
Commit-Queue: David Benjamin <davidben@chromium.org>
Cr-Commit-Position: refs/heads/master@{#594460}
parent 69db58ff
......@@ -2,19 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <stddef.h>
#include "crypto/secure_util.h"
#include "third_party/boringssl/src/include/openssl/mem.h"
namespace crypto {
bool SecureMemEqual(const void* s1, const void* s2, size_t n) {
const unsigned char* s1_ptr = reinterpret_cast<const unsigned char*>(s1);
const unsigned char* s2_ptr = reinterpret_cast<const unsigned char*>(s2);
unsigned char tmp = 0;
for (size_t i = 0; i < n; ++i, ++s1_ptr, ++s2_ptr)
tmp |= *s1_ptr ^ *s2_ptr;
return (tmp == 0);
return CRYPTO_memcmp(s1, s2, n) == 0;
}
} // namespace crypto
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment