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