// crypto.h --- cryptography utilities // // Copyright (c) 2026 Martin Michalec // // SPDX-License-Identifier: MIT // // Commentary: // // Code: #ifndef INCLUDED_CRYPTO_H #define INCLUDED_CRYPTO_H #include #include #include "utils.h" #define X25519_PUBKEY_LEN 32 #define SHA_DIGEST_SIZE 20 #define AES_256_KEY_SIZE 32 #define AES_BLOCK_SIZE 16 #define AES_IV_SIZE 16 typedef uint8_t aes_256_key[AES_256_KEY_SIZE]; extern uint8_t local_pubkey[X25519_PUBKEY_LEN]; bool crypto_init (void); ssize_t sha1_hash (uint8_t out[SHA_DIGEST_SIZE], struct memory_view in); bool hkdf_sha256 (const uint8_t peer_pubkey[X25519_PUBKEY_LEN], aes_256_key out); ssize_t aes_256_cbc_encrypt (struct memory_span out, struct memory_view in, const aes_256_key, bool salt); ssize_t aes_256_cbc_decrypt (struct memory_span out, struct memory_view in, const aes_256_key, bool salt); #endif // INCLUDED_CRYPTO_H // crypto.h ends here