+
    '(jjW                        . ROt ^ RIt^ RIt^ RIt^ RIHtHtHtHtH	t	 ^ RI
Ht ^ RIHtHt ^ RIHt ^ RIHtHtHtHtHt ^ RIHt ^ R	IHtHtHt ^ R
IHtHtH t   ! R R]!4      t"R t#RR lt$RR lt%R t&R t'R t(R t)R t*RR lt+]+t,Rt-R# )generateDsaKeyN)bchrbordtobytestostr
iter_range)Random)PKCS8PEM)SHA256)	DerObjectDerSequence
DerIntegerDerObjectIdDerBitString)Integer)test_probable_prime	COMPOSITEPROBABLY_PRIME)_expand_subject_public_key_info_create_subject_public_key_info _extract_subject_public_key_infoc                      a  ] tR t^Nt o Rt. ROtR tR tR tR t	R t
R tR tR	 tR
 tR tR tR tR tRR lt]t]tR tR tR tR tR tR tR tRtV tR# )r   a  Class defining an actual DSA key.
Do not instantiate directly.
Use :func:`generate`, :func:`construct` or :func:`import_key` instead.

:ivar p: DSA modulus
:vartype p: integer

:ivar q: Order of the subgroup
:vartype q: integer

:ivar g: Generator
:vartype g: integer

:ivar y: Public key
:vartype y: integer

:ivar x: Private key
:vartype x: integer

:undocumented: exportKey, publickey
c           	     t   \        VP                  4       4      p\        R4      pVP                  V4      '       g"   \        R\	        W2,
          4      ,          4      hW#,
          pV'       d<   V\        R4      8w  d,   \        R\	        V\        R4      ,
          4      ,          4      h\        V4      V n        R# )yz$Some DSA components are missing = %szUnknown DSA components = %sNr   gpqx)setkeysissubset
