관리-도구
편집 파일: pkcs1_15.cpython-311.pyc
� ���b�N �� �b � d dl Zd dl mZmZmZ d dlmZmZmZm Z G d� d� � Z d d�Zd� ZdS ) � N)�ceil_div� bytes_to_long� long_to_bytes)�DerSequence�DerNull�DerOctetString�DerObjectIdc �* � e Zd ZdZd� Zd� Zd� Zd� ZdS )�PKCS115_SigSchemez�A signature object for ``RSASSA-PKCS1-v1_5``. Do not instantiate directly. Use :func:`Crypto.Signature.pkcs1_15.new`. c � � || _ dS )a Initialize this PKCS#1 v1.5 signature scheme object. :Parameters: rsa_key : an RSA key object Creation of signatures is only possible if this is a *private* RSA key. Verification of signatures is always possible. N)�_key)�self�rsa_keys �{/builddir/build/BUILD/imunify360-venv-2.5.2/opt/imunify360/venv/lib64/python3.11/site-packages/Crypto/Signature/pkcs1_15.py�__init__zPKCS115_SigScheme.__init__) s � � �� � � � c �4 � | j � � � S )z<Return ``True`` if this object can be used to sign messages.)r �has_private)r s r �can_signzPKCS115_SigScheme.can_sign3 s � ��y�$�$�&�&�&r c � � t j j � | j j � � }t |d� � }t ||� � }t |� � }| j � |� � }t ||� � }|S )a� Create the PKCS#1 v1.5 signature of a message. This function is also called ``RSASSA-PKCS1-V1_5-SIGN`` and it is specified in `section 8.2.1 of RFC8017 <https://tools.ietf.org/html/rfc8017#page-36>`_. :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. � )�Crypto�Util�number�sizer �nr �_EMSA_PKCS1_V1_5_ENCODEr �_decryptr )r �msg_hash�modBits�k�em�em_int�m_int� signatures r �signzPKCS115_SigScheme.sign7 sw � �$ �+�$�)�)�$�)�+�6�6���W�Q���� %�X�q� 1� 1���r�"�"��� �"�"�6�*�*��!�%��+�+� ��r c �h � t j j � | j j � � }t |d� � }t |� � |k rt d� � �t |� � }| j � |� � }t ||� � } t ||d� � g} |j � d� � } n# t $ r d} Y nw xY w| s$|� t ||d� � � � n# t $ r t d� � �w xY w||vrt d� � �dS )ax Check if the PKCS#1 v1.5 signature over a message is valid. This function is also called ``RSASSA-PKCS1-V1_5-VERIFY`` and it is specified in `section 8.2.2 of RFC8037 <https://tools.ietf.org/html/rfc8017#page-37>`_. :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: byte string :raise ValueError: if the signature is not valid. r zInvalid signatureTz1.2.840.113549.2.FN)r r r r r r r �len� ValueErrorr �_encryptr r �oid� startswith�AttributeError�append) r r r% r r! � signature_intr# �em1�possible_em1�algorithm_is_mds r �verifyzPKCS115_SigScheme.verifyV sR � �( �+�$�)�)�$�)�+�6�6���W�a� � �� �y�>�>�Q����0�1�1�1�%�i�0�0� ���#�#�M�2�2���F�A�&�&�� 2�4�X�q�$�G�G�I�L� (�"*�,�"9�"9�:M�"N�"N����!� (� (� (�"'���� (����"� Q��#�#�$;�H�a��$O�$O�P�P�P���� 2� 2� 2��0�1�1�1� 2���� �l�"�"��0�1�1�1��s0 �D �.C �D � C�D �C�)D �DN)�__name__� __module__�__qualname__�__doc__r r r&