| 1 | /* Copyright (c) 2020, Google Inc. |
| 2 | * |
| 3 | * Permission to use, copy, modify, and/or distribute this software for any |
| 4 | * purpose with or without fee is hereby granted, provided that the above |
| 5 | * copyright notice and this permission notice appear in all copies. |
| 6 | * |
| 7 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 8 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 9 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY |
| 10 | * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 11 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION |
| 12 | * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN |
| 13 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ |
| 14 | |
| 15 | #ifndef OPENSSL_HEADER_EC_EXTRA_INTERNAL_H |
| 16 | #define |
| 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_RAW_POINT| 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 draft-irtf-cfrg-hash-to-curve-16. It returns one on success and zero on |
| 34 | // error. |
| 35 | OPENSSL_EXPORT int ec_hash_to_curve_p256_xmd_sha256_sswu( |
| 36 | const EC_GROUP *group, EC_RAW_POINT *out, const uint8_t *dst, |
| 37 | size_t dst_len, const uint8_t *msg, size_t msg_len); |
| 38 | |
| 39 | // ec_hash_to_curve_p384_xmd_sha384_sswu hashes |msg| to a point on |group| and |
| 40 | // writes the result to |out|, implementing the P384_XMD:SHA-384_SSWU_RO_ suite |
| 41 | // from draft-irtf-cfrg-hash-to-curve-16. It returns one on success and zero on |
| 42 | // error. |
| 43 | OPENSSL_EXPORT int ec_hash_to_curve_p384_xmd_sha384_sswu( |
| 44 | const EC_GROUP *group, EC_RAW_POINT *out, const uint8_t *dst, |
| 45 | size_t dst_len, const uint8_t *msg, size_t msg_len); |
| 46 | |
| 47 | // ec_hash_to_curve_p384_xmd_sha512_sswu_draft07 hashes |msg| to a point on |
| 48 | // |group| and writes the result to |out|, implementing the |
| 49 | // P384_XMD:SHA-512_SSWU_RO_ suite from draft-irtf-cfrg-hash-to-curve-07. It |
| 50 | // returns one on success and zero on error. |
| 51 | // |
| 52 | // TODO(https://crbug.com/1414562): Migrate this to the final version. |
| 53 | OPENSSL_EXPORT int ec_hash_to_curve_p384_xmd_sha512_sswu_draft07( |
| 54 | const EC_GROUP *group, EC_RAW_POINT *out, const uint8_t *dst, |
| 55 | size_t dst_len, const uint8_t *msg, size_t msg_len); |
| 56 | |
| 57 | // ec_hash_to_scalar_p384_xmd_sha512_draft07 hashes |msg| to a scalar on |group| |
| 58 | // and writes the result to |out|, using the hash_to_field operation from the |
| 59 | // P384_XMD:SHA-512_SSWU_RO_ suite from draft-irtf-cfrg-hash-to-curve-07, but |
| 60 | // generating a value modulo the group order rather than a field element. |
| 61 | // |
| 62 | // TODO(https://crbug.com/1414562): Migrate this to the final version. |
| 63 | OPENSSL_EXPORT int ec_hash_to_scalar_p384_xmd_sha512_draft07( |
| 64 | const EC_GROUP *group, EC_SCALAR *out, const uint8_t *dst, size_t dst_len, |
| 65 | const uint8_t *msg, size_t msg_len); |
| 66 | |
| 67 | |
| 68 | #if defined(__cplusplus) |
| 69 | } // extern C |
| 70 | #endif |
| 71 | |
| 72 | #endif // OPENSSL_HEADER_EC_EXTRA_INTERNAL_H |
| 73 | |