Replace isc_safe routines with their OpenSSL counter parts

This commit is contained in:
Ondřej Surý
2018-04-25 14:04:31 +02:00
parent 8b9b270c7d
commit 66ba2fdad5
6 changed files with 9 additions and 102 deletions

View File

@@ -15,27 +15,26 @@
/*! \file isc/safe.h */
#include <isc/types.h>
#include <stdlib.h>
#include <isc/boolean.h>
#include <isc/lang.h>
#include <openssl/crypto.h>
ISC_LANG_BEGINDECLS
isc_boolean_t
isc_safe_memequal(const void *s1, const void *s2, size_t n);
#define isc_safe_memequal(s1, s2, n) ISC_TF(!CRYPTO_memcmp(s1, s2, n))
/*%<
* Returns ISC_TRUE iff. two blocks of memory are equal, otherwise
* ISC_FALSE.
*
*/
int
isc_safe_memcompare(const void *b1, const void *b2, size_t len);
#define isc_safe_memcompare(b1, b2, n) CRYPTO_memcmp(b1, b2, n)
/*%<
* Clone of libc memcmp() which is safe to differential timing attacks.
*/
void
isc_safe_memwipe(void *ptr, size_t len);
#define isc_safe_memwipe(ptr, len) OPENSSL_cleanse(ptr, len)
/*%<
* Clear the memory of length `len` pointed to by `ptr`.
*