wg: encoding: be more paranoid
Needless, but overkill can be fun. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
eb68ad0722
commit
7fe7f81088
1 changed files with 2 additions and 2 deletions
|
@ -102,10 +102,10 @@ bool key_from_hex(uint8_t key[static WG_KEY_LEN], const char *hex)
|
||||||
|
|
||||||
bool key_is_zero(const uint8_t key[static WG_KEY_LEN])
|
bool key_is_zero(const uint8_t key[static WG_KEY_LEN])
|
||||||
{
|
{
|
||||||
uint8_t acc = 0;
|
volatile uint8_t acc = 0;
|
||||||
for (unsigned int i = 0; i < WG_KEY_LEN; ++i) {
|
for (unsigned int i = 0; i < WG_KEY_LEN; ++i) {
|
||||||
acc |= key[i];
|
acc |= key[i];
|
||||||
__asm__ ("" : "=r" (acc) : "0" (acc));
|
__asm__ ("" : "=r" (acc) : "0" (acc));
|
||||||
}
|
}
|
||||||
return acc == 0;
|
return 1 & ((acc - 1) >> 8);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue