52 #ifdef BPU_CONF_ENCRYPTION
55 #ifdef BPU_CONF_DECRYPTION
78 #ifdef BPU_CONF_ENCRYPTION
82 #ifdef BPU_CONF_DECRYPTION
141 else if (m == 5 && t == 5) {
144 else if (m == 6 && t == 6) {
147 else if (m == 6 && t == 7) {
150 else if (m == 11 && t == 50) {
154 BPU_printError(
"Code params not supported. Supported only (m,t): (5,5), (6,6), (6,7), (11,50)");
167 switch (ctx_p->
type) {
enum _BPU_T_EN_Code_Types BPU_T_EN_Code_Types
Possible types of codes.
BPU_T_Qcmdpc_Spec * qcmdpc
BPU_T_Goppa_Params * goppa
int BPU_goppaInitParams(BPU_T_Goppa_Params **params, const uint16_t m, const uint16_t t, const BPU_T_GF2_16x mod)
BPU_goppaInitParams Initi Goppa code params.
int BPU_gf2VecMalloc(BPU_T_GF2_Vector **v, int len)
void BPU_qcmdpcFreeParams(BPU_T_Qcmdpc_Params **params)
int BPU_mecsQcmdpcDecrypt(BPU_T_GF2_Vector *out, const BPU_T_GF2_Vector *in, const struct _BPU_T_Code_Ctx *ctx)
BPU_T_Math_Ctx * math_ctx
Math context.
void BPU_mathFreeCtx(BPU_T_Math_Ctx **ctx)
Free dynamiccaly or statically allocated Aritmetic_Data structure.
#define BPU_GF2_POLY_DEG_5
void BPU_gf2VecFree(BPU_T_GF2_Vector **v)
Free dynamically or statically allocated vector.
uint16_t t
error capability of code
void BPU_goppaFreeSpec(BPU_T_Goppa_Spec *spec)
BPU_goppaFreeSpec Free Goppa code internal structure.
BPU_T_Qcmdpc_Params * qcmdpc
uint16_t m
degree of mod polynomial
void BPU_codeFreeParamsGoppa(BPU_T_UN_Code_Params *params)
BPU_codeFreeParamsGoppa.
void BPU_codeFreeParamsQcmdpc(BPU_T_UN_Code_Params *params)
#define BPU_GF2_POLY_DEG_6
#define BPU_EC_CODE_TYPE_NOT_SUPPORTED
uint16_t n0
number of cyclic matrices
int BPU_goppaDecode(BPU_T_GF2_Vector *out, const BPU_T_GF2_Vector *in, const struct _BPU_T_Code_Ctx *ctx)
int BPU_codeInitCtx(BPU_T_Code_Ctx **ctx, const BPU_T_UN_Code_Params *params, const BPU_T_EN_Code_Types type)
BPU_codeInitCtx Initialize (register) code functions encode, decode and code spec structure based on ...
uint16_t w
weight of parity-check matrix row
uint16_t m
size of cyclic matrix
uint16_t msg_len
Code dimenzion.
#define BPU_printError(fmt,...)
print error message with filename, line
int BPU_codeInitParamsQcmdpc(BPU_T_UN_Code_Params *params, const uint16_t m, const uint16_t n0, const uint16_t w, const uint16_t t)
uint16_t support_len
number of elements in support
int BPU_qcmdpcInitParams(BPU_T_Qcmdpc_Params **params, const uint16_t m, const uint16_t n0, const uint16_t w, const uint16_t t)
Code specifics union type.
BPU_T_GF2_Vector * e
Error vector.
uint16_t w
weight of parity-check matrix row
int(* _decode)(BPU_T_GF2_Vector *out, const BPU_T_GF2_Vector *in, const struct _BPU_T_Code_Ctx *ctx)
This is reference to decode function. It will be set in BPU_codeInitCtx.
#define BPU_GF2_POLY_DEG_11
int(* _encode)(BPU_T_GF2_Vector *out, const BPU_T_GF2_Vector *in, const struct _BPU_T_Code_Ctx *ctx)
This is reference to encode function. It will be set in BPU_codeInitCtx.
int BPU_mathInitCtx(BPU_T_Math_Ctx **ctx, const BPU_T_GF2_16x g, const BPU_T_GF2_16x mod)
Precalculate logaritmic and exponencial tables and initialize structure Aritmetic_Data.
uint16_t n0
number of cyclic matrices
uint16_t t
count of errors
void BPU_codeFreeCtx(BPU_T_Code_Ctx **ctx)
BPU_codeFreeCtx.
void BPU_qcmdpcFreeSpec(BPU_T_Qcmdpc_Spec *spec)
int BPU_mecsQcmdpcEncode(BPU_T_GF2_Vector *out, const BPU_T_GF2_Vector *in, const struct _BPU_T_Code_Ctx *ctx)
BPU_T_GF2_16x mod
Galois field polynomial.
int BPU_codeInitMathCtx(BPU_T_Math_Ctx **ctx, const uint16_t m, const uint16_t t, const BPU_T_GF2_16x mod)
BPU_codeInitMathCtx.
uint16_t m
size of cyclic matrix
int BPU_codeInitParamsGoppa(BPU_T_UN_Code_Params *params, const uint16_t m, const uint16_t t, const BPU_T_GF2_16x mod)
BPU_codeInitParamsGoppa.
#define BPU_EC_MALLOC_ERROR
int BPU_goppaEncode(BPU_T_GF2_Vector *out, const BPU_T_GF2_Vector *in, const struct _BPU_T_Code_Ctx *ctx)
BPU_goppaEncode Encode message using goppa code.
#define BPU_EC_CODE_PARAMS_NOT_SUPPORTED
uint8_t t
Error code correction capability.
uint16_t code_len
Code len.
void BPU_goppaFreeParams(BPU_T_Goppa_Params **params)
BPU_goppaFreeParams Free goppa code params.
BPU_T_UN_Code_Spec * code_spec
Code specific structure, like generator matrix, control matrix, gen. poly ...