ValueErrorstrdict_key)selfkey_dict	input_set
public_set	extra_sets   &&   I/home/ubuntu/cf-venv/lib/python3.14/site-packages/Crypto/PublicKey/DSA.py__init__DsaKey.__init__g   s    (	./
""9--C !789 : :*	c&k1: S[!89: ; ;N	    c                   V P                  4       '       g   \        R 4      h^Tu;8  d   V P                  8  g   M \        R4      hR Uu. uF  q0P                  V,          NK  	  upw  rErg\
        P                  ! ^VR7      pW,          P                  V4      p	WH,          p
\        WrV4      V,          pWV,          W,          ,           ,          V,          p\        \        W34      # u upi )z)DSA public key cannot be used for signingzk is not between 2 and q-1)min_inclusivemax_exclusive)r!   r   r   r   )has_private	TypeErrorr   r%   r(   r   random_rangeinversepowmapint)r)   mkcompr!   r   r   r   blind_factorinv_blind_kblind_xrss   &&&          r.   _signDsaKey._signs   s    !!GHHA9::2FG2F$iioo2FG
a++!9:<#'003"aL11,w{:;q@3 Hs   C+c                |   Vw  r4R Uu. uF  qPP                   V,          NK  	  upw  rgr^ Tu;8  d   V8  d   M R# ^ Tu;8  d
   V8  g    R#  R# \        V4      P                  V4      p
W,          V,          pW,          V,          p\        WV4      \        WlV4      ,          V,          V,          pW8H  # u upi )r   F)r   r   r   r   )r(   r   r8   r9   )r)   r<   sigrB   rC   r>   r   r   r   r   wu1u2vs   &&&           r.   _verifyDsaKey._verify   s    2FG2F$iioo2FG
aA		 $%q919 $-AJq!eq[eq[]S]*Q.!3v Hs   B9c                     RV P                   9   # )z!Whether this is a DSA private keyr!   r(   r)   s   &r.   r5   DsaKey.has_private   s     diir1   c                    R # )F rP   s   &r.   can_encryptDsaKey.can_encrypt   s    r1   c                    R # TrS   rP   s   &r.   can_signDsaKey.can_sign   s    r1   c                D   a  \        V 3R lR 4       4      p\        V4      # )zFA matching DSA public key.

Returns:
    a new :class:`DsaKey` object
c              3   L   <"   T F  qSP                   V,          3x  K  	  R # 5iNrO   ).0r=   r)   s   & r.   	<genexpr>$DsaKey.public_key.<locals>.<genexpr>   s      Q<PqTYYq\!2<Ps   !$r   )r'   r   )r)   public_componentss   f r.   
public_keyDsaKey.public_key   s#     ! Q<P QQ'((r1   c                   \        V P                  4       4      \        VP                  4       4      8w  d   R # RpV P                   F<  pT;'       d0    \        V P                  VR4      \        VP                  VR4      8H  pK>  	  V# )FTN)boolr5   _keydatagetattrr(   )r)   otherresultr>   s   &&  r.   __eq__DsaKey.__eq__   sy      "#tE,=,=,?'@@MMD B BD$!?!(T4!@"AF " r1   c                .    V P                  V4      '       * # r\   )ri   )r)   rg   s   &&r.   __ne__DsaKey.__ne__   s    ;;u%%%r1   c                    ^ RI Hp Vh)    )PicklingError)picklerp   )r)   rp   s   & r.   __getstate__DsaKey.__getstate__   s    (r1   c                d    R Uu. uF  p\        V P                  V,          4      NK!  	  up# u upi )z8The DSA domain parameters.

Returns
    tuple : (p,q,g)
)r   r   r   )r;   r(   )r)   r>   s   & r.   domainDsaKey.domain   s*     2AADIIdO$AAAs   %-c                   . pV P                    Fl  pVR 8X  d?   \        V P                  4      P                  4       pVP	                  RV3,          4       KH  \        W4      '       g   K[  VP	                  V4       Kn  	  V P                  4       '       d   VP	                  R4       RV P                  P                  \        V 4      RP                  V4      3,          # )r   zp(%d)privatez<%s @0x%x %s>,)re   r   r   size_in_bitsappendhasattrr5   	__class____name__idjoin)r)   attrsr=   bitss   &   r.   __repr__DsaKey.__repr__   s    ACxtvv335Ww./!!Q  LL#$.."9"92d8SXXe_!UUUr1   c                p     \        V P                  V,          4      #   \         d    \        T4      hi ; ir\   )r;   r(   KeyErrorAttributeError)r)   items   &&r.   __getattr__DsaKey.__getattr__   s4    	'tyy'' 	' &&	's    5Nc                &   Ve   \        V4      pVf   \        P                  pVR8X  d   R Uu. uF#  q`P                  V,          P	                  4       NK%  	  ppR pV Uu. uF
  qh! V4      NK  	  p	pR.V	,           p
RP                  V
 Uu. uF*  p\        P                  ! R\        V4      4      V,           NK,  	  up4      pR\        P                  ! V4      RR ,           # \        V P                  V P                  V P                  .4      pV P                  4       '       d   Vf   RpV'       d]   V'       g   R	p\!        V P"                  4      P%                  4       p\&        P(                  ! V\*        VWMVR
7      pV'       d   RpMRpRpMVR8w  d   V'       d   \-        R4      h^ V P                  V P                  V P                  V P.                  V P"                  .p\        V4      P%                  4       pRpM9V'       d   \-        R4      h\1        \*        \!        V P.                  4      V4      pRpVR8X  d   V# VR8X  d+   \2        P$                  ! VVR,           W54      p\        V4      # \-        RV,          4      hu upi u upi u upi )a_  Export this DSA key.

