forked from CyberHashira/Learn_OpenSSL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMAC_Using_OpenSSL.txt
36 lines (24 loc) · 1.24 KB
/
MAC_Using_OpenSSL.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# Simple MAC
openssl rand -hex -out key 32
echo -n `cat message.txt``cat key` | openssl sha256
HMAC (keyed Hash based Message Authentication Code)
# Generating a key
openssl rand -out key 16
# Display binary data in Hex format
xxd -p key
# Generate SHA1_HMAC
openssl sha1 -hmac 1130ba6fcfbacd5e5a6d3645314e6e93 -out earth.sha1hmac Earth.txt
# Generate SHA256_HMAC
openssl sha256 -hmac 1130ba6fcfbacd5e5a6d3645314e6e93 -out earth.sha256hmac Earth.txt
# Generating SHA1_HMAC using 'openssl dgst'
openssl dgst -sha1 -hmac 1130ba6fcfbacd5e5a6d3645314e6e93 Earth.txt
# Generating SHA1_HMAC using 'openssl dgst' and outputing to a file.
openssl dgst -sha1 -hmac 1130ba6fcfbacd5e5a6d3645314e6e93 -out earth.sha1hmac Earth.txt
# Generating SHA256_HMAC using 'openssl dgst'
openssl dgst -sha256 -hmac 1130ba6fcfbacd5e5a6d3645314e6e93 Earth.txt
# Alternate way to generate HMAC
openssl dgst -mac hmac -sha1 -macopt hexkey:`xxd -p key` Earth.txt
openssl dgst -mac hmac -sha256 -macopt hexkey:`xxd -p key` Earth.txt
# Generating CMAC digest
openssl dgst -mac cmac -macopt cipher:aes-128-cbc -macopt hexkey:`xxd -p key` -sha1 Earth.txt
openssl dgst -mac cmac -macopt cipher:aes-128-cbc -macopt hexkey:`xxd -p key` -sha256 Earth.txt