paddingschemes

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:

Parameters:
  • 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

OAEPEncryptionPadding

Implements the OAEP padding scheme. Appropriate for RSA-OAEP encryption. Implemented according to PKCS#1 v2.1 Section 7 ftp://ftp.rsasecurity.com/pub/pkcs/pkcs-1/pkcs-1v2-1.pdf

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

Bases: object

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

Bases: object

Authors:Gary Belvin

PSSSignaturePadding

Implements the PSS signature padding scheme. Appropriate for RSA-PSS signing. Implemented according to section 8 of ftp://ftp.rsasecurity.com/pub/pkcs/pkcs-1/pkcs-1v2-1.pdf.

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

Parameters:
  • M - the message to verify
  • EM - the encoded message
Return:

true for ‘consistent’ or false for ‘inconsistent’

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

Bases: object

Authors:Christina Garman

SAEPEncryptionPadding

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

Bases: object