HMAC-BLAKE2s, HKDF, TAI64N 実装追加
暗号プリミティブ実装: - HMAC-BLAKE2s (RFC 2104): BLAKE2s ベースの HMAC - HKDF-BLAKE2s (RFC 586): 鍵導出関数 - HKDF-Extract: 入力鍵から PRK を導出 - HKDF-Expand: PRK から必要な長さの鍵を導出 - TAI64N: WireGuard プロトコル層のタイムスタンプ(12 バイト) WireGuard での使用: - ハンドシェイク中の鍵導出チェーン - チェーン鍵 (Ck)・セッション鍵 (tk) の導出 - リプレイ防止用タイムスタンプ テスト: - test_hmac_blake2s: HMAC-BLAKE2s 検証 ✅ - test_hkdf_blake2s: HKDF 検証 ✅ - test_tai64n: TAI64N エンコード/デコード ✅
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* @file se050_hmac_blake2s.h
|
||||
* @brief HMAC-BLAKE2s Implementation (RFC 2104)
|
||||
*/
|
||||
|
||||
#ifndef SE050_HMAC_BLAKE2S_H
|
||||
#define SE050_HMAC_BLAKE2S_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define HMAC_BLAKE2S_BLOCK_SIZE 64
|
||||
#define HMAC_BLAKE2S_DIGEST_SIZE 32
|
||||
|
||||
/**
|
||||
* @brief Compute HMAC-BLAKE2s
|
||||
* @param out Output buffer (32 bytes)
|
||||
* @param key Key data
|
||||
* @param keylen Key length (1-64 bytes)
|
||||
* @param data Input data
|
||||
* @param datalen Input data length
|
||||
* @return 0 on success, -1 on error
|
||||
*/
|
||||
int se050_hmac_blake2s(uint8_t out[32],
|
||||
const uint8_t *key, size_t keylen,
|
||||
const uint8_t *data, size_t datalen);
|
||||
|
||||
/**
|
||||
* @brief One-shot HMAC-BLAKE2s with variable output length
|
||||
* @param out Output buffer
|
||||
* @param outlen Output length (1-32 bytes)
|
||||
* @param key Key data
|
||||
* @param keylen Key length
|
||||
* @param data Input data
|
||||
* @param datalen Input data length
|
||||
* @return 0 on success, -1 on error
|
||||
*/
|
||||
int se050_hmac_blake2s_variable(uint8_t *out, size_t outlen,
|
||||
const uint8_t *key, size_t keylen,
|
||||
const uint8_t *data, size_t datalen);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* SE050_HMAC_BLAKE2S_H */
|
||||
Reference in New Issue
Block a user