Skip to content

Commit

Permalink
Also hide cryptography warnings to TLS
Browse files Browse the repository at this point in the history
  • Loading branch information
gpotter2 authored and guedou committed Jun 19, 2022
1 parent 966b1ce commit 31ee7b9
Showing 1 changed file with 31 additions and 22 deletions.
53 changes: 31 additions & 22 deletions scapy/layers/tls/crypto/cipher_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
Block ciphers.
"""

from __future__ import absolute_import
import warnings

from scapy.config import conf
from scapy.layers.tls.crypto.common import CipherError
import scapy.libs.six as six
Expand All @@ -19,6 +20,7 @@
CipherAlgorithm)
from cryptography.hazmat.backends.openssl.backend import (backend,
GetCipherByName)
from cryptography import CryptographyDeprecationWarning


_tls_block_cipher_algs = {}
Expand Down Expand Up @@ -127,6 +129,8 @@ class Cipher_CAMELLIA_256_CBC(Cipher_CAMELLIA_128_CBC):

# Mostly deprecated ciphers

_sslv2_block_cipher_algs = {}

if conf.crypto_valid:
class Cipher_DES_CBC(_BlockCipher):
pc_cls = algorithms.TripleDES
Expand All @@ -152,27 +156,32 @@ class Cipher_3DES_EDE_CBC(_BlockCipher):
block_size = 8
key_len = 24

class Cipher_IDEA_CBC(_BlockCipher):
pc_cls = algorithms.IDEA
pc_cls_mode = modes.CBC
block_size = 8
key_len = 16

class Cipher_SEED_CBC(_BlockCipher):
pc_cls = algorithms.SEED
pc_cls_mode = modes.CBC
block_size = 16
key_len = 16


_sslv2_block_cipher_algs = {}

if conf.crypto_valid:
_sslv2_block_cipher_algs.update({
"IDEA_128_CBC": Cipher_IDEA_CBC,
"DES_64_CBC": Cipher_DES_CBC,
"DES_192_EDE3_CBC": Cipher_3DES_EDE_CBC
})
_sslv2_block_cipher_algs["DES_192_EDE3_CBC"] = Cipher_3DES_EDE_CBC

try:
with warnings.catch_warnings():
# Hide deprecation warnings
warnings.filterwarnings("ignore",
category=CryptographyDeprecationWarning)

class Cipher_IDEA_CBC(_BlockCipher):
pc_cls = algorithms.IDEA
pc_cls_mode = modes.CBC
block_size = 8
key_len = 16

class Cipher_SEED_CBC(_BlockCipher):
pc_cls = algorithms.SEED
pc_cls_mode = modes.CBC
block_size = 16
key_len = 16

_sslv2_block_cipher_algs.update({
"IDEA_128_CBC": Cipher_IDEA_CBC,
"DES_64_CBC": Cipher_DES_CBC,
})
except AttributeError:
pass


# We need some black magic for RC2, which is not registered by default
Expand Down

0 comments on commit 31ee7b9

Please sign in to comment.