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 // The following functions implement primitives from 30 // draft-irtf-cfrg-hash-to-curve. The |dst| parameter in each function is the 31 // domain separation tag and must be unique for each protocol and between the 32 // |hash_to_curve| and |hash_to_scalar| variants. See section 3.1 of the spec 33 // for additional guidance on this parameter. 34 35 // ec_hash_to_curve_p384_xmd_sha512_sswu_draft07 hashes |msg| to a point on 36 // |group| and writes the result to |out|, implementing the 37 // P384_XMD:SHA-512_SSWU_RO_ suite from draft-irtf-cfrg-hash-to-curve-07. It 38 // returns one on success and zero on error. 39 OPENSSL_EXPORT int ec_hash_to_curve_p384_xmd_sha512_sswu_draft07( 40 const EC_GROUP *group, EC_RAW_POINT *out, const uint8_t *dst, 41 size_t dst_len, const uint8_t *msg, size_t msg_len); 42 43 // ec_hash_to_scalar_p384_xmd_sha512_draft07 hashes |msg| to a scalar on |group| 44 // and writes the result to |out|, using the hash_to_field operation from the 45 // P384_XMD:SHA-512_SSWU_RO_ suite from draft-irtf-cfrg-hash-to-curve-07, but 46 // generating a value modulo the group order rather than a field element. 47 OPENSSL_EXPORT int ec_hash_to_scalar_p384_xmd_sha512_draft07( 48 const EC_GROUP *group, EC_SCALAR *out, const uint8_t *dst, size_t dst_len, 49 const uint8_t *msg, size_t msg_len); 50 51 52 #if defined(__cplusplus) 53 } // extern C 54 #endif 55 56 #endif // OPENSSL_HEADER_EC_EXTRA_INTERNAL_H 57