Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/Crypto/Signature/__pycache__/pss.cpython-39.pyc
Ðазад
a c�hz4 � @ sz d dl mZmZmZ d dlZd dlmZmZmZ d dl m Z d dlmZ G dd� d�Zdd � Z d d� Zdd � Zdd� ZdS )� )�bchr�bord� iter_rangeN)�ceil_div� long_to_bytes� bytes_to_long)�strxor)�Randomc @ s0 e Zd ZdZdd� Zdd� Zdd� Zdd � Zd S )� PSS_SigSchemezvA signature object for ``RSASSA-PSS``. Do not instantiate directly. Use :func:`Crypto.Signature.pss.new`. c C s || _ || _|| _|| _dS )at Initialize this PKCS#1 PSS signature scheme object. :Parameters: key : an RSA key object If a private half is given, both signature and verification are possible. If a public half is given, only verification is possible. mgfunc : callable A mask generation function that accepts two parameters: a string to use as seed, and the lenth of the mask to generate, in bytes. saltLen : integer Length of the salt, in bytes. randfunc : callable A function that returns random bytes. N)�_key�_saltLen�_mgfunc� _randfunc)�self�keyZmgfuncZsaltLenZrandfunc� r ��/root/rpmbuild/BUILDROOT/imh-python39-modules-3.9.7-92.el8.x86_64/opt/imh-python/lib/python3.9/site-packages/Crypto/Signature/pss.py�__init__/ s zPSS_SigScheme.__init__c C s | j �� S )z<Return ``True`` if this object can be used to sign messages.)r Zhas_private)r r r r �can_signF s zPSS_SigScheme.can_signc s� | j du r� j}n| j }| jdu r0� fdd�}n| j}tjj�| jj�}t |d�}t � |d | j||�}t|�}| j� |�}t||�} | S )a~ Create the PKCS#1 PSS signature of a message. This function is also called ``RSASSA-PSS-SIGN`` and it is specified in `section 8.1.1 of RFC8017 <https://tools.ietf.org/html/rfc8017#section-8.1.1>`_. :parameter msg_hash: This is an object from the :mod:`Crypto.Hash` package. It has been used to digest the message to sign. :type msg_hash: hash object :return: the signature encoded as a *byte string*. :raise ValueError: if the RSA key is not long enough for the given hash algorithm. :raise TypeError: if the RSA key has no private half. Nc s t | |� �S �N��MGF1��x�y��msg_hashr r �<lambda>b � z$PSS_SigScheme.sign.<locals>.<lambda>� � )r �digest_sizer �Crypto�Util�number�sizer �nr �_EMSA_PSS_ENCODEr r Z_decryptr ) r r �sLen�mgf�modBits�k�em�em_intZm_int� signaturer r r �signJ s zPSS_SigScheme.signc s� | j du r� j}n| j }| jr&| j}n� fdd�}tjj�| jj�}t |d�}t |�|krbtd��t|�}| j� |�}t |d d�} t|| �} t� | |d ||� dS )ap Check if the PKCS#1 PSS signature over a message is valid. This function is also called ``RSASSA-PSS-VERIFY`` and it is specified in `section 8.1.2 of RFC8037 <https://tools.ietf.org/html/rfc8017#section-8.1.2>`_. :parameter msg_hash: The hash that was carried out over the message. This is an object belonging to the :mod:`Crypto.Hash` module. :type parameter: hash object :parameter signature: The signature that needs to be validated. :type signature: bytes :raise ValueError: if the signature is not valid. Nc s t | |� �S r r r r r r r � r z&PSS_SigScheme.verify.<locals>.<lambda>r �Incorrect signaturer )r r! r r"