2 * transsip - the telephony toolkit
3 * By Daniel Borkmann <daniel@transsip.org>
4 * Copyright 2012 Daniel Borkmann <dborkma@tik.ee.ethz.ch>
5 * Subject to the GPL, version 2.
6 * Based on Bhaskar Biswas and Nicolas Sendrier McEliece
7 * implementation, LGPL 2.1.
17 gf16_t
*coeff
; /* polynomial has coefficients in the finite field */
25 #define poly_deg(p) ((p)->deg)
26 #define poly_size(p) ((p)->size)
27 #define poly_set_deg(p, d) ((p)->deg = (d))
28 #define poly_coeff(p, i) ((p)->coeff[i])
29 #define poly_set_coeff(p, i, a) ((p)->coeff[i] = (a))
30 #define poly_addto_coeff(p, i, a) ((p)->coeff[i] = gf_add((p)->coeff[i], (a)))
31 #define poly_multo_coeff(p, i, a) ((p)->coeff[i] = gf_mul((p)->coeff[i], (a)))
32 #define poly_tete(p) ((p)->coeff[(p)->deg])
34 extern int poly_calcule_deg(struct polynomial
*p
);
35 extern struct polynomial
*poly_alloc(int d
);
36 extern struct polynomial
*
37 poly_alloc_from_string(int d
, const unsigned char *str
, size_t len
);
38 extern struct polynomial
*poly_copy(struct polynomial
*p
);
39 extern void poly_free(struct polynomial
*p
);
40 extern void poly_set_to_zero(struct polynomial
*p
);
41 extern void poly_set(struct polynomial
*p
, struct polynomial
*q
);
42 extern struct polynomial
*poly_mul(struct polynomial
*p
, struct polynomial
*q
);
43 extern void poly_rem(struct polynomial
*p
, struct polynomial
*g
);
44 extern void poly_sqmod_init(struct polynomial
*g
, struct polynomial
**sq
);
45 extern void poly_sqmod(struct polynomial
*res
, struct polynomial
*p
,
46 struct polynomial
**sq
, int d
);
47 extern struct polynomial
*poly_gcd(struct polynomial
*p1
,
48 struct polynomial
*p2
);
49 extern struct polynomial
*poly_quo(struct polynomial
*p
,
50 struct polynomial
*d
);
51 extern gf16_t
poly_eval(struct polynomial
*p
, gf16_t a
);
52 extern int poly_degppf(struct polynomial
*g
);
53 extern void poly_eeaux(struct polynomial
**u
, struct polynomial
**v
,
54 struct polynomial
*p
, struct polynomial
*g
, int t
);
55 extern struct polynomial
**poly_syndrome_init(struct polynomial
*generator
,
56 gf16_t
*support
, int n
);
57 extern struct polynomial
**poly_sqrtmod_init(struct polynomial
*g
);
58 extern struct polynomial
*poly_randgen_irred(int t
, int (*u8rnd
)(void));