+
    '(j;                         ^ RI Ht ^ RIHt ^ RIHt ^ RIHt ^ RIH	t	 ^ RI
Ht RR.t ! R	 R]4      t ! R
 R]4      t ! R R]4      t ! R R]4      tRR ltR# )    )DerSequence)long_to_bytes)Integer)HMAC)EccKey)DsaKeyDssSigSchemenewc                   H   a  ] tR t^-t o RtR tR tR tR tR t	R t
RtV tR	# )
r	   z_A (EC)DSA signature object.
Do not instantiate directly.
Use :func:`Crypto.Signature.DSS.new`.
c                    Wn         W n        W0n        V P                  P                  4       V n        V P                  ^,
          ^,          ^,           V n        R# )zCreate a new Digital Signature Standard (DSS) object.

Do not instantiate this object directly,
use `Crypto.Signature.DSS.new` instead.
N)_key	_encoding_ordersize_in_bits_order_bits_order_bytes)selfkeyencodingorders   &&&&I/home/ubuntu/cf-venv/lib/python3.14/site-packages/Crypto/Signature/DSS.py__init__DssSigScheme.__init__3   sE     	!;;335!--1a7!;    c                6    V P                   P                  4       # )zJReturn ``True`` if this signature object can be used
for signing messages.)r   has_private)r   s   &r   can_signDssSigScheme.can_signA   s     yy$$&&r   c                    \        R 4      hzTo be provided by subclassesNotImplementedErrorr   msg_hashs   &&r   _compute_nonceDssSigScheme._compute_nonceG       !"@AAr   c                    \        R 4      hr    r!   r#   s   &&r   _valid_hashDssSigScheme._valid_hashJ   r'   r   c           	     $   V P                   P                  4       '       g   \        R4      hV P                  V4      '       g   \	        R4      hV P                  V4      p\        P                  ! VP                  4       RV P                   4      pV P                   P                  W24      pV P                  R8X  d7   RP                  V Uu. uF  p\        WPP                  4      NK  	  up4      pV# \        V4      P                  4       pV# u upi )a  Compute the DSA/ECDSA signature of a message.

Args:
  msg_hash (hash object):
    The hash that was carried out over the message.
    The object belongs to the :mod:`Crypto.Hash` package.
    Under mode ``'fips-186-3'``, the hash must be a FIPS
    approved secure hash (SHA-2 or SHA-3).

:return: The signature as ``bytes``
:raise ValueError: if the hash algorithm is incompatible to the (EC)DSA key
:raise TypeError: if the (EC)DSA key has no private half
zPrivate key is needed to signHash is not sufficiently strongNbinaryr   )r   r   	TypeErrorr)   
ValueErrorr%   r   
from_bytesdigestr   _signr   joinr   r   encode)r   r$   noncezsig_pairxoutputs   &&     r   signDssSigScheme.signM   s     yy$$&&;<<))>?? ##H- x01C$2C2CDE99??1, >>X%XX(02(01  -Q0A0AB(02 3F  !*113F2s   Dc                   V P                  V4      '       g   \        R4      hV P                  R8X  dq   \        V4      ^V P                  ,          8w  d   \        R4      hVRV P                   W P                  R 3 Uu. uF  p\
        P                  ! V4      NK  	  upw  rEMp \        4       P                  VRR7      p\        T4      ^8w  g   TP                  4       '       g   \        R4      h\        T^ ,          4      \        T^,          4      rT^ Tu;8  d   V P                  8  d   M M^ Tu;8  d   V P                  8  g   M \        R	4      h\
        P                  ! VP                  4       RV P                   4      pV P                  P                  WtV34      pV'       g   \        R
4      hR# u upi   \        \        3 d    \        R4      hi ; i)a  Check if a certain (EC)DSA signature is authentic.

Args:
  msg_hash (hash object):
    The hash that was carried out over the message.
    This is an object belonging to the :mod:`Crypto.Hash` module.
    Under mode ``'fips-186-3'``, the hash must be a FIPS
    approved secure hash (SHA-2 or SHA-3).

  signature (``bytes``):
    The signature that needs to be validated.

