Lines Matching refs:ff
69 EpidStatus NewFiniteField(BigNumStr const* prime, FiniteField** ff) { in NewFiniteField() argument
82 if (!prime || !ff) { in NewFiniteField()
152 *ff = finitefield_ptr; in NewFiniteField()
166 int degree, FiniteField** ff) { in NewFiniteFieldViaBinomalExtension() argument
176 if (!ground_field || !ground_element || !ff) { in NewFiniteFieldViaBinomalExtension()
261 *ff = finitefield_ptr; in NewFiniteFieldViaBinomalExtension()
277 int degree, FiniteField** ff) { in NewFiniteFieldViaPolynomialExtension() argument
289 if (!ground_field || !irr_polynomial || !ff) { in NewFiniteFieldViaPolynomialExtension()
380 *ff = finitefield_ptr; in NewFiniteFieldViaPolynomialExtension()
400 void DeleteFiniteField(FiniteField** ff) { in DeleteFiniteField() argument
401 if (ff) { in DeleteFiniteField()
402 if (*ff) { in DeleteFiniteField()
403 SAFE_FREE((*ff)->ipp_ff); in DeleteFiniteField()
404 DeleteBigNum(&(*ff)->modulus_0); in DeleteFiniteField()
406 SAFE_FREE((*ff)); in DeleteFiniteField()
410 EpidStatus NewFfElement(FiniteField const* ff, FfElement** new_ff_elem) { in NewFfElement() argument
419 if (!ff || !new_ff_elem) { in NewFfElement()
422 } else if (!ff->ipp_ff) { in NewFfElement()
427 sts = ippsGFpElementGetSize(ff->ipp_ff, (int*)&ctxsize); in NewFfElement()
440 sts = ippsGFpElementInit(&zero, 1, ipp_ff_elem, ff->ipp_ff); in NewFfElement()
453 ff_elem->element_len = ff->element_len; in NewFfElement()
454 ff_elem->degree = ff->ground_degree; in NewFfElement()
477 FiniteField const* ff) { in IsValidFfElemOctString() argument
487 if (!ff || !ff_elem_str) { in IsValidFfElemOctString()
490 basic_ff = ff; in IsValidFfElemOctString()
496 for (i = 0; (i < ff->basic_degree) && (tmp_strlen > 0); i++) { in IsValidFfElemOctString()
529 FfElement* ff_elem, FiniteField* ff) { in SetFfElementOctString() argument
532 if (!ff || !ff_elem || !ff_elem_str) { in SetFfElementOctString()
539 result = IsValidFfElemOctString(ff_elem_str, strlen, ff); in SetFfElementOctString()
544 if (strlen < (int)(ff->element_len * sizeof(Ipp32u))) { in SetFfElementOctString()
545 int length = ff->element_len * sizeof(Ipp32u); in SetFfElementOctString()
555 ff_elem->ipp_ff_elem, ff->ipp_ff); in SetFfElementOctString()
558 ff_elem->ipp_ff_elem, ff->ipp_ff); in SetFfElementOctString()
573 EpidStatus ReadFfElement(FiniteField* ff, ConstOctStr ff_elem_str, in ReadFfElement() argument
580 if (!ff || !ff_elem_str || !ff_elem) { in ReadFfElement()
583 if (!ff_elem->ipp_ff_elem || !ff->ipp_ff) { in ReadFfElement()
587 if (ff->element_len != ff_elem->element_len) { in ReadFfElement()
591 strlen_required = ff->element_strlen_required; in ReadFfElement()
596 if (1 == ff->basic_degree) { in ReadFfElement()
614 result = SetFfElementOctString(str, ipp_str_size, ff_elem, ff); in ReadFfElement()
633 EpidStatus GetFiniteFieldPrime(FiniteField* ff, BigNum** bn) { in GetFiniteFieldPrime() argument
634 if (!ff || !bn) { in GetFiniteFieldPrime()
637 if (!ff->ipp_ff) { in GetFiniteFieldPrime()
640 if (ff->basic_degree != 1 || ff->ground_degree != 1) { in GetFiniteFieldPrime()
643 *bn = ff->modulus_0; in GetFiniteFieldPrime()
647 EpidStatus InitFfElementFromBn(FiniteField* ff, BigNum* bn, in InitFfElementFromBn() argument
654 if (!ff || !bn || !ff_elem) { in InitFfElementFromBn()
657 if (!ff_elem->ipp_ff_elem || !ff->ipp_ff) { in InitFfElementFromBn()
660 if (ff->basic_degree != 1 || ff->ground_degree != 1) { in InitFfElementFromBn()
663 if (ff->element_len != ff_elem->element_len) { in InitFfElementFromBn()
667 size_t elem_size = ff->element_len * sizeof(Ipp32u); in InitFfElementFromBn()
672 result = GetFiniteFieldPrime(ff, &prime_bn); in InitFfElementFromBn()
690 result = ReadFfElement(ff, mod_str, elem_size, ff_elem); in InitFfElementFromBn()
702 EpidStatus WriteFfElement(FiniteField* ff, FfElement const* ff_elem, in WriteFfElement() argument
709 if (!ff || !ff_elem_str || !ff_elem) { in WriteFfElement()
712 if (!ff_elem->ipp_ff_elem || !ff->ipp_ff) { in WriteFfElement()
718 if (ff->element_len != ff_elem->element_len) { in WriteFfElement()
722 strlen_required = ff->element_strlen_required; in WriteFfElement()
726 if (1 == ff->basic_degree && strlen_required < strlen) { in WriteFfElement()
738 ff->ipp_ff); in WriteFfElement()
750 EpidStatus FfNeg(FiniteField* ff, FfElement const* a, FfElement* r) { in FfNeg() argument
752 if (!ff || !a || !r) { in FfNeg()
754 } else if (!ff->ipp_ff || !a->ipp_ff_elem || !r->ipp_ff_elem) { in FfNeg()
757 if (ff->element_len != a->element_len || ff->element_len != r->element_len) { in FfNeg()
760 sts = ippsGFpNeg(a->ipp_ff_elem, r->ipp_ff_elem, ff->ipp_ff); in FfNeg()
771 EpidStatus FfInv(FiniteField* ff, FfElement const* a, FfElement* r) { in FfInv() argument
774 if (!ff || !a || !r) { in FfInv()
776 } else if (!ff->ipp_ff || !a->ipp_ff_elem || !r->ipp_ff_elem) { in FfInv()
779 if (ff->element_len != a->element_len || ff->element_len != r->element_len) { in FfInv()
783 sts = ippsGFpInv(a->ipp_ff_elem, r->ipp_ff_elem, ff->ipp_ff); in FfInv()
796 EpidStatus FfAdd(FiniteField* ff, FfElement const* a, FfElement const* b, in FfAdd() argument
799 if (!ff || !a || !b || !r) { in FfAdd()
801 } else if (!ff->ipp_ff || !a->ipp_ff_elem || !b->ipp_ff_elem || in FfAdd()
805 if (ff->element_len != a->element_len || ff->element_len != b->element_len || in FfAdd()
806 ff->element_len != r->element_len) { in FfAdd()
810 sts = ippsGFpAdd(a->ipp_ff_elem, b->ipp_ff_elem, r->ipp_ff_elem, ff->ipp_ff); in FfAdd()
819 EpidStatus FfSub(FiniteField* ff, FfElement const* a, FfElement const* b, in FfSub() argument
822 if (!ff || !a || !b || !r) { in FfSub()
824 } else if (!ff->ipp_ff || !a->ipp_ff_elem || !b->ipp_ff_elem || in FfSub()
829 if (ff->element_len != a->element_len || ff->element_len != b->element_len || in FfSub()
830 ff->element_len != r->element_len) { in FfSub()
834 sts = ippsGFpSub(a->ipp_ff_elem, b->ipp_ff_elem, r->ipp_ff_elem, ff->ipp_ff); in FfSub()
843 EpidStatus FfMul(FiniteField* ff, FfElement const* a, FfElement const* b, in FfMul() argument
847 if (!ff || !a || !b || !r) { in FfMul()
849 } else if (!ff->ipp_ff || !a->ipp_ff_elem || !b->ipp_ff_elem || in FfMul()
857 ff->ipp_ff); in FfMul()
859 if (ff->element_len != a->element_len || in FfMul()
860 ff->element_len != b->element_len || in FfMul()
861 ff->element_len != r->element_len) { in FfMul()
865 ippsGFpMul(a->ipp_ff_elem, b->ipp_ff_elem, r->ipp_ff_elem, ff->ipp_ff); in FfMul()
877 EpidStatus FfIsZero(FiniteField* ff, FfElement const* a, bool* is_zero) { in FfIsZero() argument
881 if (!ff || !a || !is_zero) { in FfIsZero()
883 } else if (!ff->ipp_ff || !a->ipp_ff_elem) { in FfIsZero()
886 if (ff->element_len != a->element_len) { in FfIsZero()
890 sts = ippsGFpIsZeroElement(a->ipp_ff_elem, &ipp_result, ff->ipp_ff); in FfIsZero()
906 EpidStatus FfExp(FiniteField* ff, FfElement const* a, BigNum const* b, in FfExp() argument
916 if (!ff || !a || !b || !r) { in FfExp()
919 } else if (!ff->ipp_ff || !a->ipp_ff_elem || !r->ipp_ff_elem) { in FfExp()
923 if (ff->element_len != a->element_len || in FfExp()
924 ff->element_len != r->element_len) { in FfExp()
934 sts = ippsGFpScratchBufferSize(1, exp_bit_size, ff->ipp_ff, &element_size); in FfExp()
946 sts = ippsGFpExp(a->ipp_ff_elem, b->ipp_bn, r->ipp_ff_elem, ff->ipp_ff, in FfExp()
962 EpidStatus FfMultiExp(FiniteField* ff, FfElement const** p, BigNumStr const** b, in FfMultiExp() argument
973 if (!ff || !p || !b || !r) { in FfMultiExp()
975 } else if (!ff->ipp_ff || !r->ipp_ff_elem || m <= 0) { in FfMultiExp()
993 if (ff->element_len != p[i]->element_len) { in FfMultiExp()
997 if (ff->element_len != r->element_len) { in FfMultiExp()
1039 sts = ippsGFpScratchBufferSize(ipp_m, exp_bit_size, ff->ipp_ff, in FfMultiExp()
1054 r->ipp_ff_elem, ff->ipp_ff, scratch_buffer); in FfMultiExp()
1076 EpidStatus FfMultiExpBn(FiniteField* ff, FfElement const** p, BigNum const** b, in FfMultiExpBn() argument
1089 if (!ff || !p || !b || !r) { in FfMultiExpBn()
1091 } else if (!ff->ipp_ff || !r->ipp_ff_elem || m <= 0) { in FfMultiExpBn()
1093 } else if (ff->element_len != r->element_len) { in FfMultiExpBn()
1108 if (ff->element_len != p[i]->element_len) { in FfMultiExpBn()
1145 sts = ippsGFpScratchBufferSize(ipp_m, exp_bit_size, ff->ipp_ff, in FfMultiExpBn()
1160 r->ipp_ff_elem, ff->ipp_ff, scratch_buffer); in FfMultiExpBn()
1178 EpidStatus FfSscmMultiExp(FiniteField* ff, FfElement const** p, in FfSscmMultiExp() argument
1182 return FfMultiExp(ff, p, b, m, r); in FfSscmMultiExp()
1185 EpidStatus FfIsEqual(FiniteField* ff, FfElement const* a, FfElement const* b, in FfIsEqual() argument
1190 if (!ff || !a || !b || !is_equal) { in FfIsEqual()
1193 if (!ff->ipp_ff || !a->ipp_ff_elem || !b->ipp_ff_elem) { in FfIsEqual()
1196 if (ff->element_len != a->element_len || ff->element_len != b->element_len) { in FfIsEqual()
1200 sts = ippsGFpCmpElement(a->ipp_ff_elem, b->ipp_ff_elem, &result, ff->ipp_ff); in FfIsEqual()
1213 EpidStatus FfHash(FiniteField* ff, ConstOctStr msg, size_t msg_len, in FfHash() argument
1220 if (!ff || !msg || !r) { in FfHash()
1223 } else if (!ff->ipp_ff || !r->ipp_ff_elem || msg_len <= 0) { in FfHash()
1248 if (ff->element_len != r->element_len) { in FfHash()
1251 sts = ippsGFpSetElementHash(msg, ipp_msg_len, r->ipp_ff_elem, ff->ipp_ff, in FfHash()
1268 EpidStatus FfGetRandom(FiniteField* ff, BigNumStr const* low_bound, in FfGetRandom() argument
1275 if (!ff || !low_bound || !rnd_func || !r) { in FfGetRandom()
1279 if (!ff->ipp_ff || !r->ipp_ff_elem) { in FfGetRandom()
1283 if (ff->element_len != r->element_len) { in FfGetRandom()
1287 result = NewFfElement(ff, &low); in FfGetRandom()
1291 result = ReadFfElement(ff, low_bound, sizeof(*low_bound), low); in FfGetRandom()
1297 sts = ippsGFpSetElementRandom(r->ipp_ff_elem, ff->ipp_ff, in FfGetRandom()
1304 ff->ipp_ff); in FfGetRandom()
1323 EpidStatus FfSqrt(FiniteField* ff, FfElement const* a, FfElement* r) { in FfSqrt() argument
1347 if (!ff || !a || !r) { in FfSqrt()
1360 result = GetFiniteFieldPrime(ff, &prime); in FfSqrt()
1372 result = NewFfElement(ff, &qm1_ffe); in FfSqrt()
1388 result = NewFfElement(ff, &g); in FfSqrt()
1392 result = NewFfElement(ff, &gg); in FfSqrt()
1412 result = NewFfElement(ff, &ge); in FfSqrt()
1416 result = NewFfElement(ff, &h); in FfSqrt()
1420 result = NewFfElement(ff, &temp); in FfSqrt()
1424 result = NewFfElement(ff, &one_ffe); in FfSqrt()
1432 result = NewFfElement(ff, &ged2); in FfSqrt()
1440 result = NewFfElement(ff, >p1d2); in FfSqrt()
1444 result = NewFfElement(ff, &dd); in FfSqrt()
1460 result = InitFfElementFromBn(ff, one, one_ffe); in FfSqrt()
1468 result = InitFfElementFromBn(ff, qm1, qm1_ffe); in FfSqrt()
1478 result = ReadFfElement(ff, &one_str, sizeof(one_str), g); in FfSqrt()
1485 result = FfAdd(ff, g, one_ffe, g); in FfSqrt()
1491 result = FfExp(ff, g, qm1d2, gg); in FfSqrt()
1496 result = FfIsEqual(ff, gg, qm1_ffe, &is_equal); in FfSqrt()
1551 result = FfExp(ff, g, e, ge); in FfSqrt()
1556 result = FfInv(ff, ge, ge); in FfSqrt()
1560 result = FfMul(ff, a, ge, h); in FfSqrt()
1564 result = FfExp(ff, h, qm1dj, temp); in FfSqrt()
1568 result = FfIsEqual(ff, temp, one_ffe, &is_equal); in FfSqrt()
1582 result = FfExp(ff, g, e, ge); in FfSqrt()
1586 result = FfInv(ff, ge, ge); in FfSqrt()
1590 result = FfMul(ff, a, ge, h); in FfSqrt()
1600 result = FfExp(ff, g, ed2, ged2); in FfSqrt()
1612 result = FfExp(ff, h, tp1d2, gtp1d2); in FfSqrt()
1616 result = FfMul(ff, ged2, gtp1d2, r); in FfSqrt()
1622 result = FfMul(ff, r, r, dd); in FfSqrt()
1626 result = FfIsEqual(ff, dd, a, &is_equal); in FfSqrt()