Skip to content

Commit b658909

Browse files
committed
Drop cryptography<2.0.0 (2017)
1 parent c1efbc6 commit b658909

File tree

4 files changed

+12
-61
lines changed

4 files changed

+12
-61
lines changed

.travis.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,6 @@ matrix:
2626
env:
2727
- TOXENV=py27-linux_non_root,codecov
2828

29-
- os: linux
30-
python: 2.7
31-
env:
32-
- TOXENV=py27-linux_non_root_old-cryptography,codecov
33-
3429
- os: linux
3530
dist: xenial
3631
python: 3.8

scapy/config.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -387,17 +387,6 @@ def isCryptographyValid():
387387
return _version_checker(cryptography, (1, 7))
388388

389389

390-
def isCryptographyRecent():
391-
"""
392-
Check if the cryptography library is recent (2.0 and later)
393-
"""
394-
try:
395-
import cryptography
396-
except ImportError:
397-
return False
398-
return _version_checker(cryptography, (2, 0))
399-
400-
401390
def isCryptographyAdvanced():
402391
"""
403392
Check if the cryptography library is present, and if it supports X25519,
@@ -651,8 +640,7 @@ class Conf(ConfClass):
651640
'tftp', 'vrrp', 'vxlan', 'x509', 'zigbee']
652641
contribs = dict()
653642
crypto_valid = isCryptographyValid()
654-
crypto_valid_recent = isCryptographyRecent()
655-
crypto_valid_advanced = crypto_valid_recent and isCryptographyAdvanced()
643+
crypto_valid_advanced = isCryptographyAdvanced()
656644
fancy_prompt = True
657645
auto_crop_tables = True
658646
recv_poll_rate = 0.05

scapy/layers/tls/cert.py

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
from cryptography.hazmat.backends import default_backend
5252
from cryptography.hazmat.primitives import serialization
5353
from cryptography.hazmat.primitives.asymmetric import rsa, ec
54-
if conf.crypto_valid_recent:
5554
from cryptography.hazmat.backends.openssl.ec import InvalidSignature
5655

5756

@@ -331,16 +330,11 @@ def encrypt(self, msg, h="sha256", **kwargs):
331330
@crypto_validator
332331
def verify(self, msg, sig, h="sha256", **kwargs):
333332
# 'sig' should be a DER-encoded signature, as per RFC 3279
334-
if conf.crypto_valid_recent:
335-
try:
336-
self.pubkey.verify(sig, msg, ec.ECDSA(_get_hash(h)))
337-
return True
338-
except InvalidSignature:
339-
return False
340-
else:
341-
verifier = self.pubkey.verifier(sig, ec.ECDSA(_get_hash(h)))
342-
verifier.update(msg)
343-
return verifier.verify()
333+
try:
334+
self.pubkey.verify(sig, msg, ec.ECDSA(_get_hash(h)))
335+
return True
336+
except InvalidSignature:
337+
return False
344338

345339

346340
################
@@ -540,25 +534,15 @@ def import_from_asn1pkt(self, privkey):
540534
@crypto_validator
541535
def verify(self, msg, sig, h="sha256", **kwargs):
542536
# 'sig' should be a DER-encoded signature, as per RFC 3279
543-
if conf.crypto_valid_recent:
544-
try:
545-
self.pubkey.verify(sig, msg, ec.ECDSA(_get_hash(h)))
546-
return True
547-
except InvalidSignature:
548-
return False
549-
else:
550-
verifier = self.pubkey.verifier(sig, ec.ECDSA(_get_hash(h)))
551-
verifier.update(msg)
552-
return verifier.verify()
537+
try:
538+
self.pubkey.verify(sig, msg, ec.ECDSA(_get_hash(h)))
539+
return True
540+
except InvalidSignature:
541+
return False
553542

554543
@crypto_validator
555544
def sign(self, data, h="sha256", **kwargs):
556-
if conf.crypto_valid_recent:
557-
return self.key.sign(data, ec.ECDSA(_get_hash(h)))
558-
else:
559-
signer = self.key.signer(ec.ECDSA(_get_hash(h)))
560-
signer.update(data)
561-
return signer.finalize()
545+
return self.key.sign(data, ec.ECDSA(_get_hash(h)))
562546

563547

564548
################

tox.ini

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -90,22 +90,6 @@ commands =
9090
coverage combine
9191

9292

93-
[testenv:py27-linux_non_root_old-cryptography]
94-
description = "Scapy unit tests - old cryptography module"
95-
whitelist_externals = sudo
96-
passenv = PATH PWD PROGRAMFILES WINDIR SYSTEMROOT
97-
deps = mock
98-
# cryptography requirements
99-
setuptools>=18.5
100-
cryptography==1.9
101-
coverage
102-
python-can
103-
104-
commands =
105-
coverage run -m scapy.tools.UTscapy -c ./test/configs/linux.utsc -K random_weird_py3 -K netaccess -K needs_root -K crypto_advanced {posargs}
106-
coverage combine
107-
108-
10993
[testenv:codecov]
11094
description = "Upload coverage results to codecov"
11195
passenv = TOXENV CI TRAVIS TRAVIS_* APPVEYOR APPVEYOR_*

0 commit comments

Comments
 (0)