Args:
  format (string):
    The encoding for the output:

    - *'PEM'* (default). ASCII as per `RFC1421`_/ `RFC1423`_.
    - *'DER'*. Binary ASN.1 encoding.
    - *'OpenSSH'*. ASCII one-liner as per `RFC4253`_.
      Only suitable for public keys, not for private keys.

  passphrase (string):
    *Private keys only*. The pass phrase to protect the output.

  pkcs8 (boolean):
    *Private keys only*. If ``True`` (default), the key is encoded
    with `PKCS#8`_. If ``False``, it is encoded in the custom
    OpenSSL/OpenSSH container.

  protection (string):
    *Only in combination with a pass phrase*.
    The encryption scheme to use to protect the output.

    If :data:`pkcs8` takes value ``True``, this is the PKCS#8
    algorithm to use for deriving the secret and encrypting
    the private DSA key.
    For a complete list of algorithms, see :mod:`Crypto.IO.PKCS8`.
    The default is *PBKDF2WithHMAC-SHA1AndDES-EDE3-CBC*.

    If :data:`pkcs8` is ``False``, the obsolete PEM encryption scheme is
    used. It is based on MD5 for key derivation, and Triple DES for
    encryption. Parameter :data:`protection` is then ignored.

    The combination ``format='DER'`` and ``pkcs8=False`` is not allowed
    if a passphrase is present.

  randfunc (callable):
    A function that returns random bytes.
    By default it is :func:`Crypto.Random.get_random_bytes`.

Returns:
  byte string : the encoded key

Raises:
  ValueError : when the format is unknown or when you try to encrypt a private
    key with *DER* format and OpenSSL/OpenSSH.

.. warning::
    If you don't provide a pass phrase, the private key will be
    exported in the clear!

.. _RFC1421:    http://www.ietf.org/rfc/rfc1421.txt
.. _RFC1423:    http://www.ietf.org/rfc/rfc1423.txt
.. _RFC4253:    http://www.ietf.org/rfc/rfc4253.txt
.. _`PKCS#8`:   http://www.ietf.org/rfc/rfc5208.txt
NOpenSSHc                 h    \        V ^ ,          4      ^,          '       d   \        ^ 4      V ,           # V # )ro   )r   r   r    s   &r.   funcDsaKey.export_key.<locals>.func  s(    1J%%7Q;&Hr1      ssh-dssr1   >I   ssh-dss Tz"PBKDF2WithHMAC-SHA1AndDES-EDE3-CBC)
key_paramsrandfunczENCRYPTED PRIVATEPRIVATEr   z#DSA private key cannot be encryptedzDSA PRIVATEz*PKCS#8 is only meaningful for private keysPUBLICDERz KEYz3Unknown key format '%s'. Cannot export the DSA key.)r   r   r   r   )r   r	   get_random_bytesr(   to_bytesr   structpacklenbinascii
b2a_base64r   r   r   r   r5   r   r!   encoder
   wrapoidr%   r   r   r   )r)   formatpkcs8
