scapy.layers.tls.crypto.pkcs1

PKCS #1 methods as defined in RFC 3447.

We cannot rely solely on the cryptography library, because the openssl package used by the cryptography library may not implement the md5-sha1 hash, as with Ubuntu or OSX. This is why we reluctantly keep some legacy crypto here.

scapy.layers.tls.crypto.pkcs1.pkcs_i2osp(n, sLen)[source]

I2OSP conversion function from RFC 3447. The length parameter allows the function to perform the padding needed. Note that the user is responsible for providing a sufficient xLen.

Parameters:
  • n – nonnegative integer to be converted

  • sLen – intended length of the resulting octet string

Returns:

corresponding octet string

scapy.layers.tls.crypto.pkcs1.pkcs_ilen(n)[source]

This is a log base 256 which determines the minimum octet string length for unequivocal representation of integer n by pkcs_i2osp.

scapy.layers.tls.crypto.pkcs1.pkcs_os2ip(s)[source]

OS2IP conversion function from RFC 3447.

Parameters:

s – octet string to be converted

Returns:

n, the corresponding nonnegative integer