MCPcopy Create free account
hub / github.com/secdev/scapy / new_cipher

Method new_cipher

scapy/layers/ipsec.py:335–358  ·  view source on GitHub ↗

:param key: the secret key, a byte string :param mode_iv: the initialization vector or nonce, a byte string. Formatted by `format_mode_iv`. :param digest: also known as tag or icv. A byte string containing the digest of th

(self, key, mode_iv, digest=None)

Source from the content-addressed store, hash-verified

333
334 @crypto_validator
335 def new_cipher(self, key, mode_iv, digest=None):
336 """
337 :param key: the secret key, a byte string
338 :param mode_iv: the initialization vector or nonce, a byte string.
339 Formatted by `format_mode_iv`.
340 :param digest: also known as tag or icv. A byte string containing the
341 digest of the encrypted data. Only use this during
342 decryption!
343
344 :returns: an initialized cipher object for this algo
345 """
346 if self.is_aead and digest is not None:
347 # With AEAD, the mode needs the digest during decryption.
348 return Cipher(
349 self.cipher(key),
350 self.mode(mode_iv, digest, len(digest)),
351 default_backend(),
352 )
353 else:
354 return Cipher(
355 self.cipher(key),
356 self.mode(mode_iv),
357 default_backend(),
358 )
359
360 def pad(self, esp):
361 """

Callers 2

encryptMethod · 0.95
decryptMethod · 0.95

Calls 1

modeMethod · 0.80

Tested by

no test coverage detected