summaryrefslogtreecommitdiff
path: root/lib/lib7.c
diff options
context:
space:
mode:
authorBenedict <benedict@0xb8000.de>2017-01-26 12:47:42 +0100
committerBenedict <benedict@0xb8000.de>2017-02-21 13:00:27 +0100
commit18acbfa8d29fd1ca9c90fb252b735b2901bbe7fa (patch)
tree9e994cceb6a3e66eb2e7a11ea79734de0bb02f3f /lib/lib7.c
parent96447557db2f8a3c2e5f4c32f0cc9d3fb2d5582f (diff)
set7: task50: completed
Diffstat (limited to 'lib/lib7.c')
-rw-r--r--lib/lib7.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/lib7.c b/lib/lib7.c
new file mode 100644
index 0000000..b3e05da
--- /dev/null
+++ b/lib/lib7.c
@@ -0,0 +1,13 @@
+#include "lib7.h"
+#include "lib2.h"
+
+int cbc_mac(char *msg, unsigned int msg_len, char *iv, char *key, char *mac)
+{
+ int padding_len = 0;
+
+ char *msg_padded = __pkcs7_padding(msg, msg_len, 16, &padding_len);
+ char *res = malloc(msg_len+padding_len);
+ aes_cbc(msg_padded, msg_len+padding_len, res, key, iv, 1);
+ char *ciphertext = malloc(msg_len+padding_len);
+ memcpy(mac, &res[msg_len+padding_len-16], 16);
+}