File: //var/opt/nydus/ops/oscrypto/__pycache__/_pkcs1.cpython-39.pyc
a
�,�h]O � @ s2 d dl mZmZmZmZ d dlZd dlZd dlZd dlZd dl Z d dl
Z
ddlmZ ddl
mZmZ ddlmZmZmZmZmZ ddlmZ ddlmZ dd lmZmZmZ ejd
k r�eZ e!Z"ndd� Z e� Z#g d
�Z$dd� Z%dd� Z&dd� Z'dd� Z(dd� Z)dd� Z*dd� Z+dd� Z,dd� Z-d d!� Z.d"d#� Z/dS )$� )�unicode_literals�division�absolute_import�print_functionN� )�backend)�constant_compare�
rand_bytes)�Certificate�int_from_bytes�int_to_bytes�PrivateKeyInfo�
PublicKeyInfo)�pretty_message)�
fill_width)� type_name�byte_cls� int_types)� c C s
t | g�S )N)�bytes)�num� r �@/opt/nydus/tmp/pip-target-wkfpz8uv/lib/python/oscrypto/_pkcs1.py�chr_cls s r )�add_pss_padding�add_pkcs1v15_signature_padding�raw_rsa_private_crypt�raw_rsa_public_crypt�"remove_pkcs1v15_encryption_padding�!remove_pkcs1v15_signature_padding�verify_pss_paddingc C s: t jdkrdS t�� d } ttt| �d���dd� dkS )zM
:return:
A bool if the current machine is running OS X 10.7
�darwinFr �.� )�
� )�sys�platform�mac_ver�tuple�map�int�split)�versionr r r �_is_osx_107/ s
r. c C s
t dkrtjdkrttd���t|t�s:ttdt|����t|t �sVttdt|����|dk rpt
tdt|����t|t �s�ttdt|����|d k r�t
td
t|����| tg d��vr�t
tdt| ����t
t| �}|d
}tt�|d ��}||��� }t|�}||| d k �rt
td���|dk�r4t�|�} nd} d| | }
||
��� }d|| | d }|d | }
t| ||| d
�}tt|
�t|�A �}t|t|��}d| | }d| dd| }t|d�}|dk�r�t|t|dd
� �@ �|d
d� }|| d S )a5
Pads a byte string using the EMSA-PSS-Encode operation described in PKCS#1
v2.2.
:param hash_algorithm:
The string name of the hash algorithm to use: "sha1", "sha224",
"sha256", "sha384", "sha512"
:param salt_length:
The length of the salt as an integer - typically the same as the length
of the output from the hash_algorithm
:param key_length:
The length of the RSA key, in bits
:param message:
A byte string of the message to pad
:return:
The encoded (passed) message
� winlegacyr! z~
Pure-python RSA PSS signature padding addition code is only for
Windows XP/2003 and OS X
�?
message must be a byte string, not %s
�@
salt_length must be an integer, not %s
r �?
salt_length must be 0 or more - is %s
�?
key_length must be an integer, not %s
i z@
key_length must be 512 or more - is %s
��sha1�sha224�sha256�sha384�sha512�z
hash_algorithm must be one of "sha1", "sha224", "sha256", "sha384",
"sha512", not %s
r � r# zq
Key is not long enough to use with specified hash_algorithm and
salt_length
� � � � �0�1� N� �)�_backendr&