-
Notifications
You must be signed in to change notification settings - Fork 4
CMAC
Liesware edited this page Jan 28, 2019
·
5 revisions
In order to understand hex and type parameters read Hash
Description: Message authentication code based on block cipher.
Uses: When a block cipher is more readily available than a hash function
import socket
import json
import os,binascii
def sending(message):
ip = '127.0.0.1'
port = 6613
BUFFER_SIZE = 65536
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((ip, port))
s.send(message)
data = s.recv(BUFFER_SIZE)
print data
s.close()
return data
data_js='{"version":1,"algorithm":"CMAC","type":"string","plaintext":"Hello world!",\
"hex":0,"key":"0123456789ABCDEF0123456789ABCDEF","family":"aes"}'
sending(data_js)
Calculate CMAC-AES to string "Hello world!" with the key given.
On data_js["family"] can be one of {"aes", "rc6", "mars","serpent","twofish', "cast256"}
Json to HMAC string
{"version":1,"algorithm":"CMAC","type":"string","plaintext":"your string","hex":BOOL,
"key":"hex string","family":"block flavor"}
Json to HMAC file
{"version":1,"algorithm":"CMAC","type":"file","file":"your file",
"key":"hex string","family":"block flavor"}