mirror of
https://github.com/github/codeql.git
synced 2026-05-03 04:39:29 +02:00
Python: Rewrite py/weak-crypto-key tests
* Removed backend arugment that is not required * Added DSA constants (they are just accidentially the same as RSA right now) * Removed FakeWeakEllipticCurve and used a real weak elliptic curve instead
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
| weak_crypto.py:67:1:67:30 | ControlFlowNode for dsa_gen_key() | Creation of an DSA key uses $@ bits, which is below 2048 and considered breakable. | weak_crypto.py:12:12:12:15 | ControlFlowNode for IntegerLiteral | 1024 |
|
||||
| weak_crypto.py:68:1:68:28 | ControlFlowNode for ec_gen_key() | Creation of an ECC key uses $@ bits, which is below 224 and considered breakable. | weak_crypto.py:21:11:21:33 | ControlFlowNode for FakeWeakEllipticCurve() | 160 |
|
||||
| weak_crypto.py:69:1:69:37 | ControlFlowNode for rsa_gen_key() | Creation of an RSA key uses $@ bits, which is below 2048 and considered breakable. | weak_crypto.py:12:12:12:15 | ControlFlowNode for IntegerLiteral | 1024 |
|
||||
| weak_crypto.py:71:1:71:39 | ControlFlowNode for dsa_gen_key() | Creation of an DSA key uses $@ bits, which is below 2048 and considered breakable. | weak_crypto.py:12:12:12:15 | ControlFlowNode for IntegerLiteral | 1024 |
|
||||
| weak_crypto.py:72:1:72:34 | ControlFlowNode for ec_gen_key() | Creation of an ECC key uses $@ bits, which is below 224 and considered breakable. | weak_crypto.py:21:11:21:33 | ControlFlowNode for FakeWeakEllipticCurve() | 160 |
|
||||
| weak_crypto.py:73:1:73:46 | ControlFlowNode for rsa_gen_key() | Creation of an RSA key uses $@ bits, which is below 2048 and considered breakable. | weak_crypto.py:12:12:12:15 | ControlFlowNode for IntegerLiteral | 1024 |
|
||||
| weak_crypto.py:75:1:75:22 | ControlFlowNode for Attribute() | Creation of an DSA key uses $@ bits, which is below 2048 and considered breakable. | weak_crypto.py:12:12:12:15 | ControlFlowNode for IntegerLiteral | 1024 |
|
||||
| weak_crypto.py:76:1:76:22 | ControlFlowNode for Attribute() | Creation of an RSA key uses $@ bits, which is below 2048 and considered breakable. | weak_crypto.py:12:12:12:15 | ControlFlowNode for IntegerLiteral | 1024 |
|
||||
| weak_crypto.py:68:1:68:21 | ControlFlowNode for dsa_gen_key() | Creation of an DSA key uses $@ bits, which is below 2048 and considered breakable. | weak_crypto.py:16:12:16:15 | ControlFlowNode for IntegerLiteral | 1024 |
|
||||
| weak_crypto.py:69:1:69:19 | ControlFlowNode for ec_gen_key() | Creation of an ECC key uses $@ bits, which is below 224 and considered breakable. | weak_crypto.py:22:11:22:24 | ControlFlowNode for Attribute() | 163 |
|
||||
| weak_crypto.py:70:1:70:28 | ControlFlowNode for rsa_gen_key() | Creation of an RSA key uses $@ bits, which is below 2048 and considered breakable. | weak_crypto.py:12:12:12:15 | ControlFlowNode for IntegerLiteral | 1024 |
|
||||
| weak_crypto.py:72:1:72:30 | ControlFlowNode for dsa_gen_key() | Creation of an DSA key uses $@ bits, which is below 2048 and considered breakable. | weak_crypto.py:16:12:16:15 | ControlFlowNode for IntegerLiteral | 1024 |
|
||||
| weak_crypto.py:73:1:73:25 | ControlFlowNode for ec_gen_key() | Creation of an ECC key uses $@ bits, which is below 224 and considered breakable. | weak_crypto.py:22:11:22:24 | ControlFlowNode for Attribute() | 163 |
|
||||
| weak_crypto.py:74:1:74:37 | ControlFlowNode for rsa_gen_key() | Creation of an RSA key uses $@ bits, which is below 2048 and considered breakable. | weak_crypto.py:12:12:12:15 | ControlFlowNode for IntegerLiteral | 1024 |
|
||||
| weak_crypto.py:76:1:76:22 | ControlFlowNode for Attribute() | Creation of an DSA key uses $@ bits, which is below 2048 and considered breakable. | weak_crypto.py:16:12:16:15 | ControlFlowNode for IntegerLiteral | 1024 |
|
||||
| weak_crypto.py:77:1:77:22 | ControlFlowNode for Attribute() | Creation of an RSA key uses $@ bits, which is below 2048 and considered breakable. | weak_crypto.py:12:12:12:15 | ControlFlowNode for IntegerLiteral | 1024 |
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from cryptography.hazmat import backends
|
||||
from cryptography.hazmat.primitives.asymmetric import ec, dsa, rsa
|
||||
|
||||
#Crypto and Cryptodome have same API
|
||||
# Crypto and Cryptodome have same API
|
||||
if random():
|
||||
from Crypto.PublicKey import DSA
|
||||
from Crypto.PublicKey import RSA
|
||||
@@ -12,13 +12,14 @@ else:
|
||||
RSA_WEAK = 1024
|
||||
RSA_OK = 2048
|
||||
RSA_STRONG = 3076
|
||||
|
||||
DSA_WEAK = 1024
|
||||
DSA_OK = 2048
|
||||
DSA_STRONG = 3076
|
||||
|
||||
BIG = 10000
|
||||
|
||||
class FakeWeakEllipticCurve:
|
||||
name = "fake"
|
||||
key_size = 160
|
||||
|
||||
EC_WEAK = FakeWeakEllipticCurve()
|
||||
EC_WEAK = ec.SECT163K1() # has key size of 163
|
||||
EC_OK = ec.SECP224R1()
|
||||
EC_STRONG = ec.SECP384R1()
|
||||
EC_BIG = ec.SECT571R1()
|
||||
@@ -27,50 +28,50 @@ dsa_gen_key = dsa.generate_private_key
|
||||
ec_gen_key = ec.generate_private_key
|
||||
rsa_gen_key = rsa.generate_private_key
|
||||
|
||||
default = backends.default_backend()
|
||||
|
||||
#Strong and OK keys.
|
||||
|
||||
dsa_gen_key(key_size=RSA_OK, backend=default)
|
||||
dsa_gen_key(key_size=RSA_STRONG, backend=default)
|
||||
dsa_gen_key(key_size=BIG, backend=default)
|
||||
ec_gen_key(curve=EC_OK, backend=default)
|
||||
ec_gen_key(curve=EC_STRONG, backend=default)
|
||||
ec_gen_key(curve=EC_BIG, backend=default)
|
||||
rsa_gen_key(public_exponent=65537, key_size=RSA_OK, backend=default)
|
||||
rsa_gen_key(public_exponent=65537, key_size=RSA_STRONG, backend=default)
|
||||
rsa_gen_key(public_exponent=65537, key_size=BIG, backend=default)
|
||||
# Strong and OK keys.
|
||||
|
||||
dsa_gen_key(key_size=DSA_OK)
|
||||
dsa_gen_key(key_size=DSA_STRONG)
|
||||
dsa_gen_key(key_size=BIG)
|
||||
ec_gen_key(curve=EC_OK)
|
||||
ec_gen_key(curve=EC_STRONG)
|
||||
ec_gen_key(curve=EC_BIG)
|
||||
rsa_gen_key(public_exponent=65537, key_size=RSA_OK)
|
||||
rsa_gen_key(public_exponent=65537, key_size=RSA_STRONG)
|
||||
rsa_gen_key(public_exponent=65537, key_size=BIG)
|
||||
|
||||
DSA.generate(bits=RSA_OK)
|
||||
DSA.generate(bits=RSA_STRONG)
|
||||
RSA.generate(bits=RSA_OK)
|
||||
RSA.generate(bits=RSA_STRONG)
|
||||
|
||||
dsa_gen_key(RSA_OK, default)
|
||||
dsa_gen_key(RSA_STRONG, default)
|
||||
dsa_gen_key(BIG, default)
|
||||
ec_gen_key(EC_OK, default)
|
||||
ec_gen_key(EC_STRONG, default)
|
||||
ec_gen_key(EC_BIG, default)
|
||||
rsa_gen_key(65537, RSA_OK, default)
|
||||
rsa_gen_key(65537, RSA_STRONG, default)
|
||||
rsa_gen_key(65537, BIG, default)
|
||||
dsa_gen_key(DSA_OK)
|
||||
dsa_gen_key(DSA_STRONG)
|
||||
dsa_gen_key(BIG)
|
||||
ec_gen_key(EC_OK)
|
||||
ec_gen_key(EC_STRONG)
|
||||
ec_gen_key(EC_BIG)
|
||||
rsa_gen_key(65537, RSA_OK)
|
||||
rsa_gen_key(65537, RSA_STRONG)
|
||||
rsa_gen_key(65537, BIG)
|
||||
|
||||
DSA.generate(RSA_OK)
|
||||
DSA.generate(RSA_STRONG)
|
||||
DSA.generate(DSA_OK)
|
||||
DSA.generate(DSA_STRONG)
|
||||
RSA.generate(RSA_OK)
|
||||
RSA.generate(RSA_STRONG)
|
||||
|
||||
|
||||
# Weak keys
|
||||
|
||||
dsa_gen_key(RSA_WEAK, default)
|
||||
ec_gen_key(EC_WEAK, default)
|
||||
rsa_gen_key(65537, RSA_WEAK, default)
|
||||
dsa_gen_key(DSA_WEAK)
|
||||
ec_gen_key(EC_WEAK)
|
||||
rsa_gen_key(65537, RSA_WEAK)
|
||||
|
||||
dsa_gen_key(key_size=RSA_WEAK, default)
|
||||
ec_gen_key(curve=EC_WEAK, default)
|
||||
rsa_gen_key(65537, key_size=RSA_WEAK, default)
|
||||
dsa_gen_key(key_size=DSA_WEAK)
|
||||
ec_gen_key(curve=EC_WEAK)
|
||||
rsa_gen_key(65537, key_size=RSA_WEAK)
|
||||
|
||||
DSA.generate(RSA_WEAK)
|
||||
DSA.generate(DSA_WEAK)
|
||||
RSA.generate(RSA_WEAK)
|
||||
|
||||
Reference in New Issue
Block a user