passphrase
protectionr   r!   tup1r   tup2keypartskp	keystringparamsprivate_key
binary_keykey_typeintspem_strs   &&&&&&             r.   
export_keyDsaKey.export_key   s>   v ! ,J..HY5IJ5IIIaL))+5IDJ &**TDGTD*"|d*HGOPxV[[s2w7"<<xPI !4!4Y!?!DDD dffdffdff56}!!EJ(0779"ZZ +S* *)1"

 2H(H!
U?z$%JKK466466466466466B(.557
( !MNN8 *466 2F<JHU?U?jj *Hv,= *G 7##NQWWXXs K + Qs   )J!J	0Jc                    \        R 4      hz'Use module Crypto.Signature.DSS insteadNotImplementedError)r)   MKs   &&&r.   signDsaKey.signU      !"KLLr1   c                    \        R 4      hr   r   )r)   r   	signatures   &&&r.   verifyDsaKey.verifyX  r   r1   c                    \         hr\   r   )r)   	plaintextr   s   &&&r.   encryptDsaKey.encrypt[      !!r1   c                    \         hr\   r   )r)   
ciphertexts   &&r.   decryptDsaKey.decrypt^  r   r1   c                    \         hr\   r   r)   r   Bs   &&&r.   blindDsaKey.blinda  r   r1   c                    \         hr\   r   r   s   &&&r.   unblindDsaKey.unblindd  r   r1   c                    \         hr\   r   rP   s   &r.   sizeDsaKey.sizeg  r   r1   rO   r   r   r   r   r!   )r   NNNN)r~   
__module____qualname____firstlineno____doc__re   r/   rD   rL   r5   rT   rX   ra   ri   rl   rr   ru   r   r   r   	exportKey	publickeyr   r   r   r   r   r   r   __static_attributes____classdictcell__)__classdict__s   @r.   r   r   N   s     , )H
# "	 
)&
BV'{Y| IIMM""""" "r1   c           
        R^R^RR/P                  V 4      pVf   \        RV ,          4      h\        P                  ^,          pW,           ^,
          V,          ^,
          pV ^,
          WC,          ,
          p\	        ^4      p^V^,
          ,          p\        Wa4      \        8w  d`   V! ^@4      p\        P                  ! \        P                  ! V4      P                  4       4      V^,
          ,          p	W,          ^,          pKs  VP                  4       V8X  g   Q h^p
^V ^,
          ,          p \        V^,           4       Uu. uFK  p\        P                  ! X\	        W,           4      P                  4       ,           4      P                  4       NKM  	  ppV Uu. uF  p\        P                  ! V4      NK  	  pp\        \        V4       Uu. uF  qV,          ^W,          ,          ,          NK!  	  upW,          ^V,          ^,
          ,          ^WC,          ,          ,          4      p\	        W,           4      pVP                  4       V 8X  g   Q hVV^,          ,          pVV^,
          ,
          pVP                  4       V 8X  d   \        VV4      \        8X  d   MW^,           ,          p
EK  V^,
          V,          p\        P                  ! ^4       F  pXR,           \!        ^4      ,           \	        V4      P                  4       ,           p	\        P                  ! \        P                  ! V	4      P                  4       4      p\#        VVV4      pV^8w  g   K   M	  VVXX3# u upi u upi u upi )z+Generate a new set of DSA domain parameters            zInvalid modulus length (%d)s   ggen)getr%   r   digest_sizer   r   r   
from_bytesnewdigestrz   r   r   sum	itertoolscountr   r9   )Lr   Noutlennb_r   	upper_bitseedUoffsetjVrK   iWXcr   er   r   s   &&                    r.   _generate_domainr   k  s    sDd3(,,Q/Ay6:;;!#F	
aF"Q&A	
Q!*	B 	
Aa!eI
a
*n
<|vzz$/6689Y]KMA>>q !  Fa!eI
!!a%(+(! jj
 3 < < >>?FFH( 	
 +-.0Qg  #Q0Z]C]1qz*++]C!r'Q'A!*,=>@ AM"~~1$%$QKQK>>q q(+~=a% 
Q1A#7NT!W$wu~'>'>'@@vzz!}33561aL6 $ q!T?3+0Cs   AM'M,%M1c           
        Vf   \         P                  pV'       d   \        \        V4      w  r4p\	        V4      \
        8H  pV\	        V4      \
        8H  ,          pWc^,
          V,          ^ 8g  ,          pYe^8*  ;'       g    WS8  ,          pV\        WTV4      ^8g  ,          pV'       d   \        R4      hM\        W4      w  r4rWVP                  4       pVP                  4       p	W8w  d   \        RW3,          4      hW3R9  d   \        RW3,          4      h^Tu;8  d   V8  g   M \        R4      h\        P                  ! V	^@,           VR7      p
W^,
          ,          ^,           p\        W[V4      pRVRVRVR	VR
V/p\        V4      # )a  Generate a new DSA key pair.

The algorithm follows Appendix A.1/A.2 and B.1 of `FIPS 186-4`_,
respectively for domain generation and key pair generation.

Args:
  bits (integer):
    Key length, or size (in bits) of the DSA modulus *p*.
    It must be 1024, 2048 or 3072.

  randfunc (callable):
    Random number generation function; it accepts a single integer N
    and return a string of random data N bytes long.
    If not specified, :func:`Crypto.Random.get_random_bytes` is used.

  domain (tuple):
    The DSA domain parameters *p*, *q* and *g* as a list of 3
    integers. Size of *p* and *q* must comply to `FIPS 186-4`_.
    If not specified, the parameters are created anew.

Returns:
  :class:`DsaKey` : a new DSA key object

Raises:
  ValueError : when **bits** is too little, too big, or not a multiple of 64.

.. _FIPS 186-4: http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.186-4.pdf
zInvalid DSA domain parametersz?Mismatch between size of modulus (%d) and 'bits' parameter (%d)z;Lengths of p and q (%d, %d) are not compatibleto FIPS 186-3zIncorrent DSA generator)
exact_bitsr   r   r   r   r   r!   ))r      )r      )r   r   )r   r   )r	   r   r:   r   r   r   r9   r%   r   rz   randomr   )r   r   ru   r   r   r   	fmt_error_r   r   r   r!   r   r*   s   &&&           r.   r   r     s   < **gv&a (*i7	(+y88	1uka''	!V%%qv%	Sq\Q&&	<==  &d5
a	A	Ay 69:	B C 	C 	
v 0 0 ),-62 3 	3 q919233 	!b&8<A	UaAA!AQAs1c!S4H(r1   c           	        \        \        R\        \        V 4      4      4      p\	        V4      pRpV'       Ed   \        VP                  4      \        8H  pV\        VP                  4      \        8H  ,          pWCP                  ^,
          VP                  ,          ^ 8g  ,          pYCP                  ^8*  ;'       g    VP                  VP                  8  ,          pV\        VP                  VP                  VP                  4      ^8g  ,          pYCP                  ^ 8*  ;'       g    VP                  VP                  8  ,          p\        VR4      '       dv   YCP                  ^ 8*  ;'       g    VP                  VP                  8  ,          pV\        VP                  VP                  VP                  4      VP                  8g  ,          pV'       d   \        R4      hV# )an  Construct a DSA key from a tuple of valid DSA components.

Args:
  tup (tuple):
    A tuple of long integers, with 4 or 5 items
    in the following order:

        1. Public key (*y*).
        2. Sub-group generator (*g*).
        3. Modulus, finite field order (*p*).
        4. Sub-group order (*q*).
        5. Private key (*x*). Optional.

  consistency_check (boolean):
    If ``True``, the library will verify that the provided components
    fulfil the main DSA properties.

Raises:
  ValueError: when the key being imported fails the most basic DSA validity checks.

Returns:
  :class:`DsaKey` : a DSA key object
r!   FzInvalid DSA key componentsr   )r'   zipr:   r   r   r   r   r   r   r   r9   r   r|   r!   r%   )tupconsistency_checkr*   keyr  s   &&   r.   	constructr	    sU   2 C13w3DEFH

CI'.);	(/9<<	uuqyCEE)a//	UUaZ11355CEE>1	Ssuu-22	UUaZ11355CEE>1	3!55suu~5ISUUCEE3551SUU::I566Jr1   c                     V'       d   \        R 4      h\        4       P                  V ^RR7      pV^ ,          ^ 8w  d   \        R4      hR Uu. uF  qCV,          NK  	  pp\        V4      # u upi )z-DSA private key already comes with parametersT)nr_elementsonly_ints_expectedzNo version found)               )r%   r   decoder	  )encodedr   r   derr>   r  s   &&&   r.   _import_openssl_privater  !  sh    HII
-

wA$

OC
1v{+,,!0
1t99C
1S> 2s   A+c                 B   \        V 4      w  r4pV\        8w  d   \        R 4      hV'       d   V'       d   \        R4      h\        4       P	                  V4      P
                  p\        \        4       P	                  T;'       g    T4      4      w  rxp	WiWx3p
\        V
4      # )zNo DSA subjectPublicKeyInfozToo many DSA parameters)	r   r   r%   r   r  valuelistr   r	  )r  r   r   algoidencoded_key
emb_paramsr   r   r   r   r  s   &&&        r.   _import_subjectPublicKeyInfor  +  s    'Fw'O#F}677*233K(..A;=''(<(<*=>GA!,CS>r1   c                 2    \        V 4      p\        VR V4      # r\   )r   r  )r  r   r   sp_infos   &&& r.   _import_x509_certr  9  s    .w7G'v>>r1   c                 n   V'       d   \        R 4      h\        P                  ! W4      pV^ ,          \        8w  d   \        R4      h\	        4       P                  V^,          4      P                  p\        \        4       P                  V^,          4      4      w  rVp\        WtV4      WuWd3p\        V4      # )z"PKCS#8 already includes parameterszNo PKCS#8 encoded DSA key)r%   r
   unwrapr   r   r  r  r  r   r9   r	  )	r  r   r   r=   r!   r   r   r   r  s	   &&&      r.   _import_pkcs8r"  ?  s    =>>W)Ats{455AaD!''A;=''!-.GA!qQ<q
$CS>r1   c                    \         \        \        \        3pV F  p V! WV4      u # 	  \	        R4      h  \         d     K*  i ; i)z?Import a DSA key (public or private half), encoded in DER form.DSA key format is not supported)r  r  r  r"  r%   )key_datar   r   	decodingsdecodings   &&&  r.   _import_key_derr(  K  sW     )-" I
 	H&99  6
77  		s   5AAc                *   \        V 4      p Ve   \        V4      pV P                  R4      '       d:   \        P                  ! \	        V 4      V4      w  r#pV'       d   Rp\        W!R4      # V P                  R4      '       d   \        P                  ! V P                  R4      ^,          4      p. p\        V4      ^8  dO   \        P                  ! RVR,          4      ^ ,          pVP                  V^^V,            4       V^V,           R pK^  V^ ,          R8X  d7   R	 Uu. uF  p\        P                  ! Wh,          4      NK!  	  p	p\        V	4      # \        V 4      ^ 8  d$   \!        V ^ ,          4      ^08X  d   \        WR4      # \#        R4      hu upi )
a  Import a DSA key.

Args:
  extern_key (string or byte string):
    The DSA key to import.

    The following formats are supported for a DSA **public** key:

    - X.509 certificate (binary DER or PEM)
    - X.509 ``subjectPublicKeyInfo`` (binary DER or PEM)
    - OpenSSH (ASCII one-liner, see `RFC4253`_)

    The following formats are supported for a DSA **private** key:

    - `PKCS#8`_ ``PrivateKeyInfo`` or ``EncryptedPrivateKeyInfo``
      DER SEQUENCE (binary or PEM)
    - OpenSSL/OpenSSH custom format (binary or PEM)

    For details about the PEM encoding, see `RFC1421`_/`RFC1423`_.

  passphrase (string):
    In case of an encrypted private key, this is the pass phrase
    from which the decryption key is derived.

    Encryption may be applied either at the `PKCS#8`_ or at the PEM level.