:raise ValueError: if the signature is not authentic
r,   r-   z'The signature is not authentic (length)NT)strictz$The signature is not authentic (DER)z,The signature is not authentic (DER content)z"The signature is not authentic (d)zThe signature is not authenticF)r)   r/   r   lenr   r   r0   r   decode
IndexErrorhasOnlyIntsr   r1   r   _verify)	r   r$   	signaturer8   r_primes_primeder_seqr6   results	   &&&      r   verifyDssSigScheme.verifyz   s     ))>??>>X%9~!d&7&7"78 !JKK*34FT5F5F*G*34E4E4F*G*I J*IA !( 2 21 5*I JGWI%-..y.F 7|q (;(;(=(= !OPP&wqz2GGAJ4GWG)dkk)1w3L3LABBx01C$2C2CDE""1&89=>>) J 
+ I !GHHIs   ?F9%F> >G)r   r   r   r   r   N)__name__
__module____qualname____firstlineno____doc__r   r   r%   r)   r:   rH   __static_attributes____classdictcell__)__classdict__s   @r   r	   r	   -   s0     
<'BB+Z* *r   c                   P   a a ] tR t^t oV 3R ltR tR tR tR tR t	Rt
VtV ;t# )DeterministicDsaSigSchemec                <   < \         \        V `  WV4       W@n        R # N)superrS   r   _private_key)r   r   r   r   private_key	__class__s   &&&&&r   r   "DeterministicDsaSigScheme.__init__   s    '7uM'r   c                    \         P                  ! V4      pV P                  P                  4       p\	        V4      ^,          pWC8  d   W$V,
          ,          pV# )zSee 2.3.2 in RFC6979)r   r0   r   r   r>   )r   bstrrG   q_lenb_lens   &&   r   	_bits2int#DeterministicDsaSigScheme._bits2int   sI     ##D)((*D	A=&Fr   c                h    ^ Tu;8  d   V P                   8  g   Q h Q h\        WP                  4      # )zSee 2.3.3 in RFC6979)r   r   r   )r   	int_mod_qs   &&r   _int2octets%DeterministicDsaSigScheme._int2octets   s2     9*t{{*****Y(9(9::r   c                    V P                  V4      pW P                  8  d   TpMW P                  ,
          pV P                  V4      # )zSee 2.3.4 in RFC6979)r_   r   rc   )r   r\   z1z2s   &&  r   _bits2octets&DeterministicDsaSigScheme._bits2octets   s>     ^^D!Bkk!B##r   c                8   VP                  4       pRVP                  ,          pRVP                  ,          pR F  p\        P                  ! VW5,           V P	                  V P
                  4      ,           V P                  V4      ,           V4      P                  4       p\        P                  ! WCV4      P                  4       pK  	  Rp^ Tu;8  d   V P                  8  g   M VR8w  dR   \        P                  ! WCR,           V4      P                  4       p\        P                  ! WCV4      P                  4       pRp\        V4      V P                  8  d0   \        P                  ! WCV4      P                  4       pWs,          pKI  V P                  V4      pK  V# )z!Generate k in a deterministic way       r   )rl   rk   )r1   digest_sizer   r
   rc   rW   rh   r   r>   r   r_   )r   mhashh1mask_vnonce_kint_octr5   mask_ts   &&      r   r%   (DeterministicDsaSigScheme._compute_nonce   sR   
 \\^5,,,E---)Ghhw%/#//0A0AB C#004 56;= >DVX 
 XXgu5<<>F * u*t{{*{((7W,<#(**0&( '59@@B F f+ 1 11'59@@B  NN6*Er   c                    R # )T r#   s   &&r   r)   %DeterministicDsaSigScheme._valid_hash   s    r   )rW   )rJ   rK   rL   rM   r   r_   rc   rh   r%   r)   rO   rP   __classcell__rY   rQ   s   @@r   rS   rS      s)     (	;$&P r   rS   c                   B   a a ] tR t^t oRtV 3R ltR tR tRtVt	V ;t
# )FipsDsaSigSchemec                   < \         \        V `  WV4       W@n        \	        VP
                  4      P                  4       pWPP                  3V P                  9  d    R WPP                  3,          p\        V4      hR# )z+L/N (%d, %d) is not compliant to FIPS 186-3N)
rV   r|   r   	_randfuncr   pr   r   _fips_186_3_L_Nr/   )r   r   r   r   randfuncLerrorrY   s   &&&&&  r   r   FipsDsaSigScheme.__init__  sm    .seD!CEEN'') (<(<<B++,-EU## =r   c                \    \         P                  ! ^V P                  V P                  R7      #    )min_inclusivemax_exclusiver   )r   random_ranger   r~   r#   s   &&r   r%   FipsDsaSigScheme._compute_nonce  s%    ##!26++-1^^= 	=r   c                f    VP                   R8H  ;'       g    VP                   P                  R4      # )z*Verify that SHA-1, SHA-2 or SHA-3 are usedz1.3.14.3.2.26z2.16.840.1.101.3.4.2.)oid
startswithr#   s   &&r   r)   FipsDsaSigScheme._valid_hash  s3    / A A''(?@	Br   r~   ))i      )      )r      )i   r   )rJ   rK   rL   rM   r   r   r%   r)   rO   rP   ry   rz   s   @@r   r|   r|      s"     
O$=B Br   r|   c                   >   a a ] tR tRt oV 3R ltR tR tRtVtV ;t	# )FipsEcDsaSigSchemei  c                <   < \         \        V `  WV4       W@n        R # rU   )rV   r   r   r~   )r   r   r   r   r   rY   s   &&&&&r   r   FipsEcDsaSigScheme.__init__  s     $0F!r   c                    \         P                  ! ^V P                  P                  P                  V P
                  R7      # r   )r   r   r   _curver   r~   r#   s   &&r   r%   !FipsEcDsaSigScheme._compute_nonce  s1    ##!26))2B2B2H2H-1^^= 	=r   c                    V P                   P                  P                  4       pRpRpRpRpW4,           V,           V,           p VP                  V9   pV#   \         d    Rp T# i ; i)zpVerify that the strength of the hash matches or exceeds
the strength of the EC. We fail if the hash is too weak.F)z2.16.840.1.101.3.4.2.4z2.16.840.1.101.3.4.2.7z2.16.840.1.101.3.4.2.5)z2.16.840.1.101.3.4.2.1z2.16.840.1.101.3.4.2.8z2.16.840.1.101.3.4.2.6)z2.16.840.1.101.3.4.2.2z2.16.840.1.101.3.4.2.9)z2.16.840.1.101.3.4.2.3z2.16.840.1.101.3.4.2.10)r   pointQr   r   AttributeError)	r   r$   modulus_bitssha224sha256sha384sha512shsrG   s	   &&       r   r)   FipsEcDsaSigScheme._valid_hash"  sy     yy''446 `_EFo&/	\\S(F   	F	s   A A&%A&r   )
rJ   rK   rL   rM   r   r%   r)   rO   rP   ry   rz   s   @@r   r   r     s     "=
 r   r   Nc                   VR9  d   \        RV,          4      h\        V \        4      '       dF   V P                  P                  pRpV P
                  P                  R4      '       g   \        R4      hMR\        V \        4      '       d   \        V P                  4      pRpM$\        R\        \        V 4      4      ,           4      hV P                  4       '       d   \        W4      pMRpVR8X  d   \        WWF4      # VR	8X  d/   \        V \        4      '       d   \        WWC4      # \!        WWC4      # \        R
