Index: crypto/secure_memcmp.cc |
=================================================================== |
--- crypto/secure_memcmp.cc (revision 0) |
+++ crypto/secure_memcmp.cc (revision 0) |
@@ -0,0 +1,15 @@ |
+// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "secure_memcmp.h" |
+ |
Ryan Sleevi
2011/10/04 00:38:28
missing namespace crypto {} here
Chris Palmer
2011/10/04 00:40:30
Done.
|
+bool SecureMemcmp(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); |
+} |
+ |