Returns:
  :class:`DsaKey` : a DSA key object

Raises:
  ValueError : when the given key cannot be parsed (possibly because
    the pass phrase is wrong).

.. _RFC1421: http://www.ietf.org/rfc/rfc1421.txt
.. _RFC1423: http://www.ietf.org/rfc/rfc1423.txt
.. _RFC4253: http://www.ietf.org/rfc/rfc4253.txt
.. _PKCS#8: http://www.ietf.org/rfc/rfc5208.txt
Ns   -----r       r   :Nr  Nr   r$  )r  r  r  r  )r   
startswithr   r  r   r(  r   
a2b_base64splitr   r   unpackr{   r   r   r	  r   r%   )

extern_keyr   r  markerenc_flagr   r   lengthr!   r  s
   &&        r.   
import_keyr3  \  sS   P $JZ(
X&&"%**U:->
"KhJs55[))''
(8(8(>q(AB	)nq ]]427:FOOIaF
34!!f*+.IA;*$<HILq7%%hk2LCIS>!
:tJqM2d:zt<<
6
77 Js    %Fz1.2.840.10040.4.1)r   r	  r   r3  )NNrW   r\   ).__all__r   r   r   Crypto.Util.py3compatr   r   r   r   r   Cryptor	   	Crypto.IOr
   r   Crypto.Hashr   Crypto.Util.asn1r   r   r   r   r   Crypto.Math.Numbersr   Crypto.Math.Primalityr   r   r   Crypto.PublicKeyr   r   r   objectr   r   r   r	  r  r  r  r"  r(  r3  	importKeyr   rS   r1   r.   <module>r?     s   2 =    H H      (3 3@ @@Z"V Z"z2jFR.p?	8"C8N 	 r1   