Skip to content

Commit 2948ece

Browse files
mkannwischerhanno-becker
authored andcommitted
poly/poly_kl: Use array notation with explicit sizes
Signed-off-by: Matthias J. Kannwischer <matthias@kannwischer.eu>
1 parent 063e6f8 commit 2948ece

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

mldsa/src/poly.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ void mld_poly_uniform_4x(mld_poly *vec0, mld_poly *vec1, mld_poly *vec2,
425425
#endif /* !MLD_CONFIG_SERIAL_FIPS202_ONLY */
426426

427427
MLD_INTERNAL_API
428-
void mld_polyt1_pack(uint8_t *r, const mld_poly *a)
428+
void mld_polyt1_pack(uint8_t r[MLDSA_POLYT1_PACKEDBYTES], const mld_poly *a)
429429
{
430430
unsigned int i;
431431
mld_assert_bound(a->coeffs, MLDSA_N, 0, 1 << 10);
@@ -449,7 +449,7 @@ void mld_polyt1_pack(uint8_t *r, const mld_poly *a)
449449
}
450450

451451
MLD_INTERNAL_API
452-
void mld_polyt1_unpack(mld_poly *r, const uint8_t *a)
452+
void mld_polyt1_unpack(mld_poly *r, const uint8_t a[MLDSA_POLYT1_PACKEDBYTES])
453453
{
454454
unsigned int i;
455455

@@ -472,7 +472,7 @@ void mld_polyt1_unpack(mld_poly *r, const uint8_t *a)
472472
}
473473

474474
MLD_INTERNAL_API
475-
void mld_polyt0_pack(uint8_t *r, const mld_poly *a)
475+
void mld_polyt0_pack(uint8_t r[MLDSA_POLYT0_PACKEDBYTES], const mld_poly *a)
476476
{
477477
unsigned int i;
478478
uint32_t t[8];
@@ -519,7 +519,7 @@ void mld_polyt0_pack(uint8_t *r, const mld_poly *a)
519519
}
520520

521521
MLD_INTERNAL_API
522-
void mld_polyt0_unpack(mld_poly *r, const uint8_t *a)
522+
void mld_polyt0_unpack(mld_poly *r, const uint8_t a[MLDSA_POLYT0_PACKEDBYTES])
523523
{
524524
unsigned int i;
525525

mldsa/src/poly.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ __contract__(
286286
* - const mld_poly *a: pointer to input polynomial
287287
**************************************************/
288288
MLD_INTERNAL_API
289-
void mld_polyt1_pack(uint8_t *r, const mld_poly *a)
289+
void mld_polyt1_pack(uint8_t r[MLDSA_POLYT1_PACKEDBYTES], const mld_poly *a)
290290
__contract__(
291291
requires(memory_no_alias(r, MLDSA_POLYT1_PACKEDBYTES))
292292
requires(memory_no_alias(a, sizeof(mld_poly)))
@@ -305,7 +305,7 @@ __contract__(
305305
* - const uint8_t *a: byte array with bit-packed polynomial
306306
**************************************************/
307307
MLD_INTERNAL_API
308-
void mld_polyt1_unpack(mld_poly *r, const uint8_t *a)
308+
void mld_polyt1_unpack(mld_poly *r, const uint8_t a[MLDSA_POLYT1_PACKEDBYTES])
309309
__contract__(
310310
requires(memory_no_alias(r, sizeof(mld_poly)))
311311
requires(memory_no_alias(a, MLDSA_POLYT1_PACKEDBYTES))
@@ -325,7 +325,7 @@ __contract__(
325325
* - const mld_poly *a: pointer to input polynomial
326326
**************************************************/
327327
MLD_INTERNAL_API
328-
void mld_polyt0_pack(uint8_t *r, const mld_poly *a)
328+
void mld_polyt0_pack(uint8_t r[MLDSA_POLYT0_PACKEDBYTES], const mld_poly *a)
329329
__contract__(
330330
requires(memory_no_alias(r, MLDSA_POLYT0_PACKEDBYTES))
331331
requires(memory_no_alias(a, sizeof(mld_poly)))
@@ -345,7 +345,7 @@ __contract__(
345345
* - const uint8_t *a: byte array with bit-packed polynomial
346346
**************************************************/
347347
MLD_INTERNAL_API
348-
void mld_polyt0_unpack(mld_poly *r, const uint8_t *a)
348+
void mld_polyt0_unpack(mld_poly *r, const uint8_t a[MLDSA_POLYT0_PACKEDBYTES])
349349
__contract__(
350350
requires(memory_no_alias(r, sizeof(mld_poly)))
351351
requires(memory_no_alias(a, MLDSA_POLYT0_PACKEDBYTES))

mldsa/src/poly_kl.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ void mld_poly_challenge(mld_poly *c, const uint8_t seed[MLDSA_CTILDEBYTES])
603603
}
604604

605605
MLD_INTERNAL_API
606-
void mld_polyeta_pack(uint8_t *r, const mld_poly *a)
606+
void mld_polyeta_pack(uint8_t r[MLDSA_POLYETA_PACKEDBYTES], const mld_poly *a)
607607
{
608608
unsigned int i;
609609
uint8_t t[8];
@@ -648,7 +648,7 @@ void mld_polyeta_pack(uint8_t *r, const mld_poly *a)
648648
#endif /* MLDSA_ETA != 2 && MLDSA_ETA != 4 */
649649
}
650650

651-
void mld_polyeta_unpack(mld_poly *r, const uint8_t *a)
651+
void mld_polyeta_unpack(mld_poly *r, const uint8_t a[MLDSA_POLYETA_PACKEDBYTES])
652652
{
653653
unsigned int i;
654654

@@ -697,7 +697,7 @@ void mld_polyeta_unpack(mld_poly *r, const uint8_t *a)
697697

698698

699699
MLD_INTERNAL_API
700-
void mld_polyz_pack(uint8_t *r, const mld_poly *a)
700+
void mld_polyz_pack(uint8_t r[MLDSA_POLYZ_PACKEDBYTES], const mld_poly *a)
701701
{
702702
unsigned int i;
703703
uint32_t t[4];
@@ -748,7 +748,7 @@ void mld_polyz_pack(uint8_t *r, const mld_poly *a)
748748
}
749749

750750
MLD_INTERNAL_API
751-
void mld_polyz_unpack(mld_poly *r, const uint8_t *a)
751+
void mld_polyz_unpack(mld_poly *r, const uint8_t a[MLDSA_POLYZ_PACKEDBYTES])
752752
{
753753
unsigned int i;
754754
#if defined(MLD_USE_NATIVE_POLYZ_UNPACK_17) && MLD_CONFIG_PARAMETER_SET == 44

mldsa/src/poly_kl.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ __contract__(
251251
* - const mld_poly *a: pointer to input polynomial
252252
**************************************************/
253253
MLD_INTERNAL_API
254-
void mld_polyeta_pack(uint8_t *r, const mld_poly *a)
254+
void mld_polyeta_pack(uint8_t r[MLDSA_POLYETA_PACKEDBYTES], const mld_poly *a)
255255
__contract__(
256256
requires(memory_no_alias(r, MLDSA_POLYETA_PACKEDBYTES))
257257
requires(memory_no_alias(a, sizeof(mld_poly)))
@@ -285,7 +285,7 @@ __contract__(
285285
* - const uint8_t *a: byte array with bit-packed polynomial
286286
**************************************************/
287287
MLD_INTERNAL_API
288-
void mld_polyeta_unpack(mld_poly *r, const uint8_t *a)
288+
void mld_polyeta_unpack(mld_poly *r, const uint8_t a[MLDSA_POLYETA_PACKEDBYTES])
289289
__contract__(
290290
requires(memory_no_alias(r, sizeof(mld_poly)))
291291
requires(memory_no_alias(a, MLDSA_POLYETA_PACKEDBYTES))
@@ -305,7 +305,7 @@ __contract__(
305305
* - const mld_poly *a: pointer to input polynomial
306306
**************************************************/
307307
MLD_INTERNAL_API
308-
void mld_polyz_pack(uint8_t *r, const mld_poly *a)
308+
void mld_polyz_pack(uint8_t r[MLDSA_POLYZ_PACKEDBYTES], const mld_poly *a)
309309
__contract__(
310310
requires(memory_no_alias(r, MLDSA_POLYZ_PACKEDBYTES))
311311
requires(memory_no_alias(a, sizeof(mld_poly)))
@@ -325,7 +325,7 @@ __contract__(
325325
* - const uint8_t *a: byte array with bit-packed polynomial
326326
**************************************************/
327327
MLD_INTERNAL_API
328-
void mld_polyz_unpack(mld_poly *r, const uint8_t *a)
328+
void mld_polyz_unpack(mld_poly *r, const uint8_t a[MLDSA_POLYZ_PACKEDBYTES])
329329
__contract__(
330330
requires(memory_no_alias(r, sizeof(mld_poly)))
331331
requires(memory_no_alias(a, MLDSA_POLYZ_PACKEDBYTES))

0 commit comments

Comments
 (0)