BitPunch McEliece  v0.0.4
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
goppatypes.c
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 
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 #include "goppatypes.h"
19 #include <bitpunch/debugio.h>
20 
21 #include <stdlib.h>
22 
23 #include <bitpunch/math/gf2types.h>
26 
28  BPU_gf2xPolyFree(&spec->g);
29  BPU_gf2MatFree(&spec->g_mat);
30 #ifndef BPU_CONF_GOPPA_WO_H
31  BPU_gf2xMatFree(&spec->h_mat);
32 #endif
33  BPU_permFree(&spec->permutation);
34 }
35 
36 int BPU_goppaInitParams(BPU_T_Goppa_Params **params, const uint16_t m, const uint16_t t, const BPU_T_GF2_16x mod) {
37  *params = (BPU_T_Goppa_Params*) calloc(sizeof(BPU_T_Goppa_Params), 1);
38 
39  if (!params) {
40  BPU_printError("Can't init Code params");
41 
42  return -1;
43  }
44  (*params)->m = m;
45  (*params)->t = t;
46  (*params)->mod = mod;
47 
48  return 0;
49 }
50 
52  if (*params) {
53  free(*params);
54  }
55  *params = NULL;
56 }
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.
Definition: goppatypes.c:36
void BPU_permFree(BPU_T_Perm_Vector **p)
Free dynamically or statically alocated permutation vector.
Definition: permtypes.c:27
BPU_T_GF2_Matrix * g_mat
Generator matrix.
Definition: goppatypes.h:28
void BPU_goppaFreeSpec(BPU_T_Goppa_Spec *spec)
BPU_goppaFreeSpec Free Goppa code internal structure.
Definition: goppatypes.c:27
uint16_t BPU_T_GF2_16x
Definition: gf2xtypes.h:26
BPU_T_Perm_Vector * permutation
permutation "matrix"
Definition: goppatypes.h:31
BPU_T_GF2_16x_Matrix * h_mat
Control matrix H.
Definition: goppatypes.h:29
#define BPU_printError(fmt,...)
print error message with filename, line
Definition: debugio.h:47
void BPU_gf2xMatFree(BPU_T_GF2_16x_Matrix **m)
Free dynamically or statically allocated matrix.
Definition: gf2xtypes.c:86
void BPU_gf2xPolyFree(BPU_T_GF2_16x_Poly **p)
Definition: gf2xtypes.c:102
uint8_t t
Error code correction capability.
Definition: codectx.h:63
void BPU_gf2MatFree(BPU_T_GF2_Matrix **m)
Free dynamically or statically allocated matrix.
Definition: gf2types.c:29
void BPU_goppaFreeParams(BPU_T_Goppa_Params **params)
BPU_goppaFreeParams Free goppa code params.
Definition: goppatypes.c:51
BPU_T_GF2_16x_Poly * g
gen. polynomial
Definition: goppatypes.h:30