
The methodology used to generate this CL is documented in https://crbug.com/1098010#c34. No-Try: true Bug: 1098010 Change-Id: Ic0854e73c1dfbe8b9810db1599201b656c4774af Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3891041 Auto-Submit: Avi Drissman <avi@chromium.org> Owners-Override: Avi Drissman <avi@chromium.org> Commit-Queue: Mark Mentovai <mark@chromium.org> Reviewed-by: Mark Mentovai <mark@chromium.org> Cr-Commit-Position: refs/heads/main@{#1046511}
30 lines
1010 B
C++
30 lines
1010 B
C++
// Copyright 2012 The Chromium Authors
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#ifndef CRYPTO_SECURE_UTIL_H_
|
|
#define CRYPTO_SECURE_UTIL_H_
|
|
|
|
#include <stddef.h>
|
|
|
|
#include "crypto/crypto_export.h"
|
|
|
|
namespace crypto {
|
|
|
|
// Performs a constant-time comparison of two strings, returning true if the
|
|
// strings are equal.
|
|
//
|
|
// For cryptographic operations, comparison functions such as memcmp() may
|
|
// expose side-channel information about input, allowing an attacker to
|
|
// perform timing analysis to determine what the expected bits should be. In
|
|
// order to avoid such attacks, the comparison must execute in constant time,
|
|
// so as to not to reveal to the attacker where the difference(s) are.
|
|
// For an example attack, see
|
|
// http://groups.google.com/group/keyczar-discuss/browse_thread/thread/5571eca0948b2a13
|
|
CRYPTO_EXPORT bool SecureMemEqual(const void* s1, const void* s2, size_t n);
|
|
|
|
} // namespace crypto
|
|
|
|
#endif // CRYPTO_SECURE_UTIL_H_
|
|
|