-
Notifications
You must be signed in to change notification settings - Fork 4
Block ciphers
In order to understand hex and type parameters read Hash
In order to understand encryption and decryption read Stream
Description: Block cipher and AES winner.
Key:128, 192, 256 bits.
Iv: 128 bits.
Uses: General propuse, Performance is impportant, FIPS 197, NIST.
Description: Block cipher and AES finalist.
Key: 128, 192, 256 bits.
Iv: 128 bits.
Uses: General propuse, alternative to AES.
Description: Block cipher and AES finalist.
Key: 128, 192, 256 bits.
Iv: 128 bits.
Uses: General propuse, alternative to AES.
Description: Block cipher and AES finalist.
Key: 128, 192, 256 bits.
Iv: 128 bits.
Uses: General propuse, alternative to AES.
Description: Block cipher and AES finalist.
Key: 128, 192, 256 bits.
Iv: 128 bits.
Uses: General propuse, alternative to AES.
Description: Block cipher and AES finalist.
Key: 256 bits.
Iv: 128 bits.
Uses: General propuse, alternative to AES.
Description: Block cipher, The cipher has been approved for use by the ISO/IEC, the European Union's NESSIE project, the Japanese CRYPTREC.
Key: 128, 192, 256 bits.
Iv: 128 bits.
Uses: General propuse, alternative to AES.
Key: 128, 192, 256 bits.
Iv: 128 bits.
Uses: IoT
Key: 128 bits.
Iv: 64 bits.
Uses: IoT
spec
Description: Block cipher mode
Uses: Performance is important.
Description: Block cipher mode
Uses: Authenticated encryption.
- It only support "type":"string"
- It doesn't support "algorithm":"SIMECK64"
#!/usr/bin/env python
import requests
import json
import os,binascii
def sending(message):
url = 'http://127.0.0.1:6613/'
response = requests.post(url, data=message)
print response.content
return response.content
def stream(data_js):
req=json.loads(data_js)
print "Enc \n " + json.dumps(req) +"\n"
data_js_n=sending(json.dumps(req))
answ=json.loads(data_js_n)
print "Recived enc: \n" + (json.dumps(answ)) +"\n\n\n"
dec='{"algorithm":"AES","plaintext":"","iv":"b05691ef92cb9c9bb05691ef92cb9c9b",\
"version":1,"key":"b05691ef92cb9c9bb05691ef92cb9c9b","operation":"dec","type":"string", "mode":"ctr"}'
req=json.loads(dec)
req["plaintext"]=answ["result"]
print "Dec \n " + json.dumps(req) +"\n"
data_js_n=sending(json.dumps(req))
answ2=json.loads(data_js_n)
print "Recived dec: \n" + (json.dumps(answ2)) +"\n\n\n"
data_js='{ "version": 1 , "algorithm":"AES" , "type":"string", "plaintext": "Hello world!", "hex": 0,"operation":"enc",\
"key":"b05691ef92cb9c9bb05691ef92cb9c9b","iv":"b05691ef92cb9c9bb05691ef92cb9c9b", "mode":"ctr" }'
stream(data_js)
In this example we encrypt and decrypt Hello world! string using AES with the key and iv given in CTR mode.
On data_js["algorithm"] can be one of {AES, RC6, MARS, Twofish, SERPENT, CAST256, CAMELLIA, SPECK128, SIMECK64 }
#!/usr/bin/env python
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)
s.close()
return data
def stream(data_js):
req=json.loads(data_js)
print "Enc \n " + json.dumps(req) +"\n"
data_js_n=sending(json.dumps(req))
answ=json.loads(data_js_n)
print "Recived enc: \n" + (json.dumps(answ)) +"\n\n\n"
dec='{"algorithm":"AES","plaintext":"","iv":"b05691ef92cb9c9bb05691ef92cb9c9b",\
"version":1,"key":"b05691ef92cb9c9bb05691ef92cb9c9b","operation":"dec","type":"string", "mode":"gcm" ,"adata":"ABCD"}'
req=json.loads(dec)
req["plaintext"]=answ["result"]
print "Dec \n " + json.dumps(req) +"\n"
data_js_n=sending(json.dumps(req))
answ2=json.loads(data_js_n)
print "Recived dec: \n" + (json.dumps(answ2)) +"\n\n\n"
data_js='{ "version": 1 , "algorithm":"AES" , "type":"string", "plaintext": "Hello world!", "hex": 0,"operation":"enc",\
"key":"b05691ef92cb9c9bb05691ef92cb9c9b","iv":"b05691ef92cb9c9bb05691ef92cb9c9b", "mode":"gcm" ,"adata":"ABCD"}'
stream(data_js)
In this example we encrypt and decrypt Hello world! string using AES with the key,iv,adata given in GCM mode.
On data_js["algorithm"] can be one of {AES, RC6, MARS, Twofish, SERPENT, CAST256, CAMELLIA, SPECK128}
Json to enc string (key and iv depends on algorithm you chose) in CTR mode
{ "version": 1 , "algorithm":"block flavor" , "type":"string", "plaintext": "your string", "hex":BOOL,
"operation":"enc", "key":"Hex stringsize=32-64","iv":"Hex stringsize=16-32", "mode":"ctr"}
Json to dec string (key and iv depends on algorithm you chose) in CTR mode
{ "version": 1 , "algorithm":"block flavor" , "type":"string", "plaintext": "your hex enc string ",
"operation":"dec", "key":"Hex stringsize=32-64","iv":"Hex stringsize=16-32", "mode":"ctr"}
-
To enc/dec a file you need to change "type":"string" -> "type":"file" , "plaintext": "your hex enc string " -> "file":"your file"
-
To use enc/dec GCM mode you need to change "mode":"ctr"->"mode":"gcm" , add "adata":"your string" and "hex" parameters
-
"hex" parameter apply for "string" and "adata" parameter