use GOST for random bytes generation
This commit is contained in:
parent
fc37723762
commit
d8d820479e
1
PATH
Normal file
1
PATH
Normal file
@ -0,0 +1 @@
|
|||||||
|
/home/Vadzik/Data/Maxim/University/ВКР/disk_eraser/venv/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin
|
||||||
@ -1,8 +1,9 @@
|
|||||||
import threading
|
import threading
|
||||||
import os
|
import os
|
||||||
|
import pygost.gost3412 as gost
|
||||||
|
|
||||||
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
|
# from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
|
||||||
from cryptography.hazmat.backends import default_backend
|
# from cryptography.hazmat.backends import default_backend
|
||||||
|
|
||||||
erasing_methods = {
|
erasing_methods = {
|
||||||
"2 прохода": {
|
"2 прохода": {
|
||||||
@ -31,12 +32,17 @@ erasing_methods = {
|
|||||||
|
|
||||||
def get_random_bytes(size):
|
def get_random_bytes(size):
|
||||||
seed=os.urandom(32)
|
seed=os.urandom(32)
|
||||||
backend = default_backend()
|
# backend = default_backend()
|
||||||
cipher = Cipher(algorithms.AES(seed), modes.CTR(b'\0'*16), backend=backend)
|
# cipher = Cipher(algorithms.AES(seed), modes.CTR(b'\0'*16), backend=backend)
|
||||||
encryptor = cipher.encryptor()
|
# encryptor = cipher.encryptor()
|
||||||
|
|
||||||
nulls=b'\0'*(size)
|
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():
|
class Drive():
|
||||||
|
|
||||||
@ -84,7 +90,7 @@ class Drive():
|
|||||||
else:
|
else:
|
||||||
data = erasing_methods[method]["data"][i] * write_size
|
data = erasing_methods[method]["data"][i] * write_size
|
||||||
drive.write(data)
|
drive.write(data)
|
||||||
len_write += write_size
|
len_write += len(data)
|
||||||
cur_percent = len_write/self.capacity
|
cur_percent = len_write/self.capacity
|
||||||
if cur_percent - prev_percent > 0.01:
|
if cur_percent - prev_percent > 0.01:
|
||||||
progressbar.set(cur_percent)
|
progressbar.set(cur_percent)
|
||||||
|
|||||||
BIN
pygost-5.13/dist/pygost-5.13-py3.12.egg
vendored
BIN
pygost-5.13/dist/pygost-5.13-py3.12.egg
vendored
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user