Skip to content

Commit

Permalink
fix compiler warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
mkannwischer committed Oct 21, 2024
1 parent bbcac75 commit 8a9c7cc
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 106 deletions.
11 changes: 0 additions & 11 deletions crypto_sign/ml-dsa-44/m4f/poly.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,6 @@ void poly_caddq(poly *a) {
asm_caddq(a->coeffs);
}

/*************************************************
* Name: poly_csubq
*
* Description: For all coefficients of input polynomial subtract Q if
* coefficient is bigger than Q; add Q if coefficient is negative.
*
* Arguments: - poly *a: pointer to input/output polynomial
**************************************************/
void poly_csubq(poly *a) {
asm_caddq(a->coeffs);
}

#if 0
/*************************************************
Expand Down
2 changes: 0 additions & 2 deletions crypto_sign/ml-dsa-44/m4f/poly.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ typedef struct {
void poly_reduce(poly *a);
#define poly_caddq DILITHIUM_NAMESPACE(poly_caddq)
void poly_caddq(poly *a);
#define poly_csubq DILITHIUM_NAMESPACE(poly_csubq)
void poly_csubq(poly *a);
#define poly_freeze DILITHIUM_NAMESPACE(poly_freeze)
void poly_freeze(poly *a);

Expand Down
2 changes: 1 addition & 1 deletion crypto_sign/ml-dsa-44/m4f/sign.c
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ int crypto_sign_verify_ctx(const uint8_t *sig,
poly_invntt_tomont(&w1_elem);

// Reconstruct w1
poly_csubq(&w1_elem);
poly_caddq(&w1_elem);
if (unpack_sig_h(&tmp_elem, k_idx, sig) != 0) {
return -1;
}
Expand Down
2 changes: 0 additions & 2 deletions crypto_sign/ml-dsa-44/m4f/vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ void asm_reduce32(int32_t a[N]);
void small_asm_reduce32_central(int32_t a[N]);
#define asm_caddq DILITHIUM_NAMESPACE(asm_caddq)
void asm_caddq(int32_t a[N]);
#define asm_csubq DILITHIUM_NAMESPACE(asm_csubq)
void asm_csubq(int32_t a[N]);
#define asm_freeze DILITHIUM_NAMESPACE(asm_freeze)
void asm_freeze(int32_t a[N]);
#define asm_rej_uniform DILITHIUM_NAMESPACE(asm_rej_uniform)
Expand Down
54 changes: 0 additions & 54 deletions crypto_sign/ml-dsa-44/m4f/vector.s
Original file line number Diff line number Diff line change
Expand Up @@ -169,60 +169,6 @@ pqcrystals_dilithium_asm_caddq:
bx lr
.size pqcrystals_dilithium_asm_caddq, .-pqcrystals_dilithium_asm_caddq

.macro csubq a, tmp, q
cmp.n \a, \q
it ge
subge.w \a, \a, \q
cmp \a, #0
it mi
addmi.w \a, \a, \q
.endm

// void asm_csubq(int32_t a[N]);
.global pqcrystals_dilithium_asm_csubq
.type pqcrystals_dilithium_asm_csubq, %function
.align 2
pqcrystals_dilithium_asm_csubq:
push {r4-r10}

movw r12,#:lower16:8380417
movt r12,#:upper16:8380417

movw r10, #32
1:
ldr.w r1, [r0]
ldr.w r2, [r0, #1*4]
ldr.w r3, [r0, #2*4]
ldr.w r4, [r0, #3*4]
ldr.w r5, [r0, #4*4]
ldr.w r6, [r0, #5*4]
ldr.w r7, [r0, #6*4]
ldr.w r8, [r0, #7*4]

csubq r1, r9, r12
csubq r2, r9, r12
csubq r3, r9, r12
csubq r4, r9, r12
csubq r5, r9, r12
csubq r6, r9, r12
csubq r7, r9, r12
csubq r8, r9, r12

str.w r2, [r0, #1*4]
str.w r3, [r0, #2*4]
str.w r4, [r0, #3*4]
str.w r5, [r0, #4*4]
str.w r6, [r0, #5*4]
str.w r7, [r0, #6*4]
str.w r8, [r0, #7*4]
str r1, [r0], #8*4
subs r10, #1
bne.w 1b

pop {r4-r10}
bx lr
.size pqcrystals_dilithium_asm_csubq, .-pqcrystals_dilithium_asm_csubq

// asm_rej_uniform(int32_t *a,unsigned int len,const unsigned char *buf, unsigned int buflen);
.global pqcrystals_dilithium_asm_rej_uniform
.type pqcrystals_dilithium_asm_rej_uniform, %function
Expand Down
18 changes: 7 additions & 11 deletions crypto_sign/ml-dsa-44/m4fstack/sign.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ int crypto_sign_keypair(uint8_t *pk, uint8_t *sk) {
} data;

shake256incctx *s256 = &data.s256;
uint8_t *tr = &data.tr;
uint8_t *tr = &data.tr[0];
poly *tC = &data.tC;

/* Get randomness for rho, rhoprime and key */
Expand Down Expand Up @@ -135,7 +135,6 @@ int crypto_sign_signature_ctx(uint8_t *sig,
uint8_t *mu, *rhoprime, *rnd;
const uint8_t *rho, *tr, *key;
uint16_t nonce = 0;
unsigned int n;
uint8_t wcomp[K][768];
uint8_t ccomp[68];

Expand Down Expand Up @@ -168,9 +167,6 @@ int crypto_sign_signature_ctx(uint8_t *sig,
return -1;
}


unpack_sk_stack(rho, tr, key, sk);

/* Compute mu = CRH(tr, 0, ctxlen, ctx, msg) */
mu[0] = 0;
mu[1] = (uint8_t)ctxlen;
Expand Down Expand Up @@ -363,15 +359,15 @@ int crypto_sign_verify_ctx(const uint8_t *sig,
uint8_t w1_packed[POLYW1_PACKEDBYTES];
uint8_t wcomp[768];
} w1_packed_comp;
uint8_t *w1_packed = &w1_packed_comp.w1_packed;
uint8_t *wcomp = &w1_packed_comp.wcomp;
uint8_t *w1_packed = &w1_packed_comp.w1_packed[0];
uint8_t *wcomp = &w1_packed_comp.wcomp[0];

union {
uint8_t ccomp[68];
uint8_t mu[CRHBYTES];
} ccomp_mu;
uint8_t *ccomp = &ccomp_mu.ccomp;
uint8_t *mu = &ccomp_mu.mu;
uint8_t *ccomp = &ccomp_mu.ccomp[0];
uint8_t *mu = &ccomp_mu.mu[0];

shake256incctx s256;

Expand All @@ -381,9 +377,9 @@ int crypto_sign_verify_ctx(const uint8_t *sig,
uint8_t c2[CTILDEBYTES];
} shake_hint;

uint8_t *hint_ones = &shake_hint.hint_ones;
uint8_t *hint_ones = &shake_hint.hint_ones[0];
shake128incctx *s128 = &shake_hint.s128;
uint8_t *c2 = &shake_hint.c2;
uint8_t *c2 = &shake_hint.c2[0];

if (ctxlen > 255 || siglen != CRYPTO_BYTES) {
return -1;
Expand Down
20 changes: 0 additions & 20 deletions crypto_sign/ml-dsa-44/m4fstack/stack.c
Original file line number Diff line number Diff line change
Expand Up @@ -438,26 +438,6 @@ size_t poly_make_hint_stack(poly *a, poly *t, uint8_t w[768]){
return hints_n;
}

void unpack_sk_stack(uint8_t rho[SEEDBYTES],
uint8_t tr[TRBYTES],
uint8_t key[SEEDBYTES],
const uint8_t sk[CRYPTO_SECRETKEYBYTES])
{
unsigned int i;

for(i = 0; i < SEEDBYTES; ++i)
rho[i] = sk[i];
sk += SEEDBYTES;

for(i = 0; i < SEEDBYTES; ++i)
key[i] = sk[i];
sk += SEEDBYTES;

for(i = 0; i < TRBYTES; ++i)
tr[i] = sk[i];
sk += TRBYTES;
}

/*************************************************
* Name: unpack_sig_h_indices
*
Expand Down
5 changes: 0 additions & 5 deletions crypto_sign/ml-dsa-44/m4fstack/stack.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ size_t poly_make_hint_stack(poly *a, poly *t, uint8_t w[768]);
int unpack_sig_h_indices(uint8_t h_i[OMEGA], unsigned int * number_of_hints, unsigned int idx, const unsigned char sig[CRYPTO_BYTES]);
void poly_use_hint_stack(poly *b, const poly *a, uint8_t h_i[OMEGA], unsigned int number_of_hints);

void unpack_sk_stack(uint8_t rho[SEEDBYTES],
uint8_t tr[TRBYTES],
uint8_t key[SEEDBYTES],
const uint8_t sk[CRYPTO_SECRETKEYBYTES]);

void pack_pk_rho(unsigned char pk[CRYPTO_PUBLICKEYBYTES],
const unsigned char rho[SEEDBYTES]);

Expand Down

0 comments on commit 8a9c7cc

Please sign in to comment.