summaryrefslogtreecommitdiff
path: root/set4
diff options
context:
space:
mode:
Diffstat (limited to 'set4')
-rw-r--r--set4/task27.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/set4/task27.c b/set4/task27.c
new file mode 100644
index 0000000..ae279cd
--- /dev/null
+++ b/set4/task27.c
@@ -0,0 +1,29 @@
+#include "../lib/lib.h"
+#include "../lib/lib2.h"
+#include "../lib/lib3.h"
+#include "../lib/lib4.h"
+#include <time.h>
+
+
+int main()
+{
+ unsigned int hex[5];
+ int i;
+ char text[] = "Rolling on the floor lauthing";
+ char *key = "ROFL";
+
+ sha1_hmac(hex, text, strlen(text), key, strlen(key));
+ for(i=0; i<5; i++) {
+ printf("%08x", hex[i]);
+ }
+ printf("\n");
+
+ if(sha1_hmac_verify(hex, text, strlen(text), key, strlen(key)))
+ printf("MACs are equal\n");
+
+ // tamper message change R to r
+ text[0] = 'r';
+
+ if(!sha1_hmac_verify(hex, text, strlen(text), key, strlen(key)))
+ printf("MACs of tampered message are NOT equal\n");
+}