initial commit

This commit is contained in:
Dominik Moritz Roth 2021-09-20 11:32:55 +02:00
commit 0dabde6dad
3 changed files with 25 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*.pyc
__pycache__

0
README.md Normal file
View File

23
shark.py Normal file
View File

@ -0,0 +1,23 @@
import hashlib
import math
# Shark is a sha256+xor based encryption.
# I made it because I want to try to break it.
# (Precisely: Show it does not provide semantic security, because it is not IND-CPA-secure)
# This will work iff I succeed in building a PPT-discriminator for sha256 from randomness
# As my first approach this discriminator will be based on an LSTM-network.
def xor(ta,tb):
return bytes(a ^ b for a, b in zip(ta, tb))
def enc(plaintext, key, iv):
ciphertext = bytes()
bs = 256/8
for i in range(math.ceil(len(plaintext/bs))):
m = hashlib.sha256()
m.update(xor(key, iv + i.to_bytes(bs, byteorder='big')))
k = m.digest()
ciphertext += sxor(k, plaintext[bs*i:][:bs])
def dec(ciphertext, key, iv):
return enc(ciphertext, key, iv)