#include <stdlib.h>
+#include <stdio.h>
+#include <stdbool.h>
typedef unsigned char uc;
typedef unsigned __int128 uint128;
void addvector(int *r, const int *a, const int *b, size_t len)
{
- for(int *r2 = r; r2 < r + len;r2++, a++, b++)
- *r2 = *a + *b;
+ for(int *r2 = r; r2 < r + len; r2++)
+ *r2 = *a++ + *b++;
}
int memcmp(const void *s1, const void *s2, size_t n)
return memcmp(s3, s4, sizeof(uint128));
return memcmp(s3, s4, n % sizeof(uint128));
}
+
+int memcmp_consttime(const void *s1, const void *s2, size_t n)
+{
+ int returnvalue = 0;
+ for(uc *s3 = (uc*)s1, *s4 = (uc*)s2; s3 < (uc*)s1 + n; s3++, s4++)
+ if(*s3 != *s4 && returnvalue == 0)
+ returnvalue = *s3 - *s4;
+ return returnvalue;
+}