@@ -241,6 +241,12 @@ static void compute_A(const mayo_params_t *p, uint64_t *VtL, unsigned char *A_ou
241
241
}
242
242
}
243
243
244
+ #ifdef TARGET_BIG_ENDIAN
245
+ for (int i = 0 ; i < (((PARAM_o (p )* PARAM_k (p )+ 15 )/16 )* 16 )* MAYO_M_OVER_8 ; ++ i )
246
+ A [i ] = BSWAP64 (A [i ]);
247
+ #endif
248
+
249
+
244
250
for (int r = 0 ; r < PARAM_m (p ); r += 16 )
245
251
{
246
252
for (int c = 0 ; c < PARAM_A_cols (p )- 1 ; c += 16 )
@@ -313,10 +319,6 @@ int mayo_expand_sk(const mayo_params_t *p, const unsigned char *csk,
313
319
const int param_O_bytes = PARAM_O_bytes (p );
314
320
const int param_pk_seed_bytes = PARAM_pk_seed_bytes (p );
315
321
const int param_sk_seed_bytes = PARAM_sk_seed_bytes (p );
316
- #ifdef TARGET_BIG_ENDIAN
317
- const int param_P1_bytes = PARAM_P1_bytes (p );
318
- const int param_P2_bytes = PARAM_P2_bytes (p );
319
- #endif
320
322
321
323
const unsigned char * seed_sk = csk ;
322
324
unsigned char * seed_pk = S ;
@@ -330,22 +332,22 @@ int mayo_expand_sk(const mayo_params_t *p, const unsigned char *csk,
330
332
#endif
331
333
332
334
expand_P1_P2 (p , P , seed_pk );
333
- uint64_t * P2 = P + PARAM_P1_limbs (p );
334
-
335
335
#ifdef TARGET_BIG_ENDIAN
336
- for (int i = 0 ; i < ( param_P1_bytes + param_P2_bytes ) / 8 ; ++ i ) {
336
+ for (int i = 0 ; i < PARAM_P1_limbs ( p ) + PARAM_P2_limbs ( p ) ; ++ i ) {
337
337
P [i ] = BSWAP64 (P [i ]);
338
338
}
339
339
#endif
340
340
341
+ uint64_t * P2 = P + PARAM_P1_limbs (p );
342
+
341
343
uint64_t * P1 = P ;
342
344
343
345
// compute L_i = (P1 + P1^t)*O + P2
344
346
uint64_t * L = P2 ;
345
347
P1P1t_times_O (p , P1 , O , L );
346
348
347
349
#ifdef TARGET_BIG_ENDIAN
348
- for (int i = 0 ; i < ( param_P1_bytes + param_P2_bytes ) / 8 ; ++ i ) {
350
+ for (int i = 0 ; i < PARAM_P1_limbs ( p ) + PARAM_P2_limbs ( p ) ; ++ i ) {
349
351
P [i ] = BSWAP64 (P [i ]);
350
352
}
351
353
#endif
@@ -386,10 +388,6 @@ int mayo_sign_signature(const mayo_params_t *p, unsigned char *sig,
386
388
const int param_digest_bytes = PARAM_digest_bytes (p );
387
389
const int param_sk_seed_bytes = PARAM_sk_seed_bytes (p );
388
390
const int param_salt_bytes = PARAM_salt_bytes (p );
389
- #ifdef TARGET_BIG_ENDIAN
390
- const int param_P1_bytes = PARAM_P1_bytes (p );
391
- const int param_P2_bytes = PARAM_P2_bytes (p );
392
- #endif
393
391
394
392
ret = mayo_expand_sk (p , csk , & sk );
395
393
if (ret != MAYO_OK ) {
@@ -409,10 +407,10 @@ int mayo_sign_signature(const mayo_params_t *p, unsigned char *sig,
409
407
410
408
411
409
#ifdef TARGET_BIG_ENDIAN
412
- for (int i = 0 ; i < param_P1_bytes / 8 ; ++ i ) {
410
+ for (int i = 0 ; i < PARAM_P1_limbs ( p ) ; ++ i ) {
413
411
P1 [i ] = BSWAP64 (P1 [i ]);
414
412
}
415
- for (int i = 0 ; i < param_P2_bytes / 8 ; ++ i ) {
413
+ for (int i = 0 ; i < PARAM_P2_limbs ( p ) ; ++ i ) {
416
414
L [i ] = BSWAP64 (L [i ]);
417
415
}
418
416
#endif
@@ -631,9 +629,6 @@ int mayo_verify(const mayo_params_t *p, const unsigned char *m,
631
629
const int param_n = PARAM_n (p );
632
630
const int param_k = PARAM_k (p );
633
631
const int param_m_bytes = PARAM_m_bytes (p );
634
- #ifdef TARGET_BIG_ENDIAN
635
- const int param_P3_bytes = PARAM_P3_bytes (p );
636
- #endif
637
632
const int param_sig_bytes = PARAM_sig_bytes (p );
638
633
const int param_digest_bytes = PARAM_digest_bytes (p );
639
634
const int param_salt_bytes = PARAM_salt_bytes (p );
@@ -648,13 +643,13 @@ int mayo_verify(const mayo_params_t *p, const unsigned char *m,
648
643
uint64_t * P3 = P2 + PARAM_P2_limbs (p );
649
644
650
645
#ifdef TARGET_BIG_ENDIAN
651
- for (int i = 0 ; i < param_P1_bytes / 8 ; ++ i ) {
646
+ for (int i = 0 ; i < PARAM_P1_limbs ( p ) ; ++ i ) {
652
647
P1 [i ] = BSWAP64 (P1 [i ]);
653
648
}
654
- for (int i = 0 ; i < param_P2_bytes / 8 ; ++ i ) {
649
+ for (int i = 0 ; i < PARAM_P2_limbs ( p ) ; ++ i ) {
655
650
P2 [i ] = BSWAP64 (P2 [i ]);
656
651
}
657
- for (int i = 0 ; i < param_P3_bytes / 8 ; ++ i ) {
652
+ for (int i = 0 ; i < PARAM_P3_limbs ( p ) ; ++ i ) {
658
653
P3 [i ] = BSWAP64 (P3 [i ]);
659
654
}
660
655
#endif
0 commit comments