Lines Matching refs:meth

59 	GFMethod *meth;  in GFMethod_new()  local
61 meth = (GFMethod *) kmem_alloc(sizeof(GFMethod), kmflag); in GFMethod_new()
63 meth = (GFMethod *) malloc(sizeof(GFMethod)); in GFMethod_new()
64 if (meth == NULL) in GFMethod_new()
67 meth->constructed = MP_YES; in GFMethod_new()
68 MP_DIGITS(&meth->irr) = 0; in GFMethod_new()
69 meth->extra_free = NULL; in GFMethod_new()
70 MP_CHECKOK(mp_init(&meth->irr, kmflag)); in GFMethod_new()
74 GFMethod_free(meth); in GFMethod_new()
77 return meth; in GFMethod_new()
86 GFMethod *meth = NULL; in GFMethod_consGFp() local
88 meth = GFMethod_new(FLAG(irr)); in GFMethod_consGFp()
89 if (meth == NULL) in GFMethod_consGFp()
92 MP_CHECKOK(mp_copy(irr, &meth->irr)); in GFMethod_consGFp()
93 meth->irr_arr[0] = mpl_significant_bits(irr); in GFMethod_consGFp()
94 meth->irr_arr[1] = meth->irr_arr[2] = meth->irr_arr[3] = in GFMethod_consGFp()
95 meth->irr_arr[4] = 0; in GFMethod_consGFp()
96 switch(MP_USED(&meth->irr)) { in GFMethod_consGFp()
99 meth->field_add = &ec_GFp_add_3; in GFMethod_consGFp()
100 meth->field_sub = &ec_GFp_sub_3; in GFMethod_consGFp()
103 meth->field_add = &ec_GFp_add_4; in GFMethod_consGFp()
104 meth->field_sub = &ec_GFp_sub_4; in GFMethod_consGFp()
107 meth->field_add = &ec_GFp_add_5; in GFMethod_consGFp()
108 meth->field_sub = &ec_GFp_sub_5; in GFMethod_consGFp()
111 meth->field_add = &ec_GFp_add_6; in GFMethod_consGFp()
112 meth->field_sub = &ec_GFp_sub_6; in GFMethod_consGFp()
115 meth->field_add = &ec_GFp_add; in GFMethod_consGFp()
116 meth->field_sub = &ec_GFp_sub; in GFMethod_consGFp()
118 meth->field_neg = &ec_GFp_neg; in GFMethod_consGFp()
119 meth->field_mod = &ec_GFp_mod; in GFMethod_consGFp()
120 meth->field_mul = &ec_GFp_mul; in GFMethod_consGFp()
121 meth->field_sqr = &ec_GFp_sqr; in GFMethod_consGFp()
122 meth->field_div = &ec_GFp_div; in GFMethod_consGFp()
123 meth->field_enc = NULL; in GFMethod_consGFp()
124 meth->field_dec = NULL; in GFMethod_consGFp()
125 meth->extra1 = NULL; in GFMethod_consGFp()
126 meth->extra2 = NULL; in GFMethod_consGFp()
127 meth->extra_free = NULL; in GFMethod_consGFp()
131 GFMethod_free(meth); in GFMethod_consGFp()
134 return meth; in GFMethod_consGFp()
146 GFMethod *meth = NULL; in GFMethod_consGF2m() local
148 meth = GFMethod_new(FLAG(irr)); in GFMethod_consGF2m()
149 if (meth == NULL) in GFMethod_consGF2m()
152 MP_CHECKOK(mp_copy(irr, &meth->irr)); in GFMethod_consGF2m()
155 meth->irr_arr[0] = irr_arr[0]; in GFMethod_consGF2m()
156 meth->irr_arr[1] = irr_arr[1]; in GFMethod_consGF2m()
157 meth->irr_arr[2] = irr_arr[2]; in GFMethod_consGF2m()
159 meth->irr_arr[3] = irr_arr[3]; in GFMethod_consGF2m()
160 meth->irr_arr[4] = irr_arr[4]; in GFMethod_consGF2m()
162 meth->irr_arr[3] = meth->irr_arr[4] = 0; in GFMethod_consGF2m()
165 ret = mp_bpoly2arr(irr, meth->irr_arr, 5); in GFMethod_consGF2m()
172 meth->field_add = &ec_GF2m_add; in GFMethod_consGF2m()
173 meth->field_neg = &ec_GF2m_neg; in GFMethod_consGF2m()
174 meth->field_sub = &ec_GF2m_add; in GFMethod_consGF2m()
175 meth->field_mod = &ec_GF2m_mod; in GFMethod_consGF2m()
176 meth->field_mul = &ec_GF2m_mul; in GFMethod_consGF2m()
177 meth->field_sqr = &ec_GF2m_sqr; in GFMethod_consGF2m()
178 meth->field_div = &ec_GF2m_div; in GFMethod_consGF2m()
179 meth->field_enc = NULL; in GFMethod_consGF2m()
180 meth->field_dec = NULL; in GFMethod_consGF2m()
181 meth->extra1 = NULL; in GFMethod_consGF2m()
182 meth->extra2 = NULL; in GFMethod_consGF2m()
183 meth->extra_free = NULL; in GFMethod_consGF2m()
187 GFMethod_free(meth); in GFMethod_consGF2m()
190 return meth; in GFMethod_consGF2m()
195 GFMethod_free(GFMethod *meth) in GFMethod_free() argument
197 if (meth == NULL) in GFMethod_free()
199 if (meth->constructed == MP_NO) in GFMethod_free()
201 mp_clear(&meth->irr); in GFMethod_free()
202 if (meth->extra_free != NULL) in GFMethod_free()
203 meth->extra_free(meth); in GFMethod_free()
205 kmem_free(meth, sizeof(GFMethod)); in GFMethod_free()
207 free(meth); in GFMethod_free()
216 const GFMethod *meth) in ec_GFp_add() argument
224 if (mp_cmp(r, &meth->irr) >= 0) { in ec_GFp_add()
225 return mp_sub(r, &meth->irr, r); in ec_GFp_add()
232 ec_GFp_neg(const mp_int *a, mp_int *r, const GFMethod *meth) in ec_GFp_neg() argument
240 return mp_sub(&meth->irr, a, r); in ec_GFp_neg()
246 const GFMethod *meth) in ec_GFp_sub() argument
255 MP_CHECKOK(mp_add(r, &meth->irr, r)); in ec_GFp_sub()
257 MP_CHECKOK(ec_GFp_neg(r, r, meth)); in ec_GFp_sub()
260 MP_CHECKOK(mp_add(r, &meth->irr, r)); in ec_GFp_sub()
271 const GFMethod *meth) in ec_GFp_add_3() argument
325 a2 = MP_DIGIT(&meth->irr,2); in ec_GFp_add_3()
327 ((r2 == a2) && mp_cmp(r,&meth->irr) != MP_LT)) { in ec_GFp_add_3()
328 a1 = MP_DIGIT(&meth->irr,1); in ec_GFp_add_3()
329 a0 = MP_DIGIT(&meth->irr,0); in ec_GFp_add_3()
358 const GFMethod *meth) in ec_GFp_add_4() argument
421 a3 = MP_DIGIT(&meth->irr,3); in ec_GFp_add_4()
423 ((r3 == a3) && mp_cmp(r,&meth->irr) != MP_LT)) { in ec_GFp_add_4()
424 a2 = MP_DIGIT(&meth->irr,2); in ec_GFp_add_4()
425 a1 = MP_DIGIT(&meth->irr,1); in ec_GFp_add_4()
426 a0 = MP_DIGIT(&meth->irr,0); in ec_GFp_add_4()
458 const GFMethod *meth) in ec_GFp_add_5() argument
515 a4 = MP_DIGIT(&meth->irr,4); in ec_GFp_add_5()
517 ((r4 == a4) && mp_cmp(r,&meth->irr) != MP_LT)) { in ec_GFp_add_5()
518 a3 = MP_DIGIT(&meth->irr,3); in ec_GFp_add_5()
519 a2 = MP_DIGIT(&meth->irr,2); in ec_GFp_add_5()
520 a1 = MP_DIGIT(&meth->irr,1); in ec_GFp_add_5()
521 a0 = MP_DIGIT(&meth->irr,0); in ec_GFp_add_5()
543 const GFMethod *meth) in ec_GFp_add_6() argument
608 a5 = MP_DIGIT(&meth->irr,5); in ec_GFp_add_6()
610 ((r5 == a5) && mp_cmp(r,&meth->irr) != MP_LT)) { in ec_GFp_add_6()
611 a4 = MP_DIGIT(&meth->irr,4); in ec_GFp_add_6()
612 a3 = MP_DIGIT(&meth->irr,3); in ec_GFp_add_6()
613 a2 = MP_DIGIT(&meth->irr,2); in ec_GFp_add_6()
614 a1 = MP_DIGIT(&meth->irr,1); in ec_GFp_add_6()
615 a0 = MP_DIGIT(&meth->irr,0); in ec_GFp_add_6()
644 const GFMethod *meth) in ec_GFp_sub_3() argument
692 b2 = MP_DIGIT(&meth->irr,2); in ec_GFp_sub_3()
693 b1 = MP_DIGIT(&meth->irr,1); in ec_GFp_sub_3()
694 b0 = MP_DIGIT(&meth->irr,0); in ec_GFp_sub_3()
732 const GFMethod *meth) in ec_GFp_sub_4() argument
788 b3 = MP_DIGIT(&meth->irr,3); in ec_GFp_sub_4()
789 b2 = MP_DIGIT(&meth->irr,2); in ec_GFp_sub_4()
790 b1 = MP_DIGIT(&meth->irr,1); in ec_GFp_sub_4()
791 b0 = MP_DIGIT(&meth->irr,0); in ec_GFp_sub_4()
831 const GFMethod *meth) in ec_GFp_sub_5() argument
880 b4 = MP_DIGIT(&meth->irr,4); in ec_GFp_sub_5()
881 b3 = MP_DIGIT(&meth->irr,3); in ec_GFp_sub_5()
882 b2 = MP_DIGIT(&meth->irr,2); in ec_GFp_sub_5()
883 b1 = MP_DIGIT(&meth->irr,1); in ec_GFp_sub_5()
884 b0 = MP_DIGIT(&meth->irr,0); in ec_GFp_sub_5()
907 const GFMethod *meth) in ec_GFp_sub_6() argument
963 b5 = MP_DIGIT(&meth->irr,5); in ec_GFp_sub_6()
964 b4 = MP_DIGIT(&meth->irr,4); in ec_GFp_sub_6()
965 b3 = MP_DIGIT(&meth->irr,3); in ec_GFp_sub_6()
966 b2 = MP_DIGIT(&meth->irr,2); in ec_GFp_sub_6()
967 b1 = MP_DIGIT(&meth->irr,1); in ec_GFp_sub_6()
968 b0 = MP_DIGIT(&meth->irr,0); in ec_GFp_sub_6()
994 ec_GFp_mod(const mp_int *a, mp_int *r, const GFMethod *meth) in ec_GFp_mod() argument
996 return mp_mod(a, &meth->irr, r); in ec_GFp_mod()
1002 const GFMethod *meth) in ec_GFp_mul() argument
1004 return mp_mulmod(a, b, &meth->irr, r); in ec_GFp_mul()
1009 ec_GFp_sqr(const mp_int *a, mp_int *r, const GFMethod *meth) in ec_GFp_sqr() argument
1011 return mp_sqrmod(a, &meth->irr, r); in ec_GFp_sqr()
1018 const GFMethod *meth) in ec_GFp_div() argument
1025 return mp_invmod(b, &meth->irr, r); in ec_GFp_div()
1030 MP_CHECKOK(mp_invmod(b, &meth->irr, &t)); in ec_GFp_div()
1031 MP_CHECKOK(mp_mulmod(a, &t, &meth->irr, r)); in ec_GFp_div()
1043 const GFMethod *meth) in ec_GF2m_add() argument
1051 ec_GF2m_neg(const mp_int *a, mp_int *r, const GFMethod *meth) in ec_GF2m_neg() argument
1062 ec_GF2m_mod(const mp_int *a, mp_int *r, const GFMethod *meth) in ec_GF2m_mod() argument
1064 return mp_bmod(a, meth->irr_arr, r); in ec_GF2m_mod()
1070 const GFMethod *meth) in ec_GF2m_mul() argument
1072 return mp_bmulmod(a, b, meth->irr_arr, r); in ec_GF2m_mul()
1077 ec_GF2m_sqr(const mp_int *a, mp_int *r, const GFMethod *meth) in ec_GF2m_sqr() argument
1079 return mp_bsqrmod(a, meth->irr_arr, r); in ec_GF2m_sqr()
1086 const GFMethod *meth) in ec_GF2m_div() argument
1097 MP_CHECKOK(mp_bdivmod(&t, b, &meth->irr, meth->irr_arr, r)); in ec_GF2m_div()
1102 return mp_bdivmod(a, b, &meth->irr, meth->irr_arr, r); in ec_GF2m_div()