HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: xnsbb3110 (1041)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/local/CyberPanel/lib/python3.10/site-packages/ecdsa/__pycache__/rfc6979.cpython-310.pyc
o

��h"�@s^dZddlZddlmZddlmZmZmZddlm	Z	gd�Z
dd	�Zd
d�Zdd
d�Z
dS)a
RFC 6979:
    Deterministic Usage of the Digital Signature Algorithm (DSA) and
    Elliptic Curve Digital Signature Algorithm (ECDSA)

    http://tools.ietf.org/html/rfc6979

Many thanks to Coda Hale for his implementation in Go language:
    https://github.com/codahale/rfc6979
�N)�hexlify�)�number_to_string�number_to_string_crop�
bit_length)�hmac_compat)r�bits2int�bits2octets�
generate_kcCs2tt|�d�}t|�d}||kr|||?S|S)N��)�intr�len)�data�qlen�x�l�r�C/usr/local/CyberPanel/lib/python3.10/site-packages/ecdsa/rfc6979.pyrs
rcCs,t|t|��}||}|dkr|}t||�S)Nr)rrr)r�order�z1�z2rrrr	 s

r	�cCszt|�}|�j}|dd}tt||��tt||��t|�f}	d|}
d|}tj||d�}|�|
d�|	D]}|�|�q7|��}t�||
|���}
tj||d�}|�|
d�|	D]}|�|�q\|��}t�||
|���}
	d}
t	|
�|kr�t�||
|���}
|
|
7}
t	|
�|kszt
|
|�}d|kr�|kr�nn
|d	kr�|S|d8}t�||
d|���}t�||
|���}
qr)
aD
    Generate the ``k`` value - the nonce for DSA.

    :param int order: order of the DSA generator used in the signature
    :param int secexp: secure exponent (private key) in numeric form
    :param hash_func: reference to the same hash function used for generating
        hash, like :py:class:`hashlib.sha1`
    :param bytes data: hash in binary form of the signing data
    :param int retry_gen: how many good 'k' values to skip before returning
    :param bytes extra_entropy: additional added data in binary form as per
        section-3.6 of rfc6979
    :rtype: int
    �r��)�	digestmodTrrr)r�digest_sizerrr	�hmac�new�update�digestrr)r�secexp�	hash_funcr�	retry_gen�
extra_entropyr�holen�rolen�bx�v�k�i�t�secretrrrr
+sF��
�r
)rr)�__doc__r�binasciir�utilrrr�_compatr�__all__rr	r
rrrr�<module>s