Lines Matching defs:ecdh

2637 	struct crypto_ecdh *ecdh;
2640 ecdh = os_zalloc(sizeof(*ecdh));
2641 if (!ecdh)
2644 ecdh->ec = crypto_ec_init(group);
2645 if (!ecdh->ec)
2648 name = OSSL_EC_curve_nid2name(ecdh->ec->nid);
2652 ecdh->pkey = EVP_EC_gen(name);
2653 if (!ecdh->pkey)
2657 return ecdh;
2659 crypto_ecdh_deinit(ecdh);
2660 ecdh = NULL;
2663 struct crypto_ecdh *ecdh;
2668 ecdh = os_zalloc(sizeof(*ecdh));
2669 if (!ecdh)
2672 ecdh->ec = crypto_ec_init(group);
2673 if (!ecdh->ec)
2676 ec_params = EC_KEY_new_by_curve_name(ecdh->ec->nid);
2701 if (EVP_PKEY_keygen(kctx, &ecdh->pkey) != 1) {
2712 return ecdh;
2714 crypto_ecdh_deinit(ecdh);
2715 ecdh = NULL;
2724 struct crypto_ecdh *ecdh;
2726 ecdh = os_zalloc(sizeof(*ecdh));
2727 if (!ecdh)
2730 ecdh->ec = crypto_ec_init(group);
2731 if (!ecdh->ec)
2734 ecdh->pkey = EVP_PKEY_dup((EVP_PKEY *) own_key);
2735 if (!ecdh->pkey)
2738 return ecdh;
2740 crypto_ecdh_deinit(ecdh);
2743 struct crypto_ecdh *ecdh;
2745 ecdh = os_zalloc(sizeof(*ecdh));
2746 if (!ecdh)
2749 ecdh->ec = crypto_ec_init(group);
2750 if (!ecdh->ec)
2753 ecdh->pkey = EVP_PKEY_new();
2754 if (!ecdh->pkey ||
2755 EVP_PKEY_assign_EC_KEY(ecdh->pkey,
2760 return ecdh;
2762 crypto_ecdh_deinit(ecdh);
2768 struct wpabuf * crypto_ecdh_get_pubkey(struct crypto_ecdh *ecdh, int inc_y)
2775 len = EVP_PKEY_get1_encoded_public_key(ecdh->pkey, &pub);
2780 exp_len = 1 + 2 * crypto_ec_prime_len(ecdh->ec);
2796 int len = BN_num_bytes(ecdh->ec->prime);
2799 eckey = EVP_PKEY_get1_EC_KEY(ecdh->pkey);
2817 if (EC_POINT_get_affine_coordinates(ecdh->ec->group, pubkey,
2818 x, y, ecdh->ec->bnctx) != 1) {
2851 struct wpabuf * crypto_ecdh_set_peerkey(struct crypto_ecdh *ecdh, int inc_y,
2871 EVP_PKEY_copy_parameters(peerkey, ecdh->pkey) != 1 ||
2881 ctx = EVP_PKEY_CTX_new(ecdh->pkey, NULL);
2909 pub = EC_POINT_new(ecdh->ec->group);
2917 if (!EC_POINT_set_affine_coordinates(ecdh->ec->group, pub,
2918 x, y, ecdh->ec->bnctx)) {
2924 } else if (!EC_POINT_set_compressed_coordinates(ecdh->ec->group,
2926 ecdh->ec->bnctx)) {
2933 if (!EC_POINT_is_on_curve(ecdh->ec->group, pub, ecdh->ec->bnctx)) {
2939 eckey = EC_KEY_new_by_curve_name(ecdh->ec->nid);
2951 ctx = EVP_PKEY_CTX_new(ecdh->pkey, NULL);
2992 void crypto_ecdh_deinit(struct crypto_ecdh *ecdh)
2994 if (ecdh) {
2995 crypto_ec_deinit(ecdh->ec);
2996 EVP_PKEY_free(ecdh->pkey);
2997 os_free(ecdh);
3002 size_t crypto_ecdh_prime_len(struct crypto_ecdh *ecdh)
3004 return crypto_ec_prime_len(ecdh->ec);