10#include <botan/internal/ffi_ec.h>
11#include <botan/internal/ffi_mp.h>
12#include <botan/internal/ffi_oid.h>
13#include <botan/internal/ffi_util.h>
38 if(name ==
nullptr || out ==
nullptr) {
59 if(ec_group ==
nullptr) {
66 auto group_ptr = std::make_unique<Botan::EC_Group>(std::move(group));
67 *ec_group =
new botan_ec_group_struct(std::move(group_ptr));
75 if(ec_group ==
nullptr || ber ==
nullptr) {
81 auto group_ptr = std::make_unique<Botan::EC_Group>(std::move(group));
82 *ec_group =
new botan_ec_group_struct(std::move(group_ptr));
90 if(ec_group ==
nullptr || pem ==
nullptr) {
96 auto group_ptr = std::make_unique<Botan::EC_Group>(std::move(group));
97 *ec_group =
new botan_ec_group_struct(std::move(group_ptr));
105 if(ec_group ==
nullptr) {
111 auto group_ptr = std::make_unique<Botan::EC_Group>(std::move(group));
112 *ec_group =
new botan_ec_group_struct(std::move(group_ptr));
120 if(ec_group ==
nullptr || name ==
nullptr) {
126 auto group_ptr = std::make_unique<Botan::EC_Group>(std::move(group));
127 *ec_group =
new botan_ec_group_struct(std::move(group_ptr));
149 auto oid_ptr = std::make_unique<Botan::OID>(g.get_curve_oid());
150 *oid =
new botan_asn1_oid_struct(std::move(oid_ptr));
157int botan_ec_group_get_component(
botan_mp_t* out,
164 auto val = std::make_unique<Botan::BigInt>(getter(g));
165 *out =
new botan_mp_struct(std::move(val));
172 return botan_ec_group_get_component(p, ec_group, [](
const auto& g) ->
const Botan::BigInt& {
return g.get_p(); });
176 return botan_ec_group_get_component(a, ec_group, [](
const auto& g) ->
const Botan::BigInt& {
return g.get_a(); });
180 return botan_ec_group_get_component(b, ec_group, [](
const auto& g) ->
const Botan::BigInt& {
return g.get_b(); });
184 return botan_ec_group_get_component(
185 g_x, ec_group, [](
const auto& g) ->
const Botan::BigInt& {
return g.get_g_x(); });
189 return botan_ec_group_get_component(
190 g_y, ec_group, [](
const auto& g) ->
const Botan::BigInt& {
return g.get_g_y(); });
194 return botan_ec_group_get_component(
195 order, ec_group, [](
const auto& g) ->
const Botan::BigInt& {
return g.get_order(); });
static EC_Group from_name(std::string_view name)
static EC_Group from_PEM(std::string_view pem)
static EC_Group from_OID(const OID &oid)
static bool supports_application_specific_group()
static bool supports_named_group(std::string_view name)
struct botan_asn1_oid_struct * botan_asn1_oid_t
struct botan_ec_group_struct * botan_ec_group_t
int(* botan_view_bin_fn)(botan_view_ctx view_ctx, const uint8_t *data, size_t len)
struct botan_mp_struct * botan_mp_t
@ BOTAN_FFI_ERROR_NULL_POINTER
int(* botan_view_str_fn)(botan_view_ctx view_ctx, const char *str, size_t len)
int botan_ec_group_get_g_x(botan_mp_t *g_x, botan_ec_group_t ec_group)
int botan_ec_group_view_pem(botan_ec_group_t ec_group, botan_view_ctx ctx, botan_view_str_fn view)
int botan_ec_group_get_curve_oid(botan_asn1_oid_t *oid, botan_ec_group_t ec_group)
int botan_ec_group_from_params(botan_ec_group_t *ec_group, botan_asn1_oid_t oid, botan_mp_t p, botan_mp_t a, botan_mp_t b, botan_mp_t base_x, botan_mp_t base_y, botan_mp_t order)
int botan_ec_group_get_g_y(botan_mp_t *g_y, botan_ec_group_t ec_group)
int botan_ec_group_get_a(botan_mp_t *a, botan_ec_group_t ec_group)
int botan_ec_group_view_der(botan_ec_group_t ec_group, botan_view_ctx ctx, botan_view_bin_fn view)
int botan_ec_group_supports_named_group(const char *name, int *out)
int botan_ec_group_equal(botan_ec_group_t curve1_w, botan_ec_group_t curve2_w)
int botan_ec_group_get_order(botan_mp_t *order, botan_ec_group_t ec_group)
int botan_ec_group_from_oid(botan_ec_group_t *ec_group, botan_asn1_oid_t oid)
int botan_ec_group_from_name(botan_ec_group_t *ec_group, const char *name)
int botan_ec_group_supports_application_specific_group(int *out)
int botan_ec_group_destroy(botan_ec_group_t ec_group)
int botan_ec_group_get_b(botan_mp_t *b, botan_ec_group_t ec_group)
int botan_ec_group_get_p(botan_mp_t *p, botan_ec_group_t ec_group)
int botan_ec_group_from_ber(botan_ec_group_t *ec_group, const uint8_t *ber, size_t ber_len)
int botan_ec_group_from_pem(botan_ec_group_t *ec_group, const char *pem)
#define BOTAN_FFI_VISIT(obj, lambda)
#define BOTAN_FFI_CHECKED_DELETE(o)
int invoke_view_callback(botan_view_bin_fn view, botan_view_ctx ctx, std::span< const uint8_t > buf)
T & safe_get(botan_struct< T, M > *p)
int ffi_guard_thunk(const char *func_name, T thunk)