-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathquadsmaker.py
68 lines (55 loc) · 2.12 KB
/
quadsmaker.py
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""########################################################
########################################################
#
# Make a QUADS keyset
#
# Module name is 'quadsmaker'
#
# See grasp.py for license, copyright, and disclaimer.
#
########################################################
########################################################"""
import getpass
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import padding
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC
##########################################
# #
# Make a QUADS keyset #
# #
##########################################
secret_salt = b'\xf4tRj.t\xac\xce\xe1\x89\xf1\xfb\xc1\xc3L\xeb'
password = None
confirm = 1
print("Please enter the keying password for the domain.")
while password != confirm:
password = bytes(getpass.getpass(), 'utf-8')
confirm = bytes(getpass.getpass("Confirm: "), 'utf-8')
if password != confirm:
print("Mismatch, try again.")
if password == b'':
print("No keys will be generated")
else:
print("Password accepted")
kdf = PBKDF2HMAC(
algorithm=hashes.SHA256(),
length=32,
salt=secret_salt,
iterations=100000,
backend=default_backend()
)
backend = default_backend()
key = kdf.derive(password)
_skip = key[0]%10
iv = key[_skip:_skip+16]
#print("key="+str(key))
#print("iv="+str(iv))
file = open(r"quadsk.py","w")
file.write("key="+str(key)+"\n")
file.write("iv="+str(iv)+"\n")
file.close()
print("quadsk.py saved OK")