aboutsummaryrefslogtreecommitdiff
path: root/src/lib/crypt_ops/crypto_util.h
blob: 36ee230176ff11d8ad1f02ad8535da63922c511c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/* Copyright (c) 2001, Matej Pfajfar.
 * Copyright (c) 2001-2004, Roger Dingledine.
 * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
 * Copyright (c) 2007-2020, The Tor Project, Inc. */
/* See LICENSE for licensing information */

/**
 * \file crypto_util.h
 *
 * \brief Common functions for cryptographic routines.
 **/

#ifndef TOR_CRYPTO_UTIL_H
#define TOR_CRYPTO_UTIL_H

#include "lib/cc/torint.h"
#include "lib/malloc/malloc.h"

/** OpenSSL-based utility functions. */
void memwipe(void *mem, uint8_t byte, size_t sz);

void tor_str_wipe_and_free_(char *str);
/**
 * Securely all memory in <b>str</b>, then free it.
 *
 * As tor_free(), tolerates null pointers, and sets <b>str</b> to NULL.
 **/
#define tor_str_wipe_and_free(str)                      \
  FREE_AND_NULL(char, tor_str_wipe_and_free_, (str))

#endif /* !defined(TOR_CRYPTO_UTIL_H) */