ml_dsa_key.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * Copyright 2024-2025 The OpenSSL Project Authors. All Rights Reserved.
  3. *
  4. * Licensed under the Apache License 2.0 (the "License"). You may not use
  5. * this file except in compliance with the License. You can obtain a copy
  6. * in the file LICENSE in the source distribution or at
  7. * https://www.openssl.org/source/license.html
  8. */
  9. #include <openssl/e_os2.h>
  10. #include "ml_dsa_local.h"
  11. #include "ml_dsa_vector.h"
  12. /* NOTE - any changes to this struct may require updates to ossl_ml_dsa_dup() */
  13. struct ml_dsa_key_st {
  14. OSSL_LIB_CTX *libctx;
  15. const ML_DSA_PARAMS *params;
  16. EVP_MD *shake128_md;
  17. EVP_MD *shake256_md;
  18. uint8_t rho[ML_DSA_RHO_BYTES]; /* public random seed */
  19. uint8_t tr[ML_DSA_TR_BYTES]; /* Pre-cached public key Hash */
  20. uint8_t K[ML_DSA_K_BYTES]; /* Private random seed for signing */
  21. /*
  22. * The encoded public and private keys, these are non NULL if the key
  23. * components are generated or loaded.
  24. *
  25. * For keys that are decoded, but not yet loaded or imported into the
  26. * provider, the pub_encoding is NULL, while the seed or priv_encoding
  27. * is not NULL.
  28. */
  29. uint8_t *pub_encoding;
  30. uint8_t *priv_encoding;
  31. uint8_t *seed;
  32. int prov_flags;
  33. /*
  34. * t1 is the Polynomial encoding of the 10 MSB of each coefficient of the
  35. * uncompressed public key polynomial t. This is saved as part of the
  36. * public key. It is column vector of K polynomials.
  37. * (There are 23 bits in q-modulus.. i.e 10 bits = 23 - 13)
  38. * t1->poly is allocated.
  39. */
  40. VECTOR t1;
  41. /*
  42. * t0 is the Polynomial encoding of the 13 LSB of each coefficient of the
  43. * uncompressed public key polynomial t. This is saved as part of the
  44. * private key. It is column vector of K polynomials.
  45. */
  46. VECTOR t0;
  47. VECTOR s2; /* private secret of size K with short coefficients (-4..4) or (-2..2) */
  48. VECTOR s1; /* private secret of size L with short coefficients (-4..4) or (-2..2) */
  49. /* The s1->poly block is allocated and has space for s2 and t0 also */
  50. };