use GOST for random bytes generation

This commit is contained in:
vadzik 2024-04-14 15:54:14 +03:00
parent fc37723762
commit d8d820479e
3 changed files with 14 additions and 7 deletions

1
PATH Normal file
View File

@ -0,0 +1 @@
/home/Vadzik/Data/Maxim/University/ВКР/disk_eraser/venv/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin

View File

@ -1,8 +1,9 @@
import threading
import os
import pygost.gost3412 as gost
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
from cryptography.hazmat.backends import default_backend
# from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
# from cryptography.hazmat.backends import default_backend
erasing_methods = {
"2 прохода": {
@ -31,12 +32,17 @@ erasing_methods = {
def get_random_bytes(size):
seed=os.urandom(32)
backend = default_backend()
cipher = Cipher(algorithms.AES(seed), modes.CTR(b'\0'*16), backend=backend)
encryptor = cipher.encryptor()
# backend = default_backend()
# cipher = Cipher(algorithms.AES(seed), modes.CTR(b'\0'*16), backend=backend)
# encryptor = cipher.encryptor()
nulls=b'\0'*(size)
return encryptor.update(nulls)
enc = gost.GOST3412Kuznechik(seed)
rounds = int(size / 32)
data = b''
for i in range(512):
data += enc.encrypt(nulls)
return data
class Drive():
@ -84,7 +90,7 @@ class Drive():
else:
data = erasing_methods[method]["data"][i] * write_size
drive.write(data)
len_write += write_size
len_write += len(data)
cur_percent = len_write/self.capacity
if cur_percent - prev_percent > 0.01:
progressbar.set(cur_percent)

Binary file not shown.