Replace some memcpy() with a local loop
This commit is contained in:
parent
8deb15bd85
commit
d47cb42f5a
@ -214,8 +214,12 @@ addmul(unsigned char *c, const unsigned char *a, unsigned int xlen, const unsign
|
|||||||
A = _mm_loadu_si128((const __m128i *) a);
|
A = _mm_loadu_si128((const __m128i *) a);
|
||||||
} else {
|
} else {
|
||||||
CRYPTO_ALIGN(16) unsigned char padded[16];
|
CRYPTO_ALIGN(16) unsigned char padded[16];
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
memset(padded, 0, 16);
|
memset(padded, 0, 16);
|
||||||
memcpy(padded, a, xlen);
|
for (i = 0; i < xlen; i++) {
|
||||||
|
padded[i] = a[i];
|
||||||
|
}
|
||||||
A = _mm_load_si128((const __m128i *) padded);
|
A = _mm_load_si128((const __m128i *) padded);
|
||||||
}
|
}
|
||||||
A = _mm_shuffle_epi8(A, rev);
|
A = _mm_shuffle_epi8(A, rev);
|
||||||
|
@ -52,7 +52,9 @@ crypto_secretbox_detached(unsigned char *c, unsigned char *mac,
|
|||||||
crypto_onetimeauth_poly1305_KEYBYTES ? 1 : -1]);
|
crypto_onetimeauth_poly1305_KEYBYTES ? 1 : -1]);
|
||||||
crypto_onetimeauth_poly1305_init(&state, block0);
|
crypto_onetimeauth_poly1305_init(&state, block0);
|
||||||
|
|
||||||
memcpy(c, block0 + crypto_secretbox_ZEROBYTES, mlen0);
|
for (i = 0U; i < mlen0; i++) {
|
||||||
|
c[i] = block0[crypto_secretbox_ZEROBYTES + i];
|
||||||
|
}
|
||||||
sodium_memzero(block0, sizeof block0);
|
sodium_memzero(block0, sizeof block0);
|
||||||
if (mlen > mlen0) {
|
if (mlen > mlen0) {
|
||||||
crypto_stream_salsa20_xor_ic(c + mlen0, m + mlen0, mlen - mlen0,
|
crypto_stream_salsa20_xor_ic(c + mlen0, m + mlen0, mlen - mlen0,
|
||||||
@ -109,7 +111,9 @@ crypto_secretbox_open_detached(unsigned char *m, const unsigned char *c,
|
|||||||
if (mlen0 > 64U - crypto_secretbox_ZEROBYTES) {
|
if (mlen0 > 64U - crypto_secretbox_ZEROBYTES) {
|
||||||
mlen0 = 64U - crypto_secretbox_ZEROBYTES;
|
mlen0 = 64U - crypto_secretbox_ZEROBYTES;
|
||||||
}
|
}
|
||||||
memcpy(block0 + crypto_secretbox_ZEROBYTES, c, mlen0);
|
for (i = 0U; i < mlen0; i++) {
|
||||||
|
block0[crypto_secretbox_ZEROBYTES + i] = c[i];
|
||||||
|
}
|
||||||
crypto_stream_salsa20_xor(block0, block0,
|
crypto_stream_salsa20_xor(block0, block0,
|
||||||
crypto_secretbox_ZEROBYTES + mlen0,
|
crypto_secretbox_ZEROBYTES + mlen0,
|
||||||
n + 16, subkey);
|
n + 16, subkey);
|
||||||
|
Loading…
Reference in New Issue
Block a user