Lines Matching refs:key

493 static int ec_key_public_range_check(BN_CTX *ctx, const EC_KEY *key)  in ec_key_public_range_check()  argument
504 if (!EC_POINT_get_affine_coordinates(key->group, key->pub_key, x, y, ctx)) in ec_key_public_range_check()
507 if (EC_GROUP_get_field_type(key->group) == NID_X9_62_prime_field) { in ec_key_public_range_check()
509 || BN_cmp(x, key->group->field) >= 0 in ec_key_public_range_check()
511 || BN_cmp(y, key->group->field) >= 0) { in ec_key_public_range_check()
515 int m = EC_GROUP_get_degree(key->group); in ec_key_public_range_check()
693 int EC_KEY_set_public_key_affine_coordinates(EC_KEY *key, BIGNUM *x, in EC_KEY_set_public_key_affine_coordinates() argument
701 if (key == NULL || key->group == NULL || x == NULL || y == NULL) { in EC_KEY_set_public_key_affine_coordinates()
705 ctx = BN_CTX_new_ex(key->libctx); in EC_KEY_set_public_key_affine_coordinates()
710 point = EC_POINT_new(key->group); in EC_KEY_set_public_key_affine_coordinates()
720 if (!EC_POINT_set_affine_coordinates(key->group, point, x, y, ctx)) in EC_KEY_set_public_key_affine_coordinates()
722 if (!EC_POINT_get_affine_coordinates(key->group, point, tx, ty, ctx)) in EC_KEY_set_public_key_affine_coordinates()
735 if (!EC_KEY_set_public_key(key, point)) in EC_KEY_set_public_key_affine_coordinates()
738 if (EC_KEY_check_key(key) == 0) in EC_KEY_set_public_key_affine_coordinates()
751 OSSL_LIB_CTX *ossl_ec_key_get_libctx(const EC_KEY *key) in ossl_ec_key_get_libctx() argument
753 return key->libctx; in ossl_ec_key_get_libctx()
756 const char *ossl_ec_key_get0_propq(const EC_KEY *key) in ossl_ec_key_get0_propq() argument
758 return key->propq; in ossl_ec_key_get0_propq()
761 void ossl_ec_key_set0_libctx(EC_KEY *key, OSSL_LIB_CTX *libctx) in ossl_ec_key_set0_libctx() argument
763 key->libctx = libctx; in ossl_ec_key_set0_libctx()
767 const EC_GROUP *EC_KEY_get0_group(const EC_KEY *key) in EC_KEY_get0_group() argument
769 return key->group; in EC_KEY_get0_group()
772 int EC_KEY_set_group(EC_KEY *key, const EC_GROUP *group) in EC_KEY_set_group() argument
774 if (key->meth->set_group != NULL && key->meth->set_group(key, group) == 0) in EC_KEY_set_group()
776 EC_GROUP_free(key->group); in EC_KEY_set_group()
777 key->group = EC_GROUP_dup(group); in EC_KEY_set_group()
778 if (key->group != NULL && EC_GROUP_get_curve_name(key->group) == NID_sm2) in EC_KEY_set_group()
779 EC_KEY_set_flags(key, EC_FLAG_SM2_RANGE); in EC_KEY_set_group()
781 key->dirty_cnt++; in EC_KEY_set_group()
782 return (key->group == NULL) ? 0 : 1; in EC_KEY_set_group()
785 const BIGNUM *EC_KEY_get0_private_key(const EC_KEY *key) in EC_KEY_get0_private_key() argument
787 return key->priv_key; in EC_KEY_get0_private_key()
790 int EC_KEY_set_private_key(EC_KEY *key, const BIGNUM *priv_key) in EC_KEY_set_private_key() argument
796 if (key->group == NULL || key->group->meth == NULL) in EC_KEY_set_private_key()
807 order = EC_GROUP_get0_order(key->group); in EC_KEY_set_private_key()
811 if (key->group->meth->set_private != NULL in EC_KEY_set_private_key()
812 && key->group->meth->set_private(key, priv_key) == 0) in EC_KEY_set_private_key()
814 if (key->meth->set_private != NULL in EC_KEY_set_private_key()
815 && key->meth->set_private(key, priv_key) == 0) in EC_KEY_set_private_key()
823 BN_clear_free(key->priv_key); in EC_KEY_set_private_key()
824 key->priv_key = NULL; in EC_KEY_set_private_key()
878 BN_clear_free(key->priv_key); in EC_KEY_set_private_key()
879 key->priv_key = tmp_key; in EC_KEY_set_private_key()
880 key->dirty_cnt++; in EC_KEY_set_private_key()
885 const EC_POINT *EC_KEY_get0_public_key(const EC_KEY *key) in EC_KEY_get0_public_key() argument
887 return key->pub_key; in EC_KEY_get0_public_key()
890 int EC_KEY_set_public_key(EC_KEY *key, const EC_POINT *pub_key) in EC_KEY_set_public_key() argument
892 if (key->meth->set_public != NULL in EC_KEY_set_public_key()
893 && key->meth->set_public(key, pub_key) == 0) in EC_KEY_set_public_key()
895 EC_POINT_free(key->pub_key); in EC_KEY_set_public_key()
896 key->pub_key = EC_POINT_dup(pub_key, key->group); in EC_KEY_set_public_key()
897 key->dirty_cnt++; in EC_KEY_set_public_key()
898 return (key->pub_key == NULL) ? 0 : 1; in EC_KEY_set_public_key()
901 unsigned int EC_KEY_get_enc_flags(const EC_KEY *key) in EC_KEY_get_enc_flags() argument
903 return key->enc_flag; in EC_KEY_get_enc_flags()
906 void EC_KEY_set_enc_flags(EC_KEY *key, unsigned int flags) in EC_KEY_set_enc_flags() argument
908 key->enc_flag = flags; in EC_KEY_set_enc_flags()
911 point_conversion_form_t EC_KEY_get_conv_form(const EC_KEY *key) in EC_KEY_get_conv_form() argument
913 return key->conv_form; in EC_KEY_get_conv_form()
916 void EC_KEY_set_conv_form(EC_KEY *key, point_conversion_form_t cform) in EC_KEY_set_conv_form() argument
918 key->conv_form = cform; in EC_KEY_set_conv_form()
919 if (key->group != NULL) in EC_KEY_set_conv_form()
920 EC_GROUP_set_point_conversion_form(key->group, cform); in EC_KEY_set_conv_form()
923 void EC_KEY_set_asn1_flag(EC_KEY *key, int flag) in EC_KEY_set_asn1_flag() argument
925 if (key->group != NULL) in EC_KEY_set_asn1_flag()
926 EC_GROUP_set_asn1_flag(key->group, flag); in EC_KEY_set_asn1_flag()
930 int EC_KEY_precompute_mult(EC_KEY *key, BN_CTX *ctx) in EC_KEY_precompute_mult() argument
932 if (key->group == NULL) in EC_KEY_precompute_mult()
934 return EC_GROUP_precompute_mult(key->group, ctx); in EC_KEY_precompute_mult()
938 int EC_KEY_get_flags(const EC_KEY *key) in EC_KEY_get_flags() argument
940 return key->flags; in EC_KEY_get_flags()
943 void EC_KEY_set_flags(EC_KEY *key, int flags) in EC_KEY_set_flags() argument
945 key->flags |= flags; in EC_KEY_set_flags()
946 key->dirty_cnt++; in EC_KEY_set_flags()
949 void EC_KEY_clear_flags(EC_KEY *key, int flags) in EC_KEY_clear_flags() argument
951 key->flags &= ~flags; in EC_KEY_clear_flags()
952 key->dirty_cnt++; in EC_KEY_clear_flags()
955 int EC_KEY_decoded_from_explicit_params(const EC_KEY *key) in EC_KEY_decoded_from_explicit_params() argument
957 if (key == NULL || key->group == NULL) in EC_KEY_decoded_from_explicit_params()
959 return key->group->decoded_from_explicit_params; in EC_KEY_decoded_from_explicit_params()
962 size_t EC_KEY_key2buf(const EC_KEY *key, point_conversion_form_t form, in EC_KEY_key2buf() argument
965 if (key == NULL || key->pub_key == NULL || key->group == NULL) in EC_KEY_key2buf()
967 return EC_POINT_point2buf(key->group, key->pub_key, form, pbuf, ctx); in EC_KEY_key2buf()
970 int EC_KEY_oct2key(EC_KEY *key, const unsigned char *buf, size_t len, in EC_KEY_oct2key() argument
973 if (key == NULL || key->group == NULL) in EC_KEY_oct2key()
975 if (key->pub_key == NULL) in EC_KEY_oct2key()
976 key->pub_key = EC_POINT_new(key->group); in EC_KEY_oct2key()
977 if (key->pub_key == NULL) in EC_KEY_oct2key()
979 if (EC_POINT_oct2point(key->group, key->pub_key, buf, len, ctx) == 0) in EC_KEY_oct2key()
981 key->dirty_cnt++; in EC_KEY_oct2key()
989 if ((key->group->meth->flags & EC_FLAGS_CUSTOM_CURVE) == 0) in EC_KEY_oct2key()
990 key->conv_form = (point_conversion_form_t)(buf[0] & ~0x01); in EC_KEY_oct2key()