Debian Codegraph @

src/crypto/crypto-private.h

raw symbols SCIP
1 /* librist. Copyright © 2019 SipRadius LLC. All right reserved.
2 * Author: Kuldeep Singh Dhaka <[email protected]>
3 * Author: Sergio Ammirata, Ph.D. <[email protected]>
4 *
5 * SPDX-License-Identifier: BSD-2-Clause
6 */
7
8 #ifndef RIST_CRYPTO_PRIVATE_H
9 #define RIST_CRYPTO_PRIVATE_H
10
11 #include "common/attributes.h"
12 #include <stdint.h>
13 #include <stddef.h>
14
15 /* Best-effort wipe of transient key material that a compiler will not elide.
16 * Shared by the PSK and EAP v4 crypto paths. */
17 static inline void _librist_crypto_secure_zero(void *p, size_t n)
18 {
19 volatile unsigned char *v = (volatile unsigned char *)p;
20 while (n--)
21 *v++ = 0;
22 }
23
24 RIST_PRIV uint64_t rist_siphash(uint64_t birthtime, uint32_t seq, const char *phrase);
25
26 /* prand_u32: wall-clock fallback on CSPRNG failure. Non-security only (SSRC, flow-id, peer-id). */
27 RIST_PRIV uint32_t prand_u32(void);
28
29 /* Fail-closed CSPRNG. Returns 0 on success with *out populated, non-zero error otherwise. */
30 RIST_PRIV int _librist_crypto_random_u32(uint32_t *out);
31
32 #endif