Lines Matching refs:context
107 BN_CTX *context // IN: working context in Point2B() argument
112 BN_CTX_start(context); in Point2B()
113 bnX = BN_CTX_get(context); in Point2B()
114 bnY = BN_CTX_get(context); in Point2B()
117 || EC_POINT_get_affine_coordinates_GFp(group, ecP, bnX, bnY, context) != 1 in Point2B()
124 BN_CTX_end(context); in Point2B()
150 BN_CTX *context; in EccCurveInit() local
161 context = BN_CTX_new(); in EccCurveInit()
162 if(context == NULL) in EccCurveInit()
164 BN_CTX_start(context); in EccCurveInit()
165 bnP = BN_CTX_get(context); in EccCurveInit()
166 bnA = BN_CTX_get(context); in EccCurveInit()
167 bnB = BN_CTX_get(context); in EccCurveInit()
168 bnX = BN_CTX_get(context); in EccCurveInit()
169 bnY = BN_CTX_get(context); in EccCurveInit()
170 bnN = BN_CTX_get(context); in EccCurveInit()
171 bnH = BN_CTX_get(context); in EccCurveInit()
197 BN_CTX_end(context); in EccCurveInit()
198 BN_CTX_free(context); in EccCurveInit()
212 BN_CTX *context // IN: the BIGNUM context in PointFrom2B() argument
220 BN_CTX_start(context); in PointFrom2B()
221 bnX = BN_CTX_get(context); in PointFrom2B()
222 bnY = BN_CTX_get(context); in PointFrom2B()
227 || !EC_POINT_set_affine_coordinates_GFp(group, ecP, bnX, bnY, context) in PointFrom2B()
230 BN_CTX_end(context); in PointFrom2B()
244 BN_CTX *context // IN: the BIGNUM context in EccInitPoint2B() argument
248 BN_CTX_start(context); in EccInitPoint2B()
250 if(PointFrom2B(group, ecP, p, context) == NULL) in EccInitPoint2B()
252 BN_CTX_end(context); in EccInitPoint2B()
273 BN_CTX *context // IN: working context in PointMul() argument
276 if(EC_POINT_mul(group, ecpQ, bnA, ecpP, bnB, context) != 1) in PointMul()
351 BN_CTX *context; in _cpri__EccPointMultiply() local
363 context = BN_CTX_new(); in _cpri__EccPointMultiply()
364 if(context == NULL) in _cpri__EccPointMultiply()
366 BN_CTX_start(context); in _cpri__EccPointMultiply()
367 bnU = BN_CTX_get(context); in _cpri__EccPointMultiply()
368 bnD = BN_CTX_get(context); in _cpri__EccPointMultiply()
369 group = EccCurveInit(curveId, context); in _cpri__EccPointMultiply()
383 Q = EccInitPoint2B(group, Qin, context); in _cpri__EccPointMultiply()
413 if((retVal = PointMul(group, R, bnD, Q, bnU, context)) == CRYPT_SUCCESS) in _cpri__EccPointMultiply()
414 Point2B(group, Rout, R, (INT16) ((EC_GROUP_get_degree(group)+7)/8), context); in _cpri__EccPointMultiply()
421 BN_CTX_end(context); in _cpri__EccPointMultiply()
422 BN_CTX_free(context); in _cpri__EccPointMultiply()
473 BN_CTX *context; in _cpri__EccCommitCompute() local
484 context = BN_CTX_new(); in _cpri__EccCommitCompute()
485 if(context == NULL) in _cpri__EccCommitCompute()
487 BN_CTX_start(context); in _cpri__EccCommitCompute()
488 bnR = BN_CTX_get(context); in _cpri__EccCommitCompute()
489 bnD = BN_CTX_get(context); in _cpri__EccCommitCompute()
490 bnY = BN_CTX_get(context); in _cpri__EccCommitCompute()
497 if((group = EccCurveInit(curveId, context)) == NULL) in _cpri__EccCommitCompute()
517 pB = EccInitPoint2B(group, B, context); in _cpri__EccCommitCompute()
519 if((retVal = PointMul(group, pK, NULL, pB, bnD, context)) != CRYPT_SUCCESS) in _cpri__EccCommitCompute()
522 Point2B(group, K, pK, (INT16)keySizeInBytes, context); in _cpri__EccCommitCompute()
530 if((retVal = PointMul(group, pL, NULL, pB, bnR, context)) != CRYPT_SUCCESS) in _cpri__EccCommitCompute()
533 Point2B(group, L, pL, (INT16)keySizeInBytes, context); in _cpri__EccCommitCompute()
550 pM = EccInitPoint2B(group, M, context); in _cpri__EccCommitCompute()
551 retVal = PointMul(group, pE, NULL, pM, bnR, context); in _cpri__EccCommitCompute()
555 retVal = PointMul(group, pE, bnR, NULL, NULL, context); in _cpri__EccCommitCompute()
558 Point2B(group, E, pE, (INT16)keySizeInBytes, context); in _cpri__EccCommitCompute()
568 BN_CTX_end(context); in _cpri__EccCommitCompute()
569 BN_CTX_free(context); in _cpri__EccCommitCompute()
592 BN_CTX *context; in _cpri__EccIsPointOnCurve() local
602 if((context = BN_CTX_new()) == NULL) in _cpri__EccIsPointOnCurve()
604 BN_CTX_start(context); in _cpri__EccIsPointOnCurve()
605 bnX = BN_CTX_get(context); in _cpri__EccIsPointOnCurve()
606 bnY = BN_CTX_get(context); in _cpri__EccIsPointOnCurve()
607 bnA = BN_CTX_get(context); in _cpri__EccIsPointOnCurve()
608 bnB = BN_CTX_get(context); in _cpri__EccIsPointOnCurve()
609 bn3 = BN_CTX_get(context); in _cpri__EccIsPointOnCurve()
610 bnP = BN_CTX_get(context); in _cpri__EccIsPointOnCurve()
625 if( !BN_mod_mul(bnA, bnA, bnX, bnP, context) in _cpri__EccIsPointOnCurve()
628 || !BN_mod_add(bnA, bnA, bnB, bnP, context) in _cpri__EccIsPointOnCurve()
630 || !BN_mod_exp(bnX, bnX, bn3, bnP, context) in _cpri__EccIsPointOnCurve()
632 || !BN_mod_add(bnX, bnX, bnA, bnP, context) in _cpri__EccIsPointOnCurve()
634 || !BN_mod_mul(bnY, bnY, bnY, bnP, context) in _cpri__EccIsPointOnCurve()
638 BN_CTX_end(context); in _cpri__EccIsPointOnCurve()
639 BN_CTX_free(context); in _cpri__EccIsPointOnCurve()
683 BN_CTX *context; // the context for the BIGNUM values in _cpri__GenerateKeyEcc() local
694 context = BN_CTX_new(); in _cpri__GenerateKeyEcc()
695 if(context == NULL) in _cpri__GenerateKeyEcc()
697 BN_CTX_start(context); in _cpri__GenerateKeyEcc()
698 bnNm1 = BN_CTX_get(context); in _cpri__GenerateKeyEcc()
699 bnD = BN_CTX_get(context); in _cpri__GenerateKeyEcc()
727 || BN_mod(bnD, bnD, bnNm1, context) != 1) in _cpri__GenerateKeyEcc()
743 BN_CTX_end(context); in _cpri__GenerateKeyEcc()
744 BN_CTX_free(context); in _cpri__GenerateKeyEcc()
807 BN_CTX *context; in SignEcdsa() local
811 context = BN_CTX_new(); in SignEcdsa()
812 if(context == NULL) in SignEcdsa()
814 BN_CTX_start(context); in SignEcdsa()
815 bnN = BN_CTX_get(context); in SignEcdsa()
816 bnZ = BN_CTX_get(context); in SignEcdsa()
817 bnR = BN_CTX_get(context); in SignEcdsa()
818 bnD = BN_CTX_get(context); in SignEcdsa()
819 bnIk = BN_CTX_get(context); in SignEcdsa()
820 bnK = BN_CTX_get(context); in SignEcdsa()
862 BN_mod(bnR, bnR, bnN, context); in SignEcdsa()
871 if( BN_mod_inverse(bnIk, bnK, bnN, context) != NULL) in SignEcdsa()
907 if( !BN_mod_mul(bnD, bnR, bnD, bnN, context) in SignEcdsa()
911 || !BN_mod_mul(bnD, bnIk, bnD, bnN, context) in SignEcdsa()
924 BN_CTX_end(context); in SignEcdsa()
925 BN_CTX_free(context); in SignEcdsa()
956 BN_CTX *context; in EcDaa() local
975 context = BN_CTX_new(); in EcDaa()
976 if(context == NULL) in EcDaa()
978 BN_CTX_start(context); in EcDaa()
979 bnN = BN_CTX_get(context); in EcDaa()
980 bnK = BN_CTX_get(context); in EcDaa()
981 bnT = BN_CTX_get(context); in EcDaa()
982 bnD = BN_CTX_get(context); in EcDaa()
993 OK = OK && BN_mod(bnT, bnT, bnN, context); in EcDaa()
996 OK = OK && BN_mod_mul(bnD, bnT, bnD, bnN, context) == 1; in EcDaa()
998 OK = OK && BN_mod_add(bnD, bnK, bnD, bnN, context) == 1; in EcDaa()
1006 BN_CTX_end(context); in EcDaa()
1007 BN_CTX_free(context); in EcDaa()
1071 BN_CTX *context; in SchnorrEcc() local
1097 context = BN_CTX_new(); in SchnorrEcc()
1098 if(context == NULL) in SchnorrEcc()
1100 BN_CTX_start(context); in SchnorrEcc()
1101 bnR = BN_CTX_get(context); in SchnorrEcc()
1102 bnN = BN_CTX_get(context); in SchnorrEcc()
1103 bnK = BN_CTX_get(context); in SchnorrEcc()
1104 bnT = BN_CTX_get(context); in SchnorrEcc()
1105 bnD = BN_CTX_get(context); in SchnorrEcc()
1108 || (group = EccCurveInit(curveId, context)) == NULL in SchnorrEcc()
1129 if(PointMul(group, pR, bnK, NULL, NULL, context) == CRYPT_NO_RESULT) in SchnorrEcc()
1134 EC_POINT_get_affine_coordinates_GFp(group, pR, bnR, NULL, context); in SchnorrEcc()
1136 BN_mod(bnR, bnR, bnN, context); in SchnorrEcc()
1150 BN_div(NULL, bnT, bnT, bnN, context); in SchnorrEcc()
1159 BN_CTX_end(context); in SchnorrEcc()
1160 BN_CTX_free(context); in SchnorrEcc()
1248 BN_CTX *context; in SignSM2() local
1253 context = BN_CTX_new(); in SignSM2()
1254 BN_CTX_start(context); in SignSM2()
1255 bnK = BN_CTX_get(context); in SignSM2()
1256 bnR = BN_CTX_get(context); in SignSM2()
1257 bnS = BN_CTX_get(context); in SignSM2()
1258 bnX1 = BN_CTX_get(context); in SignSM2()
1259 bnN = BN_CTX_get(context); in SignSM2()
1260 bnD = BN_CTX_get(context); in SignSM2()
1261 bnT = BN_CTX_get(context); in SignSM2()
1262 bnE = BN_CTX_get(context); in SignSM2()
1297 if(!BN_mod_add(bnR, bnE, bnX1, bnN, context)) in SignSM2()
1313 || !BN_mod_inverse(bnT, bnT, bnN, context) // (1 + dA)^-1 mod n in SignSM2()
1322 if( !BN_mod_mul(bnS, bnD, bnR, bnN, context) // (r * dA) mod n in SignSM2()
1323 || !BN_mod_sub(bnS, bnK, bnS, bnN, context) // (k - (r * dA) mod n in SignSM2()
1324 || !BN_mod_mul(bnS, bnT, bnS, bnN, context))// t * (k - (r * dA) mod n in SignSM2()
1346 BN_CTX_end(context); in SignSM2()
1347 BN_CTX_free(context); in SignSM2()
1428 BN_CTX *context; in ValidateSignatureEcdsa() local
1454 context = BN_CTX_new(); in ValidateSignatureEcdsa()
1455 if(context == NULL) in ValidateSignatureEcdsa()
1457 BN_CTX_start(context); in ValidateSignatureEcdsa()
1458 bnR = BN_CTX_get(context); in ValidateSignatureEcdsa()
1459 bnS = BN_CTX_get(context); in ValidateSignatureEcdsa()
1460 bnN = BN_CTX_get(context); in ValidateSignatureEcdsa()
1461 bnE = BN_CTX_get(context); in ValidateSignatureEcdsa()
1462 bnV = BN_CTX_get(context); in ValidateSignatureEcdsa()
1463 bnW = BN_CTX_get(context); in ValidateSignatureEcdsa()
1464 bnQx = BN_CTX_get(context); in ValidateSignatureEcdsa()
1465 bnQy = BN_CTX_get(context); in ValidateSignatureEcdsa()
1466 bnU1 = BN_CTX_get(context); in ValidateSignatureEcdsa()
1467 bnU2 = BN_CTX_get(context); in ValidateSignatureEcdsa()
1477 || (group = EccCurveInit(curveId, context)) == NULL in ValidateSignatureEcdsa()
1483 || !EC_POINT_set_affine_coordinates_GFp(group, pQ, bnQx, bnQy, context) in ValidateSignatureEcdsa()
1497 if (BN_mod_inverse(bnW, bnS, bnN, context) == NULL) in ValidateSignatureEcdsa()
1500 if( !BN_mod_mul(bnU1, bnE, bnW, bnN, context) in ValidateSignatureEcdsa()
1501 || !BN_mod_mul(bnU2, bnR, bnW, bnN, context)) in ValidateSignatureEcdsa()
1512 || !BN_mod(bnV, bnV, bnN, context)) in ValidateSignatureEcdsa()
1520 BN_CTX_end(context); in ValidateSignatureEcdsa()
1521 BN_CTX_free(context); in ValidateSignatureEcdsa()
1627 BN_CTX *context; in ValidateSignatureSM2Dsa() local
1632 if((context = BN_CTX_new()) == NULL || curveData == NULL) in ValidateSignatureSM2Dsa()
1634 bnR = BN_CTX_get(context); in ValidateSignatureSM2Dsa()
1635 bnRp= BN_CTX_get(context); in ValidateSignatureSM2Dsa()
1636 bnE = BN_CTX_get(context); in ValidateSignatureSM2Dsa()
1637 bnT = BN_CTX_get(context); in ValidateSignatureSM2Dsa()
1638 bnS = BN_CTX_get(context); in ValidateSignatureSM2Dsa()
1639 order = BN_CTX_get(context); in ValidateSignatureSM2Dsa()
1641 || (group = EccCurveInit(curveId, context)) == NULL) in ValidateSignatureSM2Dsa()
1651 pQ = EccInitPoint2B(group, Qin, context); in ValidateSignatureSM2Dsa()
1653 pAssert(EC_POINT_get_affine_coordinates_GFp(group, pQ, bnT, bnS, context)); in ValidateSignatureSM2Dsa()
1672 if (!EC_GROUP_get_order(group, order, context)) goto Cleanup; in ValidateSignatureSM2Dsa()
1681 if(!BN_mod_add(bnT, bnR, bnS, order, context)) in ValidateSignatureSM2Dsa()
1696 if(!EC_POINT_mul(group, pQ, bnS, pQ, bnT, context)) in ValidateSignatureSM2Dsa()
1699 if(!EC_POINT_get_affine_coordinates_GFp(group, pQ, bnT, NULL, context)) in ValidateSignatureSM2Dsa()
1707 if(!BN_mod_add(bnRp, bnE, bnT, order, context)) in ValidateSignatureSM2Dsa()
1714 BN_CTX_end(context); in ValidateSignatureSM2Dsa()
1715 BN_CTX_free(context); in ValidateSignatureSM2Dsa()
1824 BN_CTX *context; in C_2_2_MQV() local
1840 context = BN_CTX_new(); in C_2_2_MQV()
1841 if(context == NULL || curveData == NULL) in C_2_2_MQV()
1843 BN_CTX_start(context); in C_2_2_MQV()
1844 bnTa = BN_CTX_get(context); in C_2_2_MQV()
1845 bnDeA = BN_CTX_get(context); in C_2_2_MQV()
1846 bnDsA = BN_CTX_get(context); in C_2_2_MQV()
1847 bnXeA = BN_CTX_get(context); in C_2_2_MQV()
1848 bnH = BN_CTX_get(context); in C_2_2_MQV()
1849 bnN = BN_CTX_get(context); in C_2_2_MQV()
1850 bnXeB = BN_CTX_get(context); in C_2_2_MQV()
1859 if((group = EccCurveInit(curveId, context)) == NULL) in C_2_2_MQV()
1868 pQeB = EccInitPoint2B(group, QeB, context); in C_2_2_MQV()
1869 pQsB = EccInitPoint2B(group, QsB, context); in C_2_2_MQV()
1871 if( (retVal = PointMul(group, pQeA, bnDeA, NULL, NULL, context)) in C_2_2_MQV()
1874 if(EC_POINT_get_affine_coordinates_GFp(group, pQeA, bnXeA, NULL, context) != 1) in C_2_2_MQV()
1883 !BN_mod_mul(bnTa, bnDsA, bnTa, bnN, context) in C_2_2_MQV()
1885 || !BN_mod_add(bnTa, bnDeA, bnTa, bnN, context) in C_2_2_MQV()
1894 if(!BN_mul(bnTa, bnTa, bnH, context)) in C_2_2_MQV()
1902 if( !EC_POINT_mul(group, pQsB, NULL, pQsB, bnXeB, context) in C_2_2_MQV()
1904 || !EC_POINT_add(group, pQeB, pQeB, pQsB, context) in C_2_2_MQV()
1908 if(PointMul(group, pQeB, NULL, pQeB, bnTa, context) == CRYPT_SUCCESS) in C_2_2_MQV()
1910 Point2B(group, outZ, pQeB, (INT16)BN_num_bytes(bnN), context); in C_2_2_MQV()
1916 BN_CTX_end(context); in C_2_2_MQV()
1917 BN_CTX_free(context); in C_2_2_MQV()
1969 BN_CTX *context; in SM2KeyExchange() local
1986 context = BN_CTX_new(); in SM2KeyExchange()
1987 if(context == NULL || curveData == NULL) in SM2KeyExchange()
1989 BN_CTX_start(context); in SM2KeyExchange()
1990 bnTa = BN_CTX_get(context); in SM2KeyExchange()
1991 bnDeA = BN_CTX_get(context); in SM2KeyExchange()
1992 bnDsA = BN_CTX_get(context); in SM2KeyExchange()
1993 bnXeA = BN_CTX_get(context); in SM2KeyExchange()
1994 bnH = BN_CTX_get(context); in SM2KeyExchange()
1995 bnN = BN_CTX_get(context); in SM2KeyExchange()
1996 bnXeB = BN_CTX_get(context); in SM2KeyExchange()
2000 if((group = EccCurveInit(curveId, context)) == NULL) in SM2KeyExchange()
2009 pQeB = EccInitPoint2B(group, QeB, context); in SM2KeyExchange()
2010 pQsB = EccInitPoint2B(group, QsB, context); in SM2KeyExchange()
2012 if( (retVal = PointMul(group, pQeA, bnDeA, NULL, NULL, context)) in SM2KeyExchange()
2015 if(EC_POINT_get_affine_coordinates_GFp(group, pQeA, bnXeA, NULL, context) != 1) in SM2KeyExchange()
2023 !BN_mod_mul(bnTa, bnDeA, bnTa, bnN, context) in SM2KeyExchange()
2025 || !BN_mod_add(bnTa, bnDsA, bnTa, bnN, context) in SM2KeyExchange()
2034 if(!BN_mul(bnTa, bnTa, bnH, context)) in SM2KeyExchange()
2042 if( !EC_POINT_mul(group, pQeB, NULL, pQeB, bnXeB, context) in SM2KeyExchange()
2044 || !EC_POINT_add(group, pQeB, pQeB, pQsB, context) in SM2KeyExchange()
2048 if(PointMul(group, pQeB, NULL, pQeB, bnTa, context) == CRYPT_SUCCESS) in SM2KeyExchange()
2050 Point2B(group, outZ, pQeB, (INT16)BN_num_bytes(bnN), context); in SM2KeyExchange()
2056 BN_CTX_end(context); in SM2KeyExchange()
2057 BN_CTX_free(context); in SM2KeyExchange()
2080 BN_CTX *context; in C_2_2_ECDH() local
2086 context = BN_CTX_new(); in C_2_2_ECDH()
2087 if(context == NULL || curveData == NULL) in C_2_2_ECDH()
2089 BN_CTX_start(context); in C_2_2_ECDH()
2090 order = BN_CTX_get(context); in C_2_2_ECDH()
2091 if((bnD = BN_CTX_get(context)) == NULL) in C_2_2_ECDH()
2094 if((group = EccCurveInit(curveId, context)) == NULL) in C_2_2_ECDH()
2096 if (!EC_GROUP_get_order(group, order, context)) in C_2_2_ECDH()
2102 pQ = EccInitPoint2B(group, QsB, context); in C_2_2_ECDH()
2104 if(PointMul(group, pQ, NULL, pQ, bnD, context) != CRYPT_NO_RESULT) in C_2_2_ECDH()
2106 Point2B(group, outZ1, pQ, size, context); in C_2_2_ECDH()
2110 PointFrom2B(group, pQ, QeB, context); in C_2_2_ECDH()
2112 if(PointMul(group, pQ, NULL, pQ, bnD, context) != CRYPT_NO_RESULT) in C_2_2_ECDH()
2114 Point2B(group, outZ2, pQ, size, context); in C_2_2_ECDH()
2117 BN_CTX_end(context); in C_2_2_ECDH()
2118 BN_CTX_free(context); in C_2_2_ECDH()