Go to the documentation of this file.
25 #include "../fipsmodule/bn/internal.h"
26 #include "../fipsmodule/ec/internal.h"
27 #include "../internal.h"
67 static const char kPrefix[] =
"H2C-OVERSIZE-DST-";
83 uint8_t l_i_b_str_zero[3] = {out_len >> 8, out_len, 0};
104 for (
size_t j = 0; j < md_size; j++) {
120 size_t todo = out_len >= md_size ? md_size : out_len;
139 size_t L = (
bits +
k + 7) / 8;
144 if (
L * 8 >= 2 *
bits - 2 ||
159 assert(
len <= num_words *
sizeof(BN_ULONG));
163 for (
size_t i = 0;
i <
len;
i++) {
182 size_t num_words = 2 *
group->field.width;
203 size_t num_words = 2 *
group->order.width;
211 assert(
group->a_is_minus3);
220 assert(
group->a_is_minus3);
239 const BN_ULONG *
c1,
size_t num_c1,
245 group->meth->felem_sqr;
248 if (
group->field.width == 0 || (
group->field.d[0] & 3) != 3 ||
249 !
group->a_is_minus3) {
254 EC_FELEM tv1, tv2, tv3, tv4, xd, x1n, x2n,
tmp, gxd, gx1, y1, y2;
255 felem_sqr(
group, &tv1,
u);
256 felem_mul(
group, &tv3, Z, &tv1);
257 felem_sqr(
group, &tv2, &tv3);
265 felem_sqr(
group, &tv2, &xd);
266 felem_mul(
group, &gxd, &tv2, &xd);
268 felem_sqr(
group, &gx1, &x1n);
270 felem_mul(
group, &gx1, &gx1, &x1n);
273 felem_sqr(
group, &tv4, &gxd);
274 felem_mul(
group, &tv2, &gx1, &gxd);
275 felem_mul(
group, &tv4, &tv4, &tv2);
277 felem_mul(
group, &y1, &y1, &tv2);
278 felem_mul(
group, &x2n, &tv3, &x1n);
279 felem_mul(
group, &y2, &y1,
c2);
280 felem_mul(
group, &y2, &y2, &tv1);
281 felem_mul(
group, &y2, &y2,
u);
282 felem_sqr(
group, &tv2, &y1);
283 felem_mul(
group, &tv2, &tv2, &gxd);
291 BN_ULONG e3 = sgn0_u ^ sgn0_y;
292 e3 = ((BN_ULONG)0) - e3;
298 felem_mul(
group, &
out->X, &x1n, &xd);
299 felem_mul(
group, &
out->Y, &y1, &gxd);
315 size_t num_c1 =
group->field.width;
341 size_t dst_len,
const uint8_t *
msg,
size_t msg_len) {
356 static const uint8_t kSqrt1728[] = {
357 0x01, 0x98, 0x77, 0xcc, 0x10, 0x41, 0xb7, 0x55, 0x57, 0x43, 0xc0, 0xae,
358 0x2e, 0x3a, 0x3e, 0x61, 0xfb, 0x2a, 0xaa, 0x2e, 0x0e, 0x87, 0xea, 0x55,
359 0x7a, 0x56, 0x3d, 0x8b, 0x59, 0x8a, 0x09, 0x40, 0xd0, 0xa6, 0x97, 0xa9,
360 0xe0, 0xb9, 0xe9, 0x2c, 0xfa, 0xa3, 0x14, 0xf5, 0x83, 0xc9, 0xd0, 0x66
372 dst_len,
msg, msg_len);
#define EVP_MD_block_size
#define ec_felem_from_bytes
const OPENSSL_EXPORT EVP_MD * EVP_sha512(void)
static int hash_to_curve(const EC_GROUP *group, const EVP_MD *md, const EC_FELEM *Z, const EC_FELEM *c2, unsigned k, EC_RAW_POINT *out, const uint8_t *dst, size_t dst_len, const uint8_t *msg, size_t msg_len)
static void mul_A(const EC_GROUP *group, EC_FELEM *out, const EC_FELEM *in)
#define OPENSSL_PUT_ERROR(library, reason)
OPENSSL_EXPORT pem_password_cb void * u
static int hash_to_field2(const EC_GROUP *group, const EVP_MD *md, EC_FELEM *out1, EC_FELEM *out2, const uint8_t *dst, size_t dst_len, unsigned k, const uint8_t *msg, size_t msg_len)
static struct test_ctx ctx
std::vector< std::string > words
#define EVP_DigestInit_ex
static void * OPENSSL_memset(void *dst, int c, size_t n)
int ec_hash_to_curve_p384_xmd_sha512_sswu_draft07(const EC_GROUP *group, EC_RAW_POINT *out, const uint8_t *dst, size_t dst_len, const uint8_t *msg, size_t msg_len)
#define EC_R_GROUP_MISMATCH
#define EC_GROUP_get_curve_name
static void * OPENSSL_memcpy(void *dst, const void *src, size_t n)
OPENSSL_EXPORT ASN1_BIT_STRING * bits
#define ERR_R_INTERNAL_ERROR
static int num_bytes_to_derive(size_t *out, const BIGNUM *modulus, unsigned k)
#define EVP_MAX_MD_BLOCK_SIZE
static int felem_from_u8(const EC_GROUP *group, EC_FELEM *out, uint8_t a)
static int hash_to_scalar(const EC_GROUP *group, const EVP_MD *md, EC_SCALAR *out, const uint8_t *dst, size_t dst_len, unsigned k, const uint8_t *msg, size_t msg_len)
static int map_to_curve_simple_swu(const EC_GROUP *group, const EC_FELEM *Z, const BN_ULONG *c1, size_t num_c1, const EC_FELEM *c2, EC_RAW_POINT *out, const EC_FELEM *u)
#define EVP_DigestFinal_ex
#define ec_felem_non_zero_mask
static BN_ULONG sgn0_le(const EC_GROUP *group, const EC_FELEM *a)
UniquePtr< SSL_SESSION > ret
#define ec_felem_to_bytes
static void mul_minus_A(const EC_GROUP *group, EC_FELEM *out, const EC_FELEM *in)
static void big_endian_to_words(BN_ULONG *out, size_t num_words, const uint8_t *in, size_t len)
#define EVP_MD_CTX_cleanup
if(p->owned &&p->wrapped !=NULL)
#define OPENSSL_STATIC_ASSERT(cond, msg)
static int expand_message_xmd(const EVP_MD *md, uint8_t *out, size_t out_len, const uint8_t *msg, size_t msg_len, const uint8_t *dst, size_t dst_len)
int ec_hash_to_scalar_p384_xmd_sha512_draft07(const EC_GROUP *group, EC_SCALAR *out, const uint8_t *dst, size_t dst_len, const uint8_t *msg, size_t msg_len)
grpc
Author(s):
autogenerated on Fri May 16 2025 02:59:01