Przeglądaj źródła

Renamed local variable to avoid a warning about a redefinition; also disabled the MSVC warning C4146 (it is raised whenever negation is applied on an unsigned type, but this has a portable and standard behaviour, and there are good reasons to do that).

master
Thomas Pornin 5 lat temu
rodzic
commit
7175413a5c
4 zmienionych plików z 28 dodań i 18 usunięć
  1. +6
    -1
      crypto_sign/falcon-1024/clean/Makefile.Microsoft_nmake
  2. +8
    -8
      crypto_sign/falcon-1024/clean/common.c
  3. +6
    -1
      crypto_sign/falcon-512/clean/Makefile.Microsoft_nmake
  4. +8
    -8
      crypto_sign/falcon-512/clean/common.c

+ 6
- 1
crypto_sign/falcon-1024/clean/Makefile.Microsoft_nmake Wyświetl plik

@@ -3,7 +3,12 @@

LIBRARY=libfalcon-1024_clean.lib
OBJECTS=codec.obj common.obj fft.obj fpr.obj keygen.obj pqclean.obj rng.obj sign.obj vrfy.obj
CFLAGS=/nologo /I ..\..\..\common /W4 /WX

# Warning C4146 is raised when a unary minus operator is applied to an
# unsigned type; this has nonetheless been standard and portable for as
# long as there has been a C standard, and we do that a lot, especially
# for constant-time computations. Thus, we disable that spurious warning.
CFLAGS=/nologo /I ..\..\..\common /W4 /wd4146 /WX

all: $(LIBRARY)



+ 8
- 8
crypto_sign/falcon-1024/clean/common.c Wyświetl plik

@@ -140,7 +140,7 @@ PQCLEAN_FALCON1024_CLEAN_hash_to_point(
v = 0;
for (u = 0; u < m; u ++) {
uint16_t *s, *d;
unsigned j, sv, dv, m;
unsigned j, sv, dv, mk;

if (u < n) {
s = &x[u];
@@ -160,11 +160,11 @@ PQCLEAN_FALCON1024_CLEAN_hash_to_point(
/*
* We increment v for the next iteration, but
* only if the source value is valid. The mask
* 'm' is -1 if the value is valid, 0 otherwise,
* so we _subtract_ m.
* 'mk' is -1 if the value is valid, 0 otherwise,
* so we _subtract_ mk.
*/
m = (sv >> 15) - 1U;
v -= m;
mk = (sv >> 15) - 1U;
v -= mk;

/*
* In this loop we consider jumps by p slots; if
@@ -190,10 +190,10 @@ PQCLEAN_FALCON1024_CLEAN_hash_to_point(
* The swap should be performed only if the source
* is valid AND the jump j has its 'p' bit set.
*/
m &= -(((j & p) + 0x1FF) >> 9);
mk &= -(((j & p) + 0x1FF) >> 9);

*s = (uint16_t)(sv ^ (m & (sv ^ dv)));
*d = (uint16_t)(dv ^ (m & (sv ^ dv)));
*s = (uint16_t)(sv ^ (mk & (sv ^ dv)));
*d = (uint16_t)(dv ^ (mk & (sv ^ dv)));
}
}



+ 6
- 1
crypto_sign/falcon-512/clean/Makefile.Microsoft_nmake Wyświetl plik

@@ -3,7 +3,12 @@

LIBRARY=libfalcon-512_clean.lib
OBJECTS=codec.obj common.obj fft.obj fpr.obj keygen.obj pqclean.obj rng.obj sign.obj vrfy.obj
CFLAGS=/nologo /I ..\..\..\common /W4 /WX

# Warning C4146 is raised when a unary minus operator is applied to an
# unsigned type; this has nonetheless been standard and portable for as
# long as there has been a C standard, and we do that a lot, especially
# for constant-time computations. Thus, we disable that spurious warning.
CFLAGS=/nologo /I ..\..\..\common /W4 /wd4146 /WX

all: $(LIBRARY)



+ 8
- 8
crypto_sign/falcon-512/clean/common.c Wyświetl plik

@@ -140,7 +140,7 @@ PQCLEAN_FALCON512_CLEAN_hash_to_point(
v = 0;
for (u = 0; u < m; u ++) {
uint16_t *s, *d;
unsigned j, sv, dv, m;
unsigned j, sv, dv, mk;

if (u < n) {
s = &x[u];
@@ -160,11 +160,11 @@ PQCLEAN_FALCON512_CLEAN_hash_to_point(
/*
* We increment v for the next iteration, but
* only if the source value is valid. The mask
* 'm' is -1 if the value is valid, 0 otherwise,
* so we _subtract_ m.
* 'mk' is -1 if the value is valid, 0 otherwise,
* so we _subtract_ mk.
*/
m = (sv >> 15) - 1U;
v -= m;
mk = (sv >> 15) - 1U;
v -= mk;

/*
* In this loop we consider jumps by p slots; if
@@ -190,10 +190,10 @@ PQCLEAN_FALCON512_CLEAN_hash_to_point(
* The swap should be performed only if the source
* is valid AND the jump j has its 'p' bit set.
*/
m &= -(((j & p) + 0x1FF) >> 9);
mk &= -(((j & p) + 0x1FF) >> 9);

*s = (uint16_t)(sv ^ (m & (sv ^ dv)));
*d = (uint16_t)(dv ^ (m & (sv ^ dv)));
*s = (uint16_t)(sv ^ (mk & (sv ^ dv)));
*d = (uint16_t)(dv ^ (mk & (sv ^ dv)));
}
}



Ładowanie…
Anuluj
Zapisz