This commit is contained in:
Frank Denis
2015-11-26 19:07:37 +01:00
parent 23b4e21680
commit 457ff09ee7
+2 -19
View File
@@ -170,16 +170,8 @@ void
sodium_increment(unsigned char *n, const size_t nlen)
{
size_t i = 0U;
#if !defined(CPU_UNALIGNED_ACCESS) || !defined(NATIVE_LITTLE_ENDIAN) || defined(__EMSCRIPTEN__)
uint_fast16_t c = 1U;
#else
uint_fast64_t c = 1U;
for (; i < (nlen & ~0x3); i += 4U) {
c += (uint_fast64_t) *((const uint32_t *) (const void *) &n[i]);
*((uint32_t *) (void *) &n[i]) = (uint32_t) c;
c >>= 32;
}
#endif
for (; i < nlen; i++) {
c += (uint_fast16_t) n[i];
n[i] = (unsigned char) c;
@@ -191,17 +183,8 @@ void
sodium_add(unsigned char *a, const unsigned char *b, const size_t len)
{
size_t i = 0U;
#if !defined(CPU_UNALIGNED_ACCESS) || !defined(NATIVE_LITTLE_ENDIAN) || defined(__EMSCRIPTEN__)
uint_fast16_t c = 0U;
#else
uint_fast64_t c = 0U;
for (; i < (len & ~0x3); i += 4U) {
c += (uint_fast64_t) *((const uint32_t *) (const void *) &a[i]) +
(uint_fast64_t) *((const uint32_t *) (const void *) &b[i]);
*((uint32_t *) (void *) &a[i]) = (uint32_t) c;
c >>= 32;
}
#endif
for (; i < len; i++) {
c += (uint_fast16_t) a[i] + (uint_fast16_t) b[i];
a[i] = (unsigned char) c;