You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: python-checks/src/test/resources/checks/robustCipherAlgorithm.py
+17-17Lines changed: 17 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -3,23 +3,23 @@ def pycryptodomexExamples():
3
3
fromCryptodome.Randomimportget_random_bytes
4
4
5
5
key=b'-8B key-'
6
-
DES.new(key, DES.MODE_OFB) # Noncompliant {{DES works with 56-bit keys that allow attacks via exhaustive search.}}
6
+
DES.new(key, DES.MODE_OFB) # Noncompliant {{Use a strong cipher algorithm.}}
7
7
# ^^^^^^^
8
8
9
9
key=DES3.adjust_key_parity(get_random_bytes(24))
10
-
cipher=DES3.new(key, DES3.MODE_CFB) # Noncompliant {{Triple DES is vulnerable to meet-in-the-middle attacks.}}
10
+
cipher=DES3.new(key, DES3.MODE_CFB) # Noncompliant {{Use a strong cipher algorithm.}}
11
11
# ^^^^^^^^
12
12
13
13
key=b'Sixteen byte key'
14
-
cipher=ARC2.new(key, ARC2.MODE_CFB) # Noncompliant {{RC2 is vulnerable to a related-key attack.}}
14
+
cipher=ARC2.new(key, ARC2.MODE_CFB) # Noncompliant {{Use a strong cipher algorithm.}}
15
15
# ^^^^^^^^
16
16
17
17
key=b'Very long and confidential key'
18
-
cipher=ARC4.new(key) # Noncompliant {{RC4 is vulnerable to several attacks.}}
18
+
cipher=ARC4.new(key) # Noncompliant {{Use a strong cipher algorithm.}}
19
19
# ^^^^^^^^
20
20
21
21
key=b'An arbitrarily long key'
22
-
cipher=Blowfish.new(key, Blowfish.MODE_CBC) # Noncompliant {{Blowfish uses a 64-bit block size, which makes it vulnerable to birthday attacks.}}
22
+
cipher=Blowfish.new(key, Blowfish.MODE_CBC) # Noncompliant {{Use a strong cipher algorithm.}}
23
23
# ^^^^^^^^^^^^
24
24
25
25
key=b'Sixteen byte key'
@@ -38,20 +38,20 @@ def pycroptodomeExamples():
38
38
fromCrypto.Randomimportget_random_bytes
39
39
40
40
key=b'-8B key-'
41
-
DES.new(key, DES.MODE_OFB) # Noncompliant {{DES works with 56-bit keys that allow attacks via exhaustive search.}}
41
+
DES.new(key, DES.MODE_OFB) # Noncompliant {{Use a strong cipher algorithm.}}
42
42
# ^^^^^^^
43
43
44
44
key=DES3.adjust_key_parity(get_random_bytes(24))
45
-
cipher=DES3.new(key, DES3.MODE_CFB) # Noncompliant {{Triple DES is vulnerable to meet-in-the-middle attacks.}}
45
+
cipher=DES3.new(key, DES3.MODE_CFB) # Noncompliant {{Use a strong cipher algorithm.}}
46
46
# ^^^^^^^^
47
47
key=b'Sixteen byte key'
48
-
cipher=ARC2.new(key, ARC2.MODE_CFB) # Noncompliant {{RC2 is vulnerable to a related-key attack.}}
48
+
cipher=ARC2.new(key, ARC2.MODE_CFB) # Noncompliant {{Use a strong cipher algorithm.}}
49
49
# ^^^^^^^^
50
50
key=b'Very long and confidential key'
51
-
cipher=ARC4.new(key) # Noncompliant {{RC4 is vulnerable to several attacks.}}
51
+
cipher=ARC4.new(key) # Noncompliant {{Use a strong cipher algorithm.}}
52
52
# ^^^^^^^^
53
53
key=b'An arbitrarily long key'
54
-
cipher=Blowfish.new(key, Blowfish.MODE_CBC) # Noncompliant {{Blowfish uses a 64-bit block size, which makes it vulnerable to birthday attacks.}}
54
+
cipher=Blowfish.new(key, Blowfish.MODE_CBC) # Noncompliant {{Use a strong cipher algorithm.}}
55
55
# ^^^^^^^^^^^^
56
56
57
57
defpycaExamples():
@@ -62,23 +62,23 @@ def pycaExamples():
62
62
key=os.urandom(16)
63
63
iv=os.urandom(16)
64
64
65
-
tdes4=Cipher(algorithms.TripleDES(key), mode=None, backend=default_backend()) # Noncompliant {{Triple DES is vulnerable to meet-in-the-middle attacks.}}
65
+
tdes4=Cipher(algorithms.TripleDES(key), mode=None, backend=default_backend()) # Noncompliant {{Use a strong cipher algorithm.}}
66
66
# ^^^^^^^^^^^^^^^^^^^^
67
-
bf3=Cipher(algorithms.Blowfish(key), mode=None, backend=default_backend()) # Noncompliant {{Blowfish uses a 64-bit block size, which makes it vulnerable to birthday attacks.}}
67
+
bf3=Cipher(algorithms.Blowfish(key), mode=None, backend=default_backend()) # Noncompliant {{Use a strong cipher algorithm.}}
68
68
# ^^^^^^^^^^^^^^^^^^^
69
-
rc42=Cipher(algorithms.ARC4(key), mode=None, backend=default_backend()) # Noncompliant {{RC4 is vulnerable to several attacks.}}
69
+
rc42=Cipher(algorithms.ARC4(key), mode=None, backend=default_backend()) # Noncompliant {{Use a strong cipher algorithm.}}
70
70
# ^^^^^^^^^^^^^^^
71
71
72
72
defpydesExamples():
73
73
importpyDes;
74
74
75
-
des1=pyDes.des('ChangeIt') # Noncompliant {{DES works with 56-bit keys that allow attacks via exhaustive search.}}
75
+
des1=pyDes.des('ChangeIt') # Noncompliant {{Use a strong cipher algorithm.}}
76
76
# ^^^^^^^^^
77
-
des2=pyDes.des('ChangeIt', pyDes.CBC, "\0\0\0\0\0\0\0\0", pad=None, padmode=pyDes.PAD_PKCS5) # Noncompliant {{DES works with 56-bit keys that allow attacks via exhaustive search.}}
tdes1=pyDes.triple_des('ChangeItWithYourKey!!!!!') # Noncompliant {{Triple DES is vulnerable to meet-in-the-middle attacks.}}
79
+
tdes1=pyDes.triple_des('ChangeItWithYourKey!!!!!') # Noncompliant {{Use a strong cipher algorithm.}}
80
80
# ^^^^^^^^^^^^^^^^
81
-
tdes2=pyDes.triple_des('ChangeItWithYourKey!!!!!', pyDes.CBC, "\0\0\0\0\0\0\0\0", pad=None, padmode=pyDes.PAD_PKCS5) # Noncompliant {{Triple DES is vulnerable to meet-in-the-middle attacks.}}
0 commit comments