Debian Codegraph @

src/crypto/eap_v4_crypto.h

raw symbols SCIP
1 /* librist. Copyright © 2026 SipRadius LLC. All right reserved.
2 * Author: Sergio Ammirata, Ph.D. <[email protected]>
3 *
4 * SPDX-License-Identifier: BSD-2-Clause
5 */
6
7 #ifndef RIST_CRYPTO_EAP_V4_CRYPTO_H
8 #define RIST_CRYPTO_EAP_V4_CRYPTO_H
9
10 #include "common/attributes.h"
11 #include "crypto-private.h"
12 #include <stdint.h>
13 #include <stddef.h>
14
15 /* EAP SHA256-SRP6a Version 4 authenticated passphrase channel primitives:
16 * HKDF-Expand-SHA256 (per-direction key derivation) and AES-256-GCM. AEAD/HMAC
17 * need a real crypto backend (mbedTLS or Nettle); the built-in fallback returns
18 * -1, which the caller treats as "v4 unavailable, negotiate down to v3".
19 *
20 * All functions return 0 on success and a negative value on error / backend
21 * unavailable. */
22
23 /* _librist_crypto_secure_zero (best-effort key-material wipe) is provided by
24 * crypto-private.h. */
25
26 /* RFC 5869 §2.3 HKDF-Expand with SHA-256. PRK is used directly as the HMAC key
27 * (K is already a uniformly random 256-bit value, so Extract is unnecessary). */
28 RIST_PRIV int _librist_crypto_hkdf_expand_sha256(const uint8_t *prk, size_t prk_len,
29 const uint8_t *info, size_t info_len,
30 uint8_t *okm, size_t okm_len);
31
32 /* AES-256-GCM encrypt. key is 32 octets; iv is iv_len octets (12 for v4);
33 * tag_len is 16. ct must have room for pt_len octets. */
34 RIST_PRIV int _librist_crypto_aes_gcm_encrypt(const uint8_t *key, const uint8_t *iv, size_t iv_len,
35 const uint8_t *aad, size_t aad_len,
36 const uint8_t *pt, size_t pt_len,
37 uint8_t *ct, uint8_t *tag, size_t tag_len);
38
39 /* AES-256-GCM decrypt with tag verification. Returns 0 only if the tag is valid;
40 * on any failure the plaintext buffer is zeroed so a caller can never act on
41 * unverified output. */
42 RIST_PRIV int _librist_crypto_aes_gcm_decrypt(const uint8_t *key, const uint8_t *iv, size_t iv_len,
43 const uint8_t *aad, size_t aad_len,
44 const uint8_t *ct, size_t ct_len,
45 const uint8_t *tag, size_t tag_len,
46 uint8_t *pt);
47
48 #endif