ml_dsa_matrix.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. /* A 'k' by 'l' Matrix object ('k' rows and 'l' columns) containing polynomial scalars */
  10. struct matrix_st {
  11. POLY *m_poly;
  12. size_t k, l;
  13. };
  14. /**
  15. * @brief Initialize a Matrix object.
  16. *
  17. * @param m The matrix object.
  18. * @param polys A preallocated array of k * l polynomial blocks. |m| does not
  19. * own/free this.
  20. * @param k The number of rows
  21. * @param l The number of columns
  22. */
  23. static ossl_inline ossl_unused void
  24. matrix_init(MATRIX *m, POLY *polys, size_t k, size_t l)
  25. {
  26. m->k = k;
  27. m->l = l;
  28. m->m_poly = polys;
  29. }
  30. static ossl_inline ossl_unused void
  31. matrix_mult_vector(const MATRIX *a, const VECTOR *s, VECTOR *t)
  32. {
  33. ossl_ml_dsa_matrix_mult_vector(a, s, t);
  34. }
  35. static ossl_inline ossl_unused int
  36. matrix_expand_A(EVP_MD_CTX *g_ctx, const EVP_MD *md, const uint8_t *rho,
  37. MATRIX *out)
  38. {
  39. return ossl_ml_dsa_matrix_expand_A(g_ctx, md, rho, out);
  40. }