Roll src/third_party/WebKit e0eac24:489c548 (svn 193311:193320)
[chromium-blink-merge.git] / crypto / secure_util.cc
blob3fe8aa961a027e6c0c387585af0b25fd2e722ee1
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "crypto/secure_util.h"
7 namespace crypto {
9 bool SecureMemEqual(const void* s1, const void* s2, size_t n) {
10 const unsigned char* s1_ptr = reinterpret_cast<const unsigned char*>(s1);
11 const unsigned char* s2_ptr = reinterpret_cast<const unsigned char*>(s2);
12 unsigned char tmp = 0;
13 for (size_t i = 0; i < n; ++i, ++s1_ptr, ++s2_ptr)
14 tmp |= *s1_ptr ^ *s2_ptr;
15 return (tmp == 0);
18 } // namespace crypto