1 /* $NetBSD: safe.h,v 1.8 2025/01/26 16:25:42 christos Exp $ */ 2 3 /* 4 * Copyright (C) Internet Systems Consortium, Inc. ("ISC") 5 * 6 * SPDX-License-Identifier: MPL-2.0 7 * 8 * This Source Code Form is subject to the terms of the Mozilla Public 9 * License, v. 2.0. If a copy of the MPL was not distributed with this 10 * file, you can obtain one at https://mozilla.org/MPL/2.0/. 11 * 12 * See the COPYRIGHT file distributed with this work for additional 13 * information regarding copyright ownership. 14 */ 15 16 #pragma once 17 18 /*! \file isc/safe.h */ 19 20 #include <isc/lang.h> 21 22 ISC_LANG_BEGINDECLS 23 24 int 25 isc_safe_memequal(const void *, const void *, size_t); 26 27 /*%< 28 * Returns true iff. two blocks of memory are equal, otherwise 29 * false. 30 * 31 */ 32 33 void 34 isc_safe_memwipe(void *, size_t); 35 36 /*%< 37 * Clear the memory of length `len` pointed to by `ptr`. 38 * 39 * Some crypto code calls memset() on stack allocated buffers just 40 * before return so that they are wiped. Such memset() calls can be 41 * optimized away by the compiler. We provide this external non-inline C 42 * function to perform the memset operation so that the compiler cannot 43 * infer about what the function does and optimize the call away. 44 */ 45 46 ISC_LANG_ENDDECLS 47