Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: crypto/secure_memcmp.cc

Issue 8124011: Add constant-time comparison operators for cryptographic uses. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « crypto/secure_memcmp.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 #include "secure_memcmp.h"
6
Ryan Sleevi 2011/10/04 00:38:28 missing namespace crypto {} here
Chris Palmer 2011/10/04 00:40:30 Done.
7 bool SecureMemcmp(const void* s1, const void* s2, size_t n) {
8 const unsigned char* s1_ptr = reinterpret_cast<const unsigned char*>(s1);
9 const unsigned char* s2_ptr = reinterpret_cast<const unsigned char*>(s2);
10 unsigned char tmp = 0;
11 for (size_t i = 0; i < n; ++i, ++s1_ptr, ++s2_ptr)
12 tmp |= *s1_ptr ^ *s2_ptr;
13 return (tmp == 0);
14 }
15
OLDNEW
« no previous file with comments | « crypto/secure_memcmp.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698