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

Side by Side Diff: crypto/secure_memcmp.h

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
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 #ifndef CRYPTO_SECURE_MEMCMP_H_
6 #define CRYPTO_SECURE_MEMCMP_H_
7 #pragma once
8
9 #include "crypto/crypto_export.h"
10
11 namespace crypto {
12
13 // Performs a constant-time comparison of two strings, returning true if the
14 // strings are equal.
15 //
16 // For cryptographic operations, comparison functions such as memcmp() may
17 // expose side-channel information about input, allowing an attacker to
18 // perform timing analysis to determine what the expected bits should be. In
19 // order to avoid such attacks, the comparison must execute in constant time,
20 // so as to not to reveal to the attacker where the difference(s) are.
21 // For an example attack, see
22 // http://groups.google.com/group/keyczar-discuss/browse_thread/thread/5571eca09 48b2a13
23 CRYPTO_EXPORT bool SecureMemcmp(const void* s1, const void* s2, size_t n);
24
25 } // namespace crypto
26
27 #endif // CRYPTO_HMAC_H_
28
OLDNEW
« no previous file with comments | « crypto/hmac.cc ('k') | crypto/secure_memcmp.cc » ('j') | crypto/secure_memcmp.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698