SwiftGUI_Encryption 0.0.5__tar.gz → 0.0.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: SwiftGUI_Encryption
3
- Version: 0.0.5
3
+ Version: 0.0.6
4
4
  Summary: Useful encryption-features for SwiftGUI-applications based on PyCryptoDome
5
5
  License-Expression: Apache-2.0
6
6
  License-File: LICENSE
@@ -31,4 +31,15 @@ I let you use my encryption-schemes, so you won't have to dive deep into cryptog
31
31
 
32
32
  Also, this package can be used as an addon for SwiftGUI, but doesn't have to be.
33
33
 
34
+ # Installation
35
+ Open your terminal and execute this:
36
+ ```bash
37
+ pip install SwiftGUI_Encryption
38
+ ```
39
+
40
+ # Dependancies
41
+ This package wouldn't be possible without the following open-source packages:
42
+ - `PyCryptoDome`: A Python-package featuring a lot of cryptography algorithms
43
+ - `argon2pure`: A small package implementing the argon2-key-derivation algorithm
44
+
34
45
 
@@ -13,3 +13,14 @@ I let you use my encryption-schemes, so you won't have to dive deep into cryptog
13
13
 
14
14
  Also, this package can be used as an addon for SwiftGUI, but doesn't have to be.
15
15
 
16
+ # Installation
17
+ Open your terminal and execute this:
18
+ ```bash
19
+ pip install SwiftGUI_Encryption
20
+ ```
21
+
22
+ # Dependancies
23
+ This package wouldn't be possible without the following open-source packages:
24
+ - `PyCryptoDome`: A Python-package featuring a lot of cryptography algorithms
25
+ - `argon2pure`: A small package implementing the argon2-key-derivation algorithm
26
+
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "SwiftGUI_Encryption"
3
- version = "0.0.5"
3
+ version = "0.0.6"
4
4
  packages = [
5
5
  { include = "SwiftGUI_Encryption", from = "src" }
6
6
  ]
@@ -94,7 +94,7 @@ def encrypt(data: bytes, key: bytes, nonce: bytes, mac_len: int = 8) -> bytes:
94
94
  def decrypt(enc_data:bytes, key:bytes, nonce:bytes, mac_len: int = 8) -> bytes:
95
95
  """
96
96
  Decrypt some data.
97
- The tag needs to be appended to the data.
97
+ The tag needs to be appended to the front of the data.
98
98
 
99
99
  Raises a value-error if the data was manipulated (tag is invalid)
100
100
 
@@ -113,4 +113,3 @@ def decrypt(enc_data:bytes, key:bytes, nonce:bytes, mac_len: int = 8) -> bytes:
113
113
  crypter.verify(tag)
114
114
 
115
115
  return data
116
-
@@ -38,16 +38,13 @@ def encrypt_multilayer(data: bytes, *keys: bytes) -> bytes:
38
38
  A single AES-256-GCM-encryption is already very secure, even against quantumcomputers.
39
39
 
40
40
  VERY IMPORTANT:
41
- To attack even a 3-layer-encryption is basically impossible.
42
- So the attack will be on the keys, not the encryption.
43
- Make sure the keys are secure, they are the weakest link.
44
-
45
- Also, don't correlate the keys in any way.
46
- If you can calculate key2 from key1, it defies the whole reason for this multilayer-encryption.
41
+ Don't correlate the keys in any way.
42
+ If you calculate key2 from key1, you can just leave out key2.
43
+ DON'T DO SECURITY-BY-OBSCURITY!
47
44
 
48
45
  KINDA IMPORTANT:
49
- Using two keys is only a little better than one key, because someone could do a "meet-in-the-middle-attack".
50
- As a general rule, you should use an odd number of keys.
46
+ Using two keys is only a little more secure than one key, because someone could do a "meet-in-the-middle-attack".
47
+ As a general rule, you should only use an odd number of keys.
51
48
 
52
49
  TECHNICALITIES:
53
50
  Only the innermost encryption is using AES-GCM Mode. All other layers are AES-CTR.
@@ -60,14 +57,16 @@ def encrypt_multilayer(data: bytes, *keys: bytes) -> bytes:
60
57
  :return:
61
58
  """
62
59
  # GCM encryption
63
- data = encrypt_full(data, keys[0])
60
+ first_nonce = adv.random_key(NONCE_LEN)
61
+ nonce = first_nonce
62
+ data = adv.encrypt(data, keys[0], nonce)
64
63
 
65
64
  # CTR encryptions
66
65
  for key in keys[1:]:
67
- nonce = adv.random_key(12)
68
- data = nonce + adv.encrypt_CTR(data, key, nonce)
66
+ nonce = adv.make_hash(nonce)[:12]
67
+ data = adv.encrypt_CTR(data, key, nonce)
69
68
 
70
- return data
69
+ return first_nonce + data
71
70
 
72
71
  def decrypt_multilayer(data: bytes, *keys: bytes) -> bytes:
73
72
  """
@@ -77,13 +76,22 @@ def decrypt_multilayer(data: bytes, *keys: bytes) -> bytes:
77
76
 
78
77
  :return:
79
78
  """
79
+ first_nonce = data[:NONCE_LEN]
80
+ data = data[NONCE_LEN:]
81
+
82
+ nonce = first_nonce
83
+ nonces = list()
84
+
85
+ for i in range(len(keys) - 1):
86
+ nonce = adv.make_hash(nonce)[:12]
87
+ nonces.append(nonce)
88
+
80
89
  # CTR encryptions
81
- for key in keys[1:][::-1]:
82
- nonce = data[:12]
83
- data = adv.decrypt_CTR(data[12:], key, nonce)
90
+ for nonce, key in zip(nonces[::-1], keys[1:][::-1]):
91
+ data = adv.decrypt_CTR(data, key, nonce)
84
92
 
85
93
  # GCM encryption
86
- return decrypt_full(data, keys[0])
94
+ return adv.decrypt(data, keys[0], first_nonce)
87
95
 
88
96
  def encrypt_with_password(data: bytes, password: str, security_multiplier: int = 1) -> bytes:
89
97
  """