| 1 | // Copyright 2020 The BoringSSL Authors |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // https://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | #ifndef OPENSSL_HEADER_CRYPTO_EC_INTERNAL_H |
| 16 | #define OPENSSL_HEADER_CRYPTO_EC_INTERNAL_H |
| 17 | |
| 18 | #include <openssl/ec.h> |
| 19 | |
| 20 | #include "../fipsmodule/ec/internal.h" |
| 21 | |
| 22 | #if defined(__cplusplus) |
| 23 | extern "C" { |
| 24 | #endif |
| 25 | |
| 26 | |
| 27 | // Hash-to-curve. |
| 28 | // |
| 29 | // Internal |EC_JACOBIAN| versions of the corresponding public APIs. |
| 30 | |
| 31 | // ec_hash_to_curve_p256_xmd_sha256_sswu hashes |msg| to a point on |group| and |
| 32 | // writes the result to |out|, implementing the P256_XMD:SHA-256_SSWU_RO_ suite |
| 33 | // from RFC 9380. It returns one on success and zero on error. |
| 34 | OPENSSL_EXPORT int ec_hash_to_curve_p256_xmd_sha256_sswu( |
| 35 | const EC_GROUP *group, EC_JACOBIAN *out, const uint8_t *dst, size_t dst_len, |
| 36 | const uint8_t *msg, size_t msg_len); |
| 37 | |
| 38 | // ec_hash_to_curve_p384_xmd_sha384_sswu hashes |msg| to a point on |group| and |
| 39 | // writes the result to |out|, implementing the P384_XMD:SHA-384_SSWU_RO_ suite |
| 40 | // from RFC 9380. It returns one on success and zero on error. |
| 41 | OPENSSL_EXPORT int ec_hash_to_curve_p384_xmd_sha384_sswu( |
| 42 | const EC_GROUP *group, EC_JACOBIAN *out, const uint8_t *dst, size_t dst_len, |
| 43 | const uint8_t *msg, size_t msg_len); |
| 44 | |
| 45 | // ec_hash_to_scalar_p384_xmd_sha384 hashes |msg| to a scalar on |group| |
| 46 | // and writes the result to |out|, using the hash_to_field operation from the |
| 47 | // P384_XMD:SHA-384_SSWU_RO_ suite from RFC 9380, but generating a value modulo |
| 48 | // the group order rather than a field element. |
| 49 | OPENSSL_EXPORT int ec_hash_to_scalar_p384_xmd_sha384( |
| 50 | const EC_GROUP *group, EC_SCALAR *out, const uint8_t *dst, size_t dst_len, |
| 51 | const uint8_t *msg, size_t msg_len); |
| 52 | |
| 53 | // ec_hash_to_curve_p384_xmd_sha512_sswu_draft07 hashes |msg| to a point on |
| 54 | // |group| and writes the result to |out|, implementing the |
| 55 | // P384_XMD:SHA-512_SSWU_RO_ suite from draft-irtf-cfrg-hash-to-curve-07. It |
| 56 | // returns one on success and zero on error. |
| 57 | // |
| 58 | // TODO(https://crbug.com/1414562): Migrate this to the final version. |
| 59 | OPENSSL_EXPORT int ec_hash_to_curve_p384_xmd_sha512_sswu_draft07( |
| 60 | const EC_GROUP *group, EC_JACOBIAN *out, const uint8_t *dst, size_t dst_len, |
| 61 | const uint8_t *msg, size_t msg_len); |
| 62 | |
| 63 | // ec_hash_to_scalar_p384_xmd_sha512_draft07 hashes |msg| to a scalar on |group| |
| 64 | // and writes the result to |out|, using the hash_to_field operation from the |
| 65 | // P384_XMD:SHA-512_SSWU_RO_ suite from draft-irtf-cfrg-hash-to-curve-07, but |
| 66 | // generating a value modulo the group order rather than a field element. |
| 67 | // |
| 68 | // TODO(https://crbug.com/1414562): Migrate this to the final version. |
| 69 | OPENSSL_EXPORT int ec_hash_to_scalar_p384_xmd_sha512_draft07( |
| 70 | const EC_GROUP *group, EC_SCALAR *out, const uint8_t *dst, size_t dst_len, |
| 71 | const uint8_t *msg, size_t msg_len); |
| 72 | |
| 73 | |
| 74 | #if defined(__cplusplus) |
| 75 | } // extern C |
| 76 | #endif |
| 77 | |
| 78 | #endif // OPENSSL_HEADER_CRYPTO_EC_INTERNAL_H |
| 79 | |