| 1 |
// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. |
| 2 |
// SPDX-License-Identifier: Apache-2.0 OR ISC |
| 3 |
|
| 4 |
#ifndef AWSLC_HEADER_PQDSA_INTERNAL_H |
| 5 |
#define AWSLC_HEADER_PQDSA_INTERNAL_H |
| 6 |
|
| 7 |
#include <openssl/base.h> |
| 8 |
|
| 9 |
#if defined(__cplusplus) |
| 10 |
extern "C" { |
| 11 |
#endif |
| 12 |
|
| 13 |
// PQDSA_METHOD structure and helper functions. |
| 14 |
typedef struct { |
| 15 |
int (*pqdsa_keygen)(uint8_t *public_key, |
| 16 |
uint8_t *private_key, |
| 17 |
uint8_t *keygen_seed); |
| 18 |
|
| 19 |
int (*pqdsa_keygen_internal)(uint8_t *public_key, |
| 20 |
uint8_t *private_key, |
| 21 |
const uint8_t *seed); |
| 22 |
|
| 23 |
int (*pqdsa_sign_message)(const uint8_t *private_key, |
| 24 |
uint8_t *sig, |
| 25 |
size_t *sig_len, |
| 26 |
const uint8_t *message, |
| 27 |
size_t message_len, |
| 28 |
const uint8_t *ctx_string, |
| 29 |
size_t ctx_string_len); |
| 30 |
|
| 31 |
int (*pqdsa_sign)(const uint8_t *private_key, |
| 32 |
uint8_t *sig, |
| 33 |
size_t *sig_len, |
| 34 |
const uint8_t *digest, |
| 35 |
size_t digest_len); |
| 36 |
|
| 37 |
int (*pqdsa_verify_message)(const uint8_t *public_key, |
| 38 |
const uint8_t *sig, |
| 39 |
size_t sig_len, |
| 40 |
const uint8_t *message, |
| 41 |
size_t message_len, |
| 42 |
const uint8_t *ctx_string, |
| 43 |
size_t ctx_string_len); |
| 44 |
|
| 45 |
int (*pqdsa_verify)(const uint8_t *public_key, |
| 46 |
const uint8_t *sig, |
| 47 |
size_t sig_len, |
| 48 |
const uint8_t *digest, |
| 49 |
size_t digest_len); |
| 50 |
|
| 51 |
int (*pqdsa_pack_pk_from_sk)(uint8_t *public_key, |
| 52 |
const uint8_t *private_key); |
| 53 |
} PQDSA_METHOD; |
| 54 |
|
| 55 |
// PQDSA structure and helper functions. |
| 56 |
typedef struct { |
| 57 |
int nid; |
| 58 |
const uint8_t *oid; |
| 59 |
uint8_t oid_len; |
| 60 |
const char *comment; |
| 61 |
size_t public_key_len; |
| 62 |
size_t private_key_len; |
| 63 |
size_t signature_len; |
| 64 |
size_t keygen_seed_len; |
| 65 |
size_t sign_seed_len; |
| 66 |
size_t digest_len; |
| 67 |
const PQDSA_METHOD *method; |
| 68 |
} PQDSA; |
| 69 |
|
| 70 |
// PQDSA_KEY structure and helper functions. |
| 71 |
struct pqdsa_key_st { |
| 72 |
const PQDSA *pqdsa; |
| 73 |
uint8_t *public_key; |
| 74 |
uint8_t *private_key; |
| 75 |
uint8_t *seed; |
| 76 |
}; |
| 77 |
|
| 78 |
int PQDSA_KEY_init(PQDSA_KEY *key, const PQDSA *pqdsa); |
| 79 |
const PQDSA * PQDSA_find_dsa_by_nid(int nid); |
| 80 |
const EVP_PKEY_ASN1_METHOD *PQDSA_find_asn1_by_nid(int nid); |
| 81 |
const PQDSA *PQDSA_KEY_get0_dsa(PQDSA_KEY* key); |
| 82 |
PQDSA_KEY *PQDSA_KEY_new(void); |
| 83 |
void PQDSA_KEY_free(PQDSA_KEY *key); |
| 84 |
int EVP_PKEY_pqdsa_set_params(EVP_PKEY *pkey, int nid); |
| 85 |
|
| 86 |
int PQDSA_KEY_set_raw_keypair_from_seed(PQDSA_KEY *key, CBS *in); |
| 87 |
int PQDSA_KEY_set_raw_keypair_from_both(PQDSA_KEY *key, CBS *seed, CBS *expanded_key); |
| 88 |
int PQDSA_KEY_set_raw_public_key(PQDSA_KEY *key, CBS *in); |
| 89 |
int PQDSA_KEY_set_raw_private_key(PQDSA_KEY *key, CBS *in); |
| 90 |
#if defined(__cplusplus) |
| 91 |
} // extern C |
| 92 |
#endif |
| 93 |
|
| 94 |
#endif // AWSLC_HEADER_DSA_TEST_INTERNAL_H |