ff "bddlZddlmZmZmZddlmZmZmZm Z GddZ d dZ dZ dS) N)ceil_div bytes_to_long long_to_bytes) DerSequenceDerNullDerOctetString DerObjectIdc*eZdZdZdZdZdZdZdS)PKCS115_SigSchemezA signature object for ``RSASSA-PKCS1-v1_5``. Do not instantiate directly. Use :func:`Crypto.Signature.pkcs1_15.new`. c||_dS)aInitialize 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)selfrsa_keys {/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib64/python3.11/site-packages/Crypto/Signature/pkcs1_15.py__init__zPKCS115_SigScheme.__init__)s c4|jS)z`_. :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. ) CryptoUtilnumbersizer nr_EMSA_PKCS1_V1_5_ENCODEr_decryptr)rmsg_hashmodBitskemem_intm_int signatures rsignzPKCS115_SigScheme.sign7sw$+$))$)+66 WQ  %Xq 1 1r"" ""6**!%++ rchtjj|jj}t |d}t||krtdt|}|j |}t||} t||dg} |j d} n#t$rd} YnwxYw| s$|t||dn#t$rtdwxYw||vrtddS)axCheck 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 `_. :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. rzInvalid signatureTz1.2.840.113549.2.FN)rrrrr rrlen ValueErrorr_encryptrroid startswithAttributeErrorappend) rrr%r r! signature_intr#em1 possible_em1algorithm_is_mds rverifyzPKCS115_SigScheme.verifyVsR(+$))$)+66 Wa  y>>Q  011 1%i00 ##M22FA&& 24Xq$GGIL ("*,"9"9:M"N"N! ( ( ("' (" Q##$;Ha$O$OPPP 2 2 2011 1 2 l " "011 1 s0D.C D CDC)DDN)__name__ __module__ __qualname____doc__rrr&r3rrr r #sZ '''>4 4 4 4 4 rr TcTtt|jg}|r3|t t |}t||g}|t|dzkrtdt|zd|t|z dz z}d|zdz|zS)a Implement the ``EMSA-PKCS1-V1_5-ENCODE`` function, as defined in PKCS#1 v2.1 (RFC3447, 9.2). ``_EMSA-PKCS1-V1_5-ENCODE`` actually accepts the message ``M`` as input, and hash it internally. Here, we expect that the message has already been hashed instead. :Parameters: msg_hash : hash object The hash object that holds the digest of the message being signed. emLen : int The length the final encoding must have, in bytes. with_hash_parameters : bool If True (default), include NULL parameters for the hash algorithm in the ``digestAlgorithm`` SEQUENCE. :attention: the early standard (RFC2313) stated that ``DigestInfo`` had to be BER-encoded. This means that old signatures might have length tags in indefinite form, which is not supported in DER. Such encoding cannot be reproduced by this function. :Return: An ``emLen`` byte long string that encodes the hash. z9Selected hash algorithm has a too long digest (%d bytes).s) rr r+encoder.rrdigestr( TypeError)remLenwith_hash_parameters digestAlgor? digestInfoPSs rrrsd{8<88??AACDDJ.'))**,,--- !2!233F%%''MMOOvxx S__R SVYZ`VaVaabbb EC OO+a/ 0B  g % 22rc t|S)aCreate a signature object for creating or verifying PKCS#1 v1.5 signatures. :parameter rsa_key: The RSA key to use for signing or verifying the message. This is a :class:`Crypto.PublicKey.RSA` object. Signing is only possible when ``rsa_key`` is a **private** RSA key. :type rsa_key: RSA object :return: a :class:`PKCS115_SigScheme` signature object )r )rs rnewrGs W % %%r)T) Crypto.Util.numberrrrrCrypto.Util.asn1rrrr r rrGr8rrrJs>EEEEEEEEEENNNNNNNNNNNNg g g g g g g g TB3B3B3B3H & & & & &r