|
Server : Apache System : Linux cvar2.toservers.com 3.10.0-962.3.2.lve1.5.73.el7.x86_64 #1 SMP Wed Aug 24 21:31:23 UTC 2022 x86_64 User : njnconst ( 1116) PHP Version : 8.4.18 Disable Function : NONE Directory : /lib64/python2.7/site-packages/nacl/bindings/ |
Upload File : |
�
y�\c @` s d d l m Z m Z m Z d d l m Z d d l m Z m Z d d l
m Z e j � Z
e j � d Z e j � Z e j � Z e j � Z e j � Z d � Z d � Z d � Z d � Z d
� Z d � Z d e f d
� � YZ d � Z d � Z d � Z! d S( i ( t absolute_importt divisiont print_function( t
exceptions( t ffit lib( t ensurei c C` sv t j d t � } t j d t � } t j | | � } t | d k d d t j �t j | t � t j | t � f S( su
Returns a randomly generated public key and secret key.
:rtype: (bytes(public_key), bytes(secret_key))
s unsigned char[]i s Unexpected library errort raising(
R t newt crypto_sign_PUBLICKEYBYTESt crypto_sign_SECRETKEYBYTESR t crypto_sign_keypairR t exct RuntimeErrort buffer( t pkt skt rc( ( s; /tmp/pip-install-A1qMVe/pynacl/nacl/bindings/crypto_sign.pyR ! s
c C` s� t | � t k r$ t j d � � n t j d t � } t j d t � } t j | | | � } t
| d k d d t j �t j | t � t j | t � f S( s�
Computes and returns the public key and secret key using the seed ``seed``.
:param seed: bytes
:rtype: (bytes(public_key), bytes(secret_key))
s Invalid seeds unsigned char[]i s Unexpected library errorR (
t lent crypto_sign_SEEDBYTESR t
ValueErrorR R R R
R t crypto_sign_seed_keypairR R
R ( t seedR R R ( ( s; /tmp/pip-install-A1qMVe/pynacl/nacl/bindings/crypto_sign.pyR 5 s
c C` s} t j d t | � t � } t j d � } t j | | | t | � | � } t | d k d d t j �t j | | d � S( s�
Signs the message ``message`` using the secret key ``sk`` and returns the
signed message.
:param message: bytes
:param sk: bytes
:rtype: bytes
s unsigned char[]s unsigned long long *i s Unexpected library errorR (
R R R t crypto_sign_BYTESR t crypto_signR R R
R ( t messageR t signedt
signed_lenR ( ( s; /tmp/pip-install-A1qMVe/pynacl/nacl/bindings/crypto_sign.pyR M s !
c C` su t j d t | � � } t j d � } t j | | | t | � | � d k r` t j d � � n t j | | d � S( s�
Verifies the signature of the signed message ``signed`` using the public
key ``pk`` and returns the unsigned message.
:param signed: bytes
:param pk: bytes
:rtype: bytes
s unsigned char[]s unsigned long long *i s Signature was forged or corrupt( R R R R t crypto_sign_openR t BadSignatureErrorR ( R R R t message_len( ( s; /tmp/pip-install-A1qMVe/pynacl/nacl/bindings/crypto_sign.pyR a s !c C` s{ t | � t k r$ t j d � � n t } t j d | � } t j | | � } t | d k d d t j
�t j | | � S( s
Converts a public Ed25519 key (encoded as bytes ``public_key_bytes``) to
a public Curve25519 key as bytes.
Raises a ValueError if ``public_key_bytes`` is not of length
``crypto_sign_PUBLICKEYBYTES``
:param public_key_bytes: bytes
:rtype: bytes
s Invalid curve public keys unsigned char[]i s Unexpected library errorR ( R R R R t crypto_sign_curve25519_BYTESR R R t$ crypto_sign_ed25519_pk_to_curve25519R R
R ( t public_key_bytest curve_public_key_lent curve_public_keyR ( ( s; /tmp/pip-install-A1qMVe/pynacl/nacl/bindings/crypto_sign.pyR t s
c C` s{ t | � t k r$ t j d � � n t } t j d | � } t j | | � } t | d k d d t j
�t j | | � S( s
Converts a secret Ed25519 key (encoded as bytes ``secret_key_bytes``) to
a secret Curve25519 key as bytes.
Raises a ValueError if ``secret_key_bytes``is not of length
``crypto_sign_SECRETKEYBYTES``
:param public_key_bytes: bytes
:rtype: bytes
s Invalid curve public keys unsigned char[]i s Unexpected library errorR ( R R
R R R R R R t$ crypto_sign_ed25519_sk_to_curve25519R R
R ( t secret_key_bytest curve_secret_key_lent curve_secret_keyR ( ( s; /tmp/pip-install-A1qMVe/pynacl/nacl/bindings/crypto_sign.pyR$ � s
t crypto_sign_ed25519ph_statec B` s e Z d Z d g Z d � Z RS( sO
State object wrapping the sha-512 state used in ed25519ph computation
t statec C` sG t j d t � | _ t j | j � } t | d k d d t j �d S( Ns unsigned char[]i s Unexpected library errorR ( R R t crypto_sign_ed25519ph_STATEBYTESR) R t crypto_sign_ed25519ph_initR R R
( t selfR ( ( s; /tmp/pip-install-A1qMVe/pynacl/nacl/bindings/crypto_sign.pyt __init__� s ( t __name__t
__module__t __doc__t __slots__R- ( ( ( s; /tmp/pip-install-A1qMVe/pynacl/nacl/bindings/crypto_sign.pyR( � s c C` s| t t | t � d d t j �t t | t � d d t j �t j | j | t | � � } t | d k d d t j
�d S( s�
Update the hash state wrapped in edph
:param edph: the ed25519ph state being updated
:type edph: crypto_sign_ed25519ph_state
:param pmsg: the partial message
:type pmsg: bytes
:rtype: None
s/ edph parameter must be a ed25519ph_state objectR s% pmsg parameter must be a bytes objecti s Unexpected library errorN( R t
isinstanceR( R t TypeErrort bytesR t crypto_sign_ed25519ph_updateR) R R
( t edpht pmsgR ( ( s; /tmp/pip-install-A1qMVe/pynacl/nacl/bindings/crypto_sign.pyR5 � s
c C` s� t t | t � d d t j �t t | t � d d t j �t t | � t k d j t � d t j �t j
d t � } t j
| j | t j | � } t | d k d d t j �t j | t � S( sR
Create a signature for the data hashed in edph
using the secret key sk
:param edph: the ed25519ph state for the data
being signed
:type edph: crypto_sign_ed25519ph_state
:param sk: the ed25519 secret part of the signing key
:type sk: bytes
:return: ed25519ph signature
:rtype: bytes
s/ edph parameter must be a ed25519ph_state objectR s+ secret key parameter must be a bytes objects! secret key must be {0} bytes longs unsigned char[]i s Unexpected library error( R R2 R( R R3 R4 R R
t formatR R R R t"