BitPunch McEliece  v0.0.4
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
mecsctx.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 MECSCTX_H
20 #define MECSCTX_H
21 
22 #include <bitpunch/config.h>
23 #include <bitpunch/math/gf2.h>
24 #include <bitpunch/code/codectx.h>
25 
27 typedef enum _BPU_T_EN_Mecs_Types {
29 #ifdef BPU_CONF_MECS_CCA2_POINTCHEVAL_GOPPA
31 #endif
33 #ifdef BPU_CONF_MECS_CCA2_POINTCHEVAL_QCMDPC
35 #endif
37 
38 typedef struct _BPU_T_Mecs_Ctx {
40  int (* _encrypt)(BPU_T_GF2_Vector *out, const BPU_T_GF2_Vector *in, const struct _BPU_T_Mecs_Ctx *ctx);
41  int (* _decrypt)(BPU_T_GF2_Vector *out, const BPU_T_GF2_Vector *in, const struct _BPU_T_Mecs_Ctx *ctx);
42  int (* _genKeyPair)(struct _BPU_T_Code_Ctx *ctx);
43 
45  uint16_t pt_len;
46  uint16_t ct_len;
48 
50 
52 int BPU_mecsInitCtx(BPU_T_Mecs_Ctx **ctx, const BPU_T_UN_Mecs_Params *params, const BPU_T_EN_Mecs_Types type);
53 
55 
56 // Available init params for all codes, it is only wrapper for code params init
57 int BPU_mecsInitParamsGoppa(BPU_T_UN_Mecs_Params *params, const uint16_t m, const uint16_t t, const BPU_T_GF2_16x mod);
58 
60 
70 int BPU_mecsInitParamsQcmdpc(BPU_T_UN_Mecs_Params *params, const uint16_t m, const uint16_t n0, const uint16_t w, const uint16_t t);
71 
77 
78 // add yours additional params if needed
79 
80 #endif // MECSCTX_H
BPU_T_Code_Ctx * code_ctx
Definition: mecsctx.h:44
basic qc-mdpc mecs, without any conversion
Definition: mecsctx.h:32
uint16_t pt_len
PT len in bits.
Definition: mecsctx.h:45
uint16_t BPU_T_GF2_16x
Definition: gf2xtypes.h:26
int BPU_mecsFreeCtx(BPU_T_Mecs_Ctx **ctx)
Definition: mecsctx.c:158
int(* _encrypt)(BPU_T_GF2_Vector *out, const BPU_T_GF2_Vector *in, const struct _BPU_T_Mecs_Ctx *ctx)
Definition: mecsctx.h:40
int(* _genKeyPair)(struct _BPU_T_Code_Ctx *ctx)
Definition: mecsctx.h:42
void BPU_mecsFreeParamsQcmdpc(BPU_T_UN_Mecs_Params *params)
Definition: mecsctx.c:204
basic mecs, without any conversion
Definition: mecsctx.h:28
int BPU_mecsInitCtx(BPU_T_Mecs_Ctx **ctx, const BPU_T_UN_Mecs_Params *params, const BPU_T_EN_Mecs_Types type)
Initialize (register) mecs functions for encryption, decryption and key gen based on type...
Definition: mecsctx.c:37
enum _BPU_T_EN_Mecs_Types BPU_T_EN_Mecs_Types
Possible types of MECS.
int BPU_mecsInitParamsGoppa(BPU_T_UN_Mecs_Params *params, const uint16_t m, const uint16_t t, const BPU_T_GF2_16x mod)
Definition: mecsctx.c:192
int(* _decrypt)(BPU_T_GF2_Vector *out, const BPU_T_GF2_Vector *in, const struct _BPU_T_Mecs_Ctx *ctx)
Definition: mecsctx.h:41
uint16_t ct_len
CT len in bits.
Definition: mecsctx.h:46
adapted Pointcheval's cca2 conversion
Definition: mecsctx.h:30
BPU_T_EN_Mecs_Types type
Definition: mecsctx.h:39
void BPU_mecsFreeParamsGoppa(BPU_T_UN_Mecs_Params *params)
Definition: mecsctx.c:196
adapted Pointcheval's cca2 conversion for qcmdpc
Definition: mecsctx.h:34
int BPU_mecsInitParamsQcmdpc(BPU_T_UN_Mecs_Params *params, const uint16_t m, const uint16_t n0, const uint16_t w, const uint16_t t)
Definition: mecsctx.c:200
_BPU_T_EN_Mecs_Types
Possible types of MECS.
Definition: mecsctx.h:27
struct _BPU_T_Mecs_Ctx BPU_T_Mecs_Ctx