1-
21def pycryptodomex_examples ():
3- from Cryptodome .Cipher import DES , DES3 , ARC2 , ARC4 , Blowfish , AES
2+ from Cryptodome .Cipher import DES , DES3 , ARC2 , ARC4 , Blowfish , AES , CAST
43 from Cryptodome .Random import get_random_bytes
54
65 key = b'-8B key-'
@@ -23,6 +22,10 @@ def pycryptodomex_examples():
2322 cipher = Blowfish .new (key , Blowfish .MODE_CBC ) # Noncompliant {{Use a strong cipher algorithm.}}
2423 # ^^^^^^^^^^^^
2524
25+ key = os .urandom (16 )
26+ cipher = CAST .new (key , CAST .MODE_OPENPGP ) # Noncompliant {{Use a strong cipher algorithm.}}
27+ # ^^^^^^^^
28+
2629 key = b'Sixteen byte key'
2730 cipher = AES .new (key , AES .MODE_CCM ) # Compliant
2831
@@ -35,7 +38,7 @@ def pycryptodomex_examples():
3538
3639# pycryptodome is a drop-in replacement for pycrpypto, currently those two libraries are not differentiated
3740def pycroptodome_examples ():
38- from Crypto .Cipher import DES , DES3 , ARC2 , ARC4 , Blowfish , AES
41+ from Crypto .Cipher import DES , DES3 , ARC2 , ARC4 , Blowfish , AES , CAST , XOR
3942 from Crypto .Random import get_random_bytes
4043
4144 key = b'-8B key-'
@@ -55,9 +58,18 @@ def pycroptodome_examples():
5558 cipher = Blowfish .new (key , Blowfish .MODE_CBC ) # Noncompliant {{Use a strong cipher algorithm.}}
5659 # ^^^^^^^^^^^^
5760
61+ key = os .urandom (16 )
62+ cipher = CAST .new (key , CAST .MODE_OPENPGP ) # Noncompliant {{Use a strong cipher algorithm.}}
63+ # ^^^^^^^^
64+
65+ key = os .urandom (16 )
66+ cipher = XOR .new (key ) # Noncompliant {{Use a strong cipher algorithm.}}
67+ # ^^^^^^^
68+
5869def pyca_examples ():
5970 import os
6071 from cryptography .hazmat .primitives .ciphers import Cipher , algorithms , modes
72+ from cryptography .hazmat .decrepit .ciphers .algorithms import AnyAlgoFromDeprecitModule
6173 from cryptography .hazmat .backends import default_backend
6274
6375 key = os .urandom (16 )
@@ -69,6 +81,10 @@ def pyca_examples():
6981 # ^^^^^^^^^^^^^^^^^^^
7082 rc42 = Cipher (algorithms .ARC4 (key ), mode = None , backend = default_backend ()) # Noncompliant {{Use a strong cipher algorithm.}}
7183 # ^^^^^^^^^^^^^^^
84+ casts5 = Cipher (algorithms .CAST5 (key ), mode = None , backend = default_backend ()) # Noncompliant {{Use a strong cipher algorithm.}}
85+ # ^^^^^^^^^^^^^^^^
86+ deprecit = Cipher (AnyAlgoFromDeprecitModule (key ), mode = None , backend = default_backend ()) # Noncompliant {{Use a strong cipher algorithm.}}
87+ # ^^^^^^^^^^^^^^^^^^^^^^^^^
7288
7389def pydes_examples ():
7490 import pyDes ;
0 commit comments