V,          4      h)a	  Create a signature object :class:`DssSigScheme` that
can perform (EC)DSA signature or verification.

.. note::
    Refer to `NIST SP 800 Part 1 Rev 4`_ (or newer release) for an
    overview of the recommended key lengths.

Args:
    key (:class:`Crypto.PublicKey.DSA` or :class:`Crypto.PublicKey.ECC`):
        The key to use for computing the signature (*private* keys only)
        or for verifying one.
        For DSA keys, let ``L`` and ``N`` be the bit lengths of the modulus ``p``
        and of ``q``: the pair ``(L,N)`` must appear in the following list,
        in compliance to section 4.2 of `FIPS 186-4`_:

        - (1024, 160) *legacy only; do not create new signatures with this*
        - (2048, 224) *deprecated; do not create new signatures with this*
        - (2048, 256)
        - (3072, 256)

        For ECC, only keys over P-224, P-256, P-384, and P-521 are accepted.

    mode (string):
        The parameter can take these values:

        - ``'fips-186-3'``. The signature generation is randomized and carried out
          according to `FIPS 186-3`_: the nonce ``k`` is taken from the RNG.
        - ``'deterministic-rfc6979'``. The signature generation is not
          randomized. See RFC6979_.

    encoding (string):
        How the signature is encoded. This value determines the output of
        :meth:`sign` and the input to :meth:`verify`.

        The following values are accepted:

        - ``'binary'`` (default), the signature is the raw concatenation
          of ``r`` and ``s``. It is defined in the IEEE P.1363 standard.
          For DSA, the size in bytes of the signature is ``N/4`` bytes
          (e.g. 64 for ``N=256``).
          For ECDSA, the signature is always twice the length of a point
          coordinate (e.g. 64 bytes for P-256).

        - ``'der'``, the signature is a ASN.1 DER SEQUENCE
          with two INTEGERs (``r`` and ``s``). It is defined in RFC3279_.
          The size of the signature is variable.

    randfunc (callable):
        A function that returns random ``bytes``, of a given length.
        If omitted, the internal RNG is used.
        Only applicable for the *'fips-186-3'* mode.

.. _FIPS 186-3: http://csrc.nist.gov/publications/fips/fips186-3/fips_186-3.pdf
.. _FIPS 186-4: http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.186-4.pdf
.. _NIST SP 800 Part 1 Rev 4: http://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-57pt1r4.pdf
.. _RFC6979: http://tools.ietf.org/html/rfc6979
.. _RFC3279: https://tools.ietf.org/html/rfc3279#section-2.2.2
zUnknown encoding '%s'dNISTz ECC key is not on a NIST P curver8   zUnsupported key type Nzdeterministic-rfc6979z
fips-186-3zUnknown DSS mode '%s')r-   der)r/   
isinstancer   r   r   curver   r   r   qstrtyper   getattrrS   r   r|   )r   moder   r   r   private_key_attrrX   s   &&&&   r   r
   r
   6  s   D ((08;<<#v

  yy##F++?@@ ,	C	 	 03tCy>ABB
c4&&(KK		c6""%cUEE#C5CC04788r   )r-   N)Crypto.Util.asn1r   Crypto.Util.numberr   Crypto.Math.Numbersr   Crypto.Hashr   Crypto.PublicKey.ECCr   Crypto.PublicKey.DSAr   __all__objectr	   rS   r|   r   r
   rw   r   r   <module>r      sc   D ) , '  ' '5
!w6 wtK K\B| BD >]9r   