BitPunch McEliece  v0.0.4
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
codectx.h
Go to the documentation of this file.
1 /*
2 This file is part of BitPunch
3 Copyright (C) 2015 Frantisek Uhrecky <frantisek.uhrecky[what here]gmail.com>
4 Copyright (C) 2015 Andrej Gulyas <andrej.guly[what here]gmail.com>
5 
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10 
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15 
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19 #ifndef BPU_CODECTX_H
20 #define BPU_CODECTX_H
21 
22 #include <stdint.h>
23 
24 #include <bitpunch/config.h>
25 #include <bitpunch/math/gf2.h>
26 #include <bitpunch/math/gf2x.h>
27 #include <bitpunch/math/mathctx.h>
28 
29 // addiotional codes
32 
34 typedef enum _BPU_T_EN_Code_Types {
37  // HERE you can add your code type
39 
41 typedef union _BPU_T_UN_Code_Spec{
44  // HERE you add your code spec structure
46 
47 typedef union _BPU_T_UN_Code_Params{
50  // HERE you add your code spec structure
52 
53 typedef struct _BPU_T_Code_Ctx {
55  int (* _encode)(BPU_T_GF2_Vector *out, const BPU_T_GF2_Vector *in, const struct _BPU_T_Code_Ctx *ctx);
56  int (* _decode)(BPU_T_GF2_Vector *out, const BPU_T_GF2_Vector *in, const struct _BPU_T_Code_Ctx *ctx);
60 
61  uint16_t code_len;
62  uint16_t msg_len;
63  uint8_t t;
65 
74 
83 int BPU_codeInitMathCtx(BPU_T_Math_Ctx **ctx, const uint16_t m, const uint16_t t, const BPU_T_GF2_16x mod);
84 
90 
91 // Available init params for all codes, it is only wrapper for code params init
100 int BPU_codeInitParamsGoppa(BPU_T_UN_Code_Params *params, const uint16_t m, const uint16_t t, const BPU_T_GF2_16x mod);
101 
107 
117 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);
118 
124 
125 // add yours additional params if needed
126 #endif // BPU_CODECTX_H
enum _BPU_T_EN_Code_Types BPU_T_EN_Code_Types
Possible types of codes.
BPU_T_Qcmdpc_Spec * qcmdpc
Definition: codectx.h:43
BPU_T_Goppa_Params * goppa
Definition: codectx.h:48
void BPU_codeFreeParamsQcmdpc(BPU_T_UN_Code_Params *params)
Definition: codectx.c:199
BPU_T_Math_Ctx * math_ctx
Math context.
Definition: codectx.h:57
BPU_T_Qcmdpc_Params * qcmdpc
Definition: codectx.h:49
int BPU_codeInitMathCtx(BPU_T_Math_Ctx **ctx, const uint16_t m, const uint16_t t, const BPU_T_GF2_16x mod)
BPU_codeInitMathCtx.
Definition: codectx.c:126
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.
Definition: codectx.c:187
uint16_t BPU_T_GF2_16x
Definition: gf2xtypes.h:26
uint16_t msg_len
Code dimenzion.
Definition: codectx.h:62
Code specifics union type.
Definition: codectx.h:41
BPU_T_GF2_Vector * e
Error vector.
Definition: codectx.h:58
void BPU_codeFreeCtx(BPU_T_Code_Ctx **ctx)
BPU_codeFreeCtx.
Definition: codectx.c:161
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.
Definition: codectx.h:56
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)
Definition: codectx.c:195
void BPU_codeFreeParamsGoppa(BPU_T_UN_Code_Params *params)
BPU_codeFreeParamsGoppa.
Definition: codectx.c:191
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.
Definition: codectx.h:55
_BPU_T_EN_Code_Types
Possible types of codes.
Definition: codectx.h:34
struct _BPU_T_Code_Ctx BPU_T_Code_Ctx
BPU_T_EN_Code_Types type
Definition: codectx.h:54
union _BPU_T_UN_Code_Spec BPU_T_UN_Code_Spec
Code specifics union type.
BPU_T_Goppa_Spec * goppa
Definition: codectx.h:42
union _BPU_T_UN_Code_Params BPU_T_UN_Code_Params
uint8_t t
Error code correction capability.
Definition: codectx.h:63
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 ...
Definition: codectx.c:31
uint16_t code_len
Code len.
Definition: codectx.h:61
BPU_T_UN_Code_Spec * code_spec
Code specific structure, like generator matrix, control matrix, gen. poly ...
Definition: codectx.h:59