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 OPENSSL_HEADER_EC_EXTRA_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_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_scalar_p384_xmd_sha384 hashes |msg| to a scalar on |group| 48 // and writes the result to |out|, using the hash_to_field operation from the 49 // P384_XMD:SHA-384_SSWU_RO_ suite from draft-irtf-cfrg-hash-to-curve-16, but 50 // generating a value modulo the group order rather than a field element. 51 OPENSSL_EXPORT int ec_hash_to_scalar_p384_xmd_sha384( 52 const EC_GROUP *group, EC_SCALAR *out, const uint8_t *dst, size_t dst_len, 53 const uint8_t *msg, size_t msg_len); 54 55 // ec_hash_to_curve_p384_xmd_sha512_sswu_draft07 hashes |msg| to a point on 56 // |group| and writes the result to |out|, implementing the 57 // P384_XMD:SHA-512_SSWU_RO_ suite from draft-irtf-cfrg-hash-to-curve-07. It 58 // returns one on success and zero on error. 59 // 60 // TODO(https://crbug.com/1414562): Migrate this to the final version. 61 OPENSSL_EXPORT int ec_hash_to_curve_p384_xmd_sha512_sswu_draft07( 62 const EC_GROUP *group, EC_RAW_POINT *out, const uint8_t *dst, 63 size_t dst_len, const uint8_t *msg, size_t msg_len); 64 65 // ec_hash_to_scalar_p384_xmd_sha512_draft07 hashes |msg| to a scalar on |group| 66 // and writes the result to |out|, using the hash_to_field operation from the 67 // P384_XMD:SHA-512_SSWU_RO_ suite from draft-irtf-cfrg-hash-to-curve-07, but 68 // generating a value modulo the group order rather than a field element. 69 // 70 // TODO(https://crbug.com/1414562): Migrate this to the final version. 71 OPENSSL_EXPORT int ec_hash_to_scalar_p384_xmd_sha512_draft07( 72 const EC_GROUP *group, EC_SCALAR *out, const uint8_t *dst, size_t dst_len, 73 const uint8_t *msg, size_t msg_len); 74 75 76 #if defined(__cplusplus) 77 } // extern C 78 #endif 79 80 #endif // OPENSSL_HEADER_EC_EXTRA_INTERNAL_H 81