- Updated pdf(now with warnings for compiler flags).
- Added the optional assignment 2.e.
- Removed the unworking code for exercise 1.
- char a = 0;
- magic_function();
- char b = 0;
- printf("%p\n", &a);
- printf("%p\n", &b);
-
+ printf("Ik snap hier nog even niks van...\n");
+#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)
{
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)
}
int memcmp(const void *s1, const void *s2, size_t n)
return memcmp(s3, s4, sizeof(uint128));
return memcmp(s3, s4, n % sizeof(uint128));
}
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;
+}
+++ /dev/null
-#include <stdio.h>
-
-void magic_function()
-{
- char a = 0;
- a = a+1;
-}