A collection of encryption and signature padding schemes

paddingschemes.MGF1(seed, maskBytes, hashFn, hLen)[source]

MGF1 Mask Generation Function

Implemented according to PKCS #1 specification, see appendix B.2.1:

  • hLen: is the output length of the hash function
  • maskBytes: the number of mask bytes to return
class paddingschemes.OAEPEncryptionPadding(_hash_type='sha1')[source]

Bases: object

Authors:Gary Belvin


Implements the OAEP padding scheme. Appropriate for RSA-OAEP encryption. Implemented according to PKCS#1 v2.1 Section 7

decode(encMessage, label='')[source]
encode(message, emLen, label='', seed=None)[source]
Return:a Bytes object
class paddingschemes.PKCS7Padding(block_size=16)[source]

Bases: object

encode(_bytes, block_size=16)[source]
class paddingschemes.PSSPadding(_hash_type='sha1')[source]

Bases: object

Authors:Gary Belvin


Implements the PSS signature padding scheme. Appropriate for RSA-PSS signing. Implemented according to section 8 of

encode(M, emBits=None, salt=None)[source]

Encodes a message with PSS padding emLen will be set to the minimum allowed length if not explicitly set

verify(M, EM, emBits=None)[source]

Verifies that EM is a correct encoding for M

  • M - the message to verify
  • EM - the encoded message

true for ‘consistent’ or false for ‘inconsistent’

class paddingschemes.SAEPEncryptionPadding(_hash_type='sha384')[source]

Bases: object

Authors:Christina Garman


decode(encMessage, n, s0)[source]
encode(message, n, s0)[source]
class paddingschemes.hashFunc(_hash_type=None)[source]

Bases: object