1 /* Copyright (c) 2024, Google LLC 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_CRYPTO_SLHDSA_INTERNAL_H 16 #define OPENSSL_HEADER_CRYPTO_SLHDSA_INTERNAL_H 17 18 #include <openssl/slhdsa.h> 19 20 #include "params.h" 21 22 #if defined(__cplusplus) 23 extern "C" { 24 #endif 25 26 27 // SLHDSA_SHA2_128S_generate_key_from_seed generates an SLH-DSA-SHA2-128s key 28 // pair from a 48-byte seed and writes the result to |out_public_key| and 29 // |out_secret_key|. 30 OPENSSL_EXPORT void SLHDSA_SHA2_128S_generate_key_from_seed( 31 uint8_t out_public_key[SLHDSA_SHA2_128S_PUBLIC_KEY_BYTES], 32 uint8_t out_secret_key[SLHDSA_SHA2_128S_PRIVATE_KEY_BYTES], 33 const uint8_t seed[3 * SLHDSA_SHA2_128S_N]); 34 35 // SLHDSA_SHA2_128S_sign_internal acts like |SLHDSA_SHA2_128S_sign| but 36 // accepts an explicit entropy input, which can be PK.seed (bytes 32..48 of 37 // the private key) to generate deterministic signatures. It also takes the 38 // input message in three parts so that the "internal" version of the signing 39 // function, from section 9.2, can be implemented. The |header| argument may be 40 // NULL to omit it. 41 OPENSSL_EXPORT void SLHDSA_SHA2_128S_sign_internal( 42 uint8_t out_signature[SLHDSA_SHA2_128S_SIGNATURE_BYTES], 43 const uint8_t secret_key[SLHDSA_SHA2_128S_PRIVATE_KEY_BYTES], 44 const uint8_t header[SLHDSA_M_PRIME_HEADER_LEN], const uint8_t *context, 45 size_t context_len, const uint8_t *msg, size_t msg_len, 46 const uint8_t entropy[SLHDSA_SHA2_128S_N]); 47 48 // SLHDSA_SHA2_128S_verify_internal acts like |SLHDSA_SHA2_128S_verify| but 49 // takes the input message in three parts so that the "internal" version of the 50 // verification function, from section 9.3, can be implemented. The |header| 51 // argument may be NULL to omit it. 52 OPENSSL_EXPORT int SLHDSA_SHA2_128S_verify_internal( 53 const uint8_t *signature, size_t signature_len, 54 const uint8_t public_key[SLHDSA_SHA2_128S_PUBLIC_KEY_BYTES], 55 const uint8_t header[SLHDSA_M_PRIME_HEADER_LEN], const uint8_t *context, 56 size_t context_len, const uint8_t *msg, size_t msg_len); 57 58 59 #if defined(__cplusplus) 60 } // extern C 61 #endif 62 63 #endif // OPENSSL_HEADER_CRYPTO_SLHDSA_INTERNAL_H 64