1*5f24b0e3Stb /* $OpenBSD: crypto_memory.c,v 1.3 2024/11/06 04:18:42 tb Exp $ */ 2bb523e98Stb /* 3bb523e98Stb * Copyright (c) 2014 Bob Beck 4bb523e98Stb * 5bb523e98Stb * Permission to use, copy, modify, and distribute this software for any 6bb523e98Stb * purpose with or without fee is hereby granted, provided that the above 7bb523e98Stb * copyright notice and this permission notice appear in all copies. 8bb523e98Stb * 9bb523e98Stb * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10bb523e98Stb * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11bb523e98Stb * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12bb523e98Stb * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13bb523e98Stb * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14bb523e98Stb * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15bb523e98Stb * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16bb523e98Stb */ 17a1c202f0Stb 18bb523e98Stb #include <stdio.h> 19bb523e98Stb #include <stdlib.h> 20bb523e98Stb #include <string.h> 21bb523e98Stb 22bb523e98Stb #include <openssl/crypto.h> 23bb523e98Stb 24*5f24b0e3Stb void 25*5f24b0e3Stb OPENSSL_cleanse(void *ptr, size_t len) 26*5f24b0e3Stb { 27*5f24b0e3Stb explicit_bzero(ptr, len); 28*5f24b0e3Stb } 29*5f24b0e3Stb LCRYPTO_ALIAS(OPENSSL_cleanse); 30*5f24b0e3Stb 31bb523e98Stb int 32bb523e98Stb CRYPTO_set_mem_functions(void *(*m)(size_t), void *(*r)(void *, size_t), 33bb523e98Stb void (*f)(void *)) 34bb523e98Stb { 35bb523e98Stb return 0; 36bb523e98Stb } 37bb523e98Stb LCRYPTO_ALIAS(CRYPTO_set_mem_functions); 38bb523e98Stb 39bb523e98Stb int 40bb523e98Stb CRYPTO_set_mem_ex_functions(void *(*m)(size_t, const char *, int), 41bb523e98Stb void *(*r)(void *, size_t, const char *, int), void (*f)(void *)) 42bb523e98Stb { 43bb523e98Stb return 0; 44bb523e98Stb } 45bb523e98Stb LCRYPTO_ALIAS(CRYPTO_set_mem_ex_functions); 46bb523e98Stb 47bb523e98Stb void * 48bb523e98Stb CRYPTO_malloc(size_t num, const char *file, int line) 49bb523e98Stb { 50bb523e98Stb return malloc(num); 51bb523e98Stb } 52bb523e98Stb LCRYPTO_ALIAS(CRYPTO_malloc); 53bb523e98Stb 54bb523e98Stb char * 55bb523e98Stb CRYPTO_strdup(const char *str, const char *file, int line) 56bb523e98Stb { 57bb523e98Stb return strdup(str); 58bb523e98Stb } 59bb523e98Stb LCRYPTO_ALIAS(CRYPTO_strdup); 60bb523e98Stb 61bb523e98Stb void 62bb523e98Stb CRYPTO_free(void *ptr, const char *file, int line) 63bb523e98Stb { 64bb523e98Stb free(ptr); 65bb523e98Stb } 66bb523e98Stb LCRYPTO_ALIAS(CRYPTO_free); 67