24 行
682 B
C
24 行
682 B
C
#ifndef PAZE_MEM_H
|
|
#define PAZE_MEM_H
|
|
#include "paze/paze_types.h"
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/* 常量时间比较:相等返回 0。仅依赖比较结果不分支。 */
|
|
int paze_ct_equal(const void *a, const void *b, size_t n);
|
|
|
|
/* 常量时间:cond 为真则 dst <- src。cond 转为 0/1 后逐字节掩码。 */
|
|
void paze_ct_select(void *dst, const void *src, size_t n, int cond);
|
|
|
|
/* 安全清零:不被编译器优化掉。 */
|
|
void paze_memzero(void *p, size_t n);
|
|
|
|
/* 确定性填充(用于 PKCS#7 / PKCS#1 等已知模式,非密钥路径)。 */
|
|
void paze_xor_block(uint8_t *dst, const uint8_t *a, const uint8_t *b, size_t n);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
#endif
|