Debian Codegraph @

debian/rust-vendor/aws-lc-sys/aws-lc/crypto/ec_extra/internal.h

raw
1 // Copyright (c) 2020, Google Inc.
2 // SPDX-License-Identifier: ISC
3
4 #ifndef OPENSSL_HEADER_EC_EXTRA_INTERNAL_H
5 #define OPENSSL_HEADER_EC_EXTRA_INTERNAL_H
6
7 #include <openssl/ec.h>
8
9 #include "../fipsmodule/ec/internal.h"
10
11 #if defined(__cplusplus)
12 extern "C" {
13 #endif
14
15
16 // Hash-to-curve.
17 //
18 // Internal |EC_JACOBIAN| versions of the corresponding public APIs.
19
20 // ec_hash_to_curve_p256_xmd_sha256_sswu hashes |msg| to a point on |group| and
21 // writes the result to |out|, implementing the P256_XMD:SHA-256_SSWU_RO_ suite
22 // from RFC 9380. It returns one on success and zero on error.
23 OPENSSL_EXPORT int ec_hash_to_curve_p256_xmd_sha256_sswu(
24 const EC_GROUP *group, EC_JACOBIAN *out, const uint8_t *dst, size_t dst_len,
25 const uint8_t *msg, size_t msg_len);
26
27 // ec_hash_to_curve_p384_xmd_sha384_sswu hashes |msg| to a point on |group| and
28 // writes the result to |out|, implementing the P384_XMD:SHA-384_SSWU_RO_ suite
29 // from RFC 9380. It returns one on success and zero on error.
30 OPENSSL_EXPORT int ec_hash_to_curve_p384_xmd_sha384_sswu(
31 const EC_GROUP *group, EC_JACOBIAN *out, const uint8_t *dst, size_t dst_len,
32 const uint8_t *msg, size_t msg_len);
33
34 // ec_hash_to_scalar_p384_xmd_sha384 hashes |msg| to a scalar on |group|
35 // and writes the result to |out|, using the hash_to_field operation from the
36 // P384_XMD:SHA-384_SSWU_RO_ suite from RFC 9380, but generating a value modulo
37 // the group order rather than a field element.
38 OPENSSL_EXPORT int ec_hash_to_scalar_p384_xmd_sha384(
39 const EC_GROUP *group, EC_SCALAR *out, const uint8_t *dst, size_t dst_len,
40 const uint8_t *msg, size_t msg_len);
41
42 // ec_hash_to_curve_p384_xmd_sha512_sswu_draft07 hashes |msg| to a point on
43 // |group| and writes the result to |out|, implementing the
44 // P384_XMD:SHA-512_SSWU_RO_ suite from draft-irtf-cfrg-hash-to-curve-07. It
45 // returns one on success and zero on error.
46 //
47 // TODO(https://crbug.com/1414562): Migrate this to the final version.
48 OPENSSL_EXPORT int ec_hash_to_curve_p384_xmd_sha512_sswu_draft07(
49 const EC_GROUP *group, EC_JACOBIAN *out, const uint8_t *dst, size_t dst_len,
50 const uint8_t *msg, size_t msg_len);
51
52 // ec_hash_to_scalar_p384_xmd_sha512_draft07 hashes |msg| to a scalar on |group|
53 // and writes the result to |out|, using the hash_to_field operation from the
54 // P384_XMD:SHA-512_SSWU_RO_ suite from draft-irtf-cfrg-hash-to-curve-07, but
55 // generating a value modulo the group order rather than a field element.
56 //
57 // TODO(https://crbug.com/1414562): Migrate this to the final version.
58 OPENSSL_EXPORT int ec_hash_to_scalar_p384_xmd_sha512_draft07(
59 const EC_GROUP *group, EC_SCALAR *out, const uint8_t *dst, size_t dst_len,
60 const uint8_t *msg, size_t msg_len);
61
62 enum ECParametersType {
63 UNKNOWN_EC_PARAMETERS = 0,
64 NAMED_CURVE_EC_PARAMETERS = 1,
65 SPECIFIED_CURVE_EC_PARAMETERS = 2,
66 };
67
68 // EC_KEY_parse_parameters_and_type parses the elliptic curve key parameters from |cbs| and
69 // sets the type of parameters found on |paramType|.
70 EC_GROUP *EC_KEY_parse_parameters_and_type(CBS *cbs, enum ECParametersType *paramType);
71
72 #if defined(__cplusplus)
73 } // extern C
74 #endif
75
76 #endif // OPENSSL_HEADER_EC_EXTRA_INTERNAL_H