code: def removeCMSPadding(str, blocksize=AES_blocksize):
    '''CMS padding: Remove padding with bytes containing the number of padding bytes '''
    try:
      pad_len = ord(str[-1]) # last byte contains number of padding bytes
    except TypeError:
      pad_len = str[-1]
    assert pad_len <= blocksize, 'padding error' 
    assert pad_len <= len(str), 'padding error'
      
    return str[:-pad_lenf removeCMSPadding(str, blocksize=AES_blocksize):
    '''CMS padding: Remove padding with bytes containing the number of padding bytes '''
    try:
      pad_len = ord(str[-1]) # last byte contains number of padding bytes
    except TypeError:
      pad_len = str[-1]
    assert pad_len <= blocksize, 'padding error' 
    assert pad_len <= len(str), 'padding error'
      
    return str[:-pad_len]
docs: CMS padding: Remove padding with bytes containing the number of padding bytes