diff options
author | Martin Willi <martin@revosec.ch> | 2015-04-11 16:44:18 +0200 |
---|---|---|
committer | Martin Willi <martin@revosec.ch> | 2015-04-14 11:51:54 +0200 |
commit | b833963270fbffe3186f5c71c7584c2347a44038 (patch) | |
tree | 75e2d440ec3f27ca6f25b899c592e51258e21c26 /src/libstrongswan/utils/utils.h | |
parent | 39e1ddec2ed3480e0edc07bbabfacbf907dc4e3f (diff) | |
download | strongswan-b833963270fbffe3186f5c71c7584c2347a44038.tar.bz2 strongswan-b833963270fbffe3186f5c71c7584c2347a44038.tar.xz |
utils: Add a constant time memeq() variant for cryptographic purposes
Diffstat (limited to 'src/libstrongswan/utils/utils.h')
-rw-r--r-- | src/libstrongswan/utils/utils.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/libstrongswan/utils/utils.h b/src/libstrongswan/utils/utils.h index 7c48d949f..2675acae8 100644 --- a/src/libstrongswan/utils/utils.h +++ b/src/libstrongswan/utils/utils.h @@ -185,6 +185,11 @@ static inline bool memeq(const void *x, const void *y, size_t len) } /** + * Same as memeq(), but with a constant runtime, safe for cryptographic use. + */ +bool memeq_const(const void *x, const void *y, size_t len); + +/** * Calling memcpy() with NULL pointers, even with n == 0, results in undefined * behavior according to the C standard. This version is guaranteed to not * access the pointers if n is 0. |