Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/Cryptodome/Signature/__pycache__/DSS.cpython-39.pyc
Ðазад
a b�h�; � @ s� d gZ ddlmZ ddlmZ ddlmZ ddlmZ ddl m Z G dd� de�ZG d d � d e�Z G dd� de�ZG d d� de�Zddd �ZdS )�new� )�DerSequence)� long_to_bytes)�Integer)�HMAC)�EccKeyc @ s@ e Zd ZdZdd� Zdd� Zdd� Zdd � Zd d� Zdd � Z dS )�DssSigSchemezoA (EC)DSA signature object. Do not instantiate directly. Use :func:`Cryptodome.Signature.DSS.new`. c C s6 || _ || _|| _| j�� | _| jd d d | _dS )z�Create a new Digital Signature Standard (DSS) object. Do not instantiate this object directly, use `Cryptodome.Signature.DSS.new` instead. � � N)�_key� _encoding�_order�size_in_bits�_order_bits�_order_bytes)�self�key�encoding�order� r ��/root/rpmbuild/BUILDROOT/imh-python39-modules-3.9.7-92.el8.x86_64/opt/imh-python/lib/python3.9/site-packages/Cryptodome/Signature/DSS.py�__init__3 s zDssSigScheme.__init__c C s | j �� S )zRReturn ``True`` if this signature object can be used for signing messages.)r �has_private�r r r r �can_signA s zDssSigScheme.can_signc C s t d��d S �NzTo be provided by subclasses��NotImplementedError�r �msg_hashr r r �_compute_nonceG s zDssSigScheme._compute_noncec C s t d��d S r r r r r r �_valid_hashJ s zDssSigScheme._valid_hashc sv � � |�std��� �|�}t�|�� d� j� �}� j�||�}� j dkrfd� � fdd�|D ��}nt|��� }|S )a� Produce the DSA/ECDSA signature of a message. :parameter msg_hash: The hash that was carried out over the message. The object belongs to the :mod:`Cryptodome.Hash` package. Under mode *'fips-186-3'*, the hash must be a FIPS approved secure hash (SHA-1 or a member of the SHA-2 family), of cryptographic strength appropriate for the DSA key. For instance, a 3072/256 DSA key can only be used in combination with SHA-512. :type msg_hash: hash object :return: The signature as a *byte string* :raise ValueError: if the hash algorithm is incompatible to the (EC)DSA key :raise TypeError: if the (EC)DSA key has no private half �Hash is not sufficiently strongN�binary� c s g | ]}t |� j��qS r )r r ��.0�xr r r � <listcomp>l s �z%DssSigScheme.sign.<locals>.<listcomp>) r! � ValueErrorr r � from_bytes�digestr r Z_signr �joinr �encode)r r �nonce�zZsig_pair�outputr r r �signM s � zDssSigScheme.signc C sH | � |�std��| jdkrbt|�d| j kr6td��dd� |d| j� || jd� fD �\}}njzt� j|dd �}W n ttfy� td ��Y n0 t|�dks�|�� s�td��t |d �t |d � }}d| k r�| j k �rn nd| k �r| j k �sn td��t �|�� d| j� �}| j �|||f�}|�sDtd��dS )a� Check if a certain (EC)DSA signature is authentic. :parameter msg_hash: The hash that was carried out over the message. This is an object belonging to the :mod:`Cryptodome.Hash` module. Under mode *'fips-186-3'*, the hash must be a FIPS approved secure hash (SHA-1 or a member of the SHA-2 family), of cryptographic strength appropriate for the DSA key. For instance, a 3072/256 DSA key can only be used in combination with SHA-512. :type msg_hash: hash object :parameter signature: The signature that needs to be validated :type signature: byte string :raise ValueError: if the signature is not authentic r"