
    M je              	         S SK Jr  S SKrS SKrS SKrS SKJr  S SKJr  S SK	J
r  S SKJr  S SKJrJrJrJrJrJrJrJr  S SKJrJr  S S	KJrJrJr  S S
KJrJ r   S SK!J"r"  \R                  " SSS5      r#\RH                  \RJ                  \RL                  \RN                  \RP                  \RR                  \RT                  \RV                  \RX                  4   r- " S S\.5      r/      S$S jr0      S%S jr1S&S jr2 " S S5      r3 " S S5      r4 " S S\Rj                  5      r6 " S S\.5      r7\Rp                  r8\Rr                  r9\Rt                  r:\Rv                  r;\Rx                  r<\Rz                  r=\R|                  r>\R~                  r?\R                  r@\R                  rA\R                  rB " S S5      rC " S S5      rD " S S 5      rE " S! S"5      rFS'S# jrGg)(    )annotationsN)Iterable)utils)x509)hashes)dsaeced448ed25519paddingrsax448x25519) CertificateIssuerPrivateKeyTypesCertificatePublicKeyTypes)	ExtensionExtensionType_make_sequence_methods)Name	_ASN1Type)ObjectIdentifieri     c                  ,   ^  \ rS rSrSU 4S jjrSrU =r$ )AttributeNotFound5   c                0   > [         TU ]  U5        X l        g N)super__init__oid)selfmsgr    	__class__s      g/root/GenerationalWealth/GenerationalWealth/venv/lib/python3.13/site-packages/cryptography/x509/base.pyr   AttributeNotFound.__init__6   s        )r    )r"   strr    r   returnNone__name__
__module____qualname____firstlineno__r   __static_attributes____classcell__r#   s   @r$   r   r   5   s     r&   r   c                `    U H(  nUR                   U R                   :X  d  M  [        S5      e   g )Nz$This extension has already been set.)r    
ValueError)	extension
extensionses      r$   _reject_duplicate_extensionr7   ;   s*    
 55IMM!CDD r&   c                >    U H  u  n  nX :X  d  M  [        S5      e   g )Nz$This attribute has already been set.)r3   )r    
attributesattr_oid_s       r$   _reject_duplicate_attributer<   E   s%    
 %!Q?CDD %r&   c                    U R                   b@  U R                  5       nU(       a  UO[        R                  " 5       nU R	                  SS9U-
  $ U $ )zNormalizes a datetime to a naive datetime in UTC.

time -- datetime to normalize. Assumed to be in UTC if not timezone
        aware.
N)tzinfo)r>   	utcoffsetdatetime	timedeltareplace)timeoffsets     r$   _convert_to_naive_utc_timerE   O   sG     {{!!x'9'9';||4|(611r&   c                      \ rS rSr\R
                  R                  4       S
S jjr\SS j5       r	\SS j5       rSS jr
SS jrSS jrSrg	)	Attribute]   c                (    Xl         X l        X0l        g r   )_oid_value_type)r!   r    valuerL   s       r$   r   Attribute.__init__^   s     	
r&   c                    U R                   $ r   )rJ   r!   s    r$   r    Attribute.oidh   s    yyr&   c                    U R                   $ r   )rK   rP   s    r$   rM   Attribute.valuel   s    {{r&   c                >    SU R                    SU R                  < S3$ )Nz<Attribute(oid=z, value=)>)r    rM   rP   s    r$   __repr__Attribute.__repr__p   s     
(4::.CCr&   c                    [        U[        5      (       d  [        $ U R                  UR                  :H  =(       a9    U R                  UR                  :H  =(       a    U R
                  UR
                  :H  $ r   )
isinstancerG   NotImplementedr    rM   rL   )r!   others     r$   __eq__Attribute.__eq__s   sV    %++!! HH		! *

ekk)*

ekk)	
r&   c                Z    [        U R                  U R                  U R                  45      $ r   )hashr    rM   rL   rP   s    r$   __hash__Attribute.__hash__}   s     TXXtzz4::677r&   )rJ   rL   rK   N)r    r   rM   bytesrL   intr(   r)   )r(   r   )r(   rb   r(   r'   )r[   objectr(   boolr(   rc   )r+   r,   r-   r.   r   
UTF8StringrM   r   propertyr    rV   r\   r`   r/    r&   r$   rG   rG   ]   sv    
 ))//	  	
 
    D
8r&   rG   c                  R    \ rS rSr    SS jr\" S5      u  rrrS	S jr	S
S jr
Srg)
Attributes   c                $    [        U5      U l        g r   )list_attributes)r!   r9   s     r$   r   Attributes.__init__   s      
+r&   rp   c                "    SU R                    S3$ )Nz<Attributes(rU   rp   rP   s    r$   rV   Attributes.__repr__   s    d../r22r&   c                \    U  H  nUR                   U:X  d  M  Us  $    [        SU S3U5      e)NzNo z attribute was found)r    r   )r!   r    attrs      r$   get_attribute_for_oid Attributes.get_attribute_for_oid   s5    Dxx3   #cU*> ?EEr&   rs   N)r9   zIterable[Attribute]r(   r)   rd   )r    r   r(   rG   )r+   r,   r-   r.   r   r   __len____iter____getitem__rV   rw   r/   rj   r&   r$   rl   rl      s7    ,', 
, &<M%J"GX{3Fr&   rl   c                      \ rS rSrSrSrSrg)Version   r      rj   N)r+   r,   r-   r.   v1v3r/   rj   r&   r$   r}   r}      s    	
B	
Br&   r}   c                  ,   ^  \ rS rSrSU 4S jjrSrU =r$ )InvalidVersion   c                0   > [         TU ]  U5        X l        g r   )r   r   parsed_version)r!   r"   r   r#   s      r$   r   InvalidVersion.__init__   s    ,r&   )r   )r"   r'   r   rc   r(   r)   r*   r1   s   @r$   r   r      s    - -r&   r   c                      \ rS rSrS/ / 4     SS jjrSS jr      SS jrSS.       SS jjr SSSS.           SS	 jjjrS
r	g) CertificateSigningRequestBuilder   Nc                (    Xl         X l        X0l        g)z2
Creates an empty X.509 certificate request (v1).
N)_subject_name_extensionsrp   )r!   subject_namer5   r9   s       r$   r   )CertificateSigningRequestBuilder.__init__   s     *%%r&   c                    [        U[        5      (       d  [        S5      eU R                  b  [	        S5      e[        XR                  U R                  5      $ )z6
Sets the certificate requestor's distinguished name.
Expecting x509.Name object.&The subject name may only be set once.)rY   r   	TypeErrorr   r3   r   r   rp   r!   names     r$   r   -CertificateSigningRequestBuilder.subject_name   sS     $%%9::)EFF/""D$4$4
 	
r&   c                    [        U[        5      (       d  [        S5      e[        UR                  X!5      n[        X0R                  5        [        U R                  / U R                  QUPU R                  5      $ )z5
Adds an X.509 extension to the certificate request.
"extension must be an ExtensionType)
rY   r   r   r   r    r7   r   r   r   rp   r!   extvalcriticalr4   s       r$   add_extension.CertificateSigningRequestBuilder.add_extension   sm     &-00@AAfjj(;	#I/?/?@/*d*	*
 	
r&   )_tagc               x   [        U[        5      (       d  [        S5      e[        U[        5      (       d  [        S5      eUb   [        U[        5      (       d  [        S5      e[        XR                  5        Ub  UR                  nOSn[        U R                  U R                  / U R                  QXU4P5      $ )z;
Adds an X.509 attribute with an OID and associated value.
zoid must be an ObjectIdentifierzvalue must be bytesNztag must be _ASN1Type)rY   r   r   rb   r   r<   rp   rM   r   r   r   )r!   r    rM   r   tags        r$   add_attribute.CertificateSigningRequestBuilder.add_attribute   s     #/00=>>%''122JtY$?$?344#C)9)9:**CC/2d2S 12
 	
r&   rsa_paddingecdsa_deterministicc                  U R                   c  [        S5      eUbd  [        U[        R                  [        R
                  45      (       d  [        S5      e[        U[        R                  5      (       d  [        S5      eUb*  [        U[        R                  5      (       d  [        S5      e[        R                  " U UUUU5      $ )z6
Signs the request using the requestor's private key.
z/A CertificateSigningRequest must have a subjectPadding must be PSS or PKCS1v15&Padding is only supported for RSA keys1Deterministic ECDSA is only supported for EC keys)r   r3   rY   r   PSSPKCS1v15r   r   RSAPrivateKeyr	   EllipticCurvePrivateKey	rust_x509create_x509_csrr!   private_key	algorithmbackendr   r   s         r$   sign%CertificateSigningRequestBuilder.sign   s     %NOO"kGKK9I9I+JKK ABBk3+<+<== HII*k2+E+EFFG  ((
 	
r&   )rp   r   r   )r   Name | Noner5   list[Extension[ExtensionType]]r9   0list[tuple[ObjectIdentifier, bytes, int | None]])r   r   r(   r   )r   r   r   rf   r(   r   )r    r   rM   rb   r   z_ASN1Type | Noner(   r   r   )r   r   r   _AllowedHashTypes | Noner   
typing.Anyr   %padding.PSS | padding.PKCS1v15 | Noner   bool | Noner(   CertificateSigningRequest)
r+   r,   r-   r.   r   r   r   r   r   r/   rj   r&   r$   r   r      s     %)57GI	&!& 3& E	&


#
/3
	)
. "&

 

 
 
*
H #	!
 >B+/!
5!
 ,!
 	!
 ;!
 )!
 
#!
 !
r&   r   c                      \ rS rSr% S\S'   SSSSSS/ 4               SS jjrSS jrSS jr    SS jrSS	 jr	SS
 jr
SS jr      SS jr SSSS.           SS jjjrSrg)CertificateBuilderi$  r   r   Nc                    [         R                  U l        Xl        X l        X0l        X@l        XPl        X`l        Xpl	        g r   )
r}   r   _version_issuer_namer   _public_key_serial_number_not_valid_before_not_valid_afterr   )r!   issuer_namer   
public_keyserial_numbernot_valid_beforenot_valid_afterr5   s           r$   r   CertificateBuilder.__init__'  s9      

')%+!1 /%r&   c           	        [        U[        5      (       d  [        S5      eU R                  b  [	        S5      e[        UU R                  U R                  U R                  U R                  U R                  U R                  5      $ )z#
Sets the CA's distinguished name.
r   %The issuer name may only be set once.)rY   r   r   r   r3   r   r   r   r   r   r   r   r   s     r$   r   CertificateBuilder.issuer_name:  s{     $%%9::(DEE!""!!
 	
r&   c           	        [        U[        5      (       d  [        S5      eU R                  b  [	        S5      e[        U R                  UU R                  U R                  U R                  U R                  U R                  5      $ )z*
Sets the requestor's distinguished name.
r   r   )rY   r   r   r   r3   r   r   r   r   r   r   r   r   s     r$   r   CertificateBuilder.subject_nameL  s{     $%%9::)EFF!""!!
 	
r&   c           
        [        U[        R                  [        R                  [
        R                  [        R                  [        R                  [        R                  [        R                  45      (       d  [        S5      eU R                   b  [#        S5      e[%        U R&                  U R(                  UU R*                  U R,                  U R.                  U R0                  5      $ )zD
Sets the requestor's public key (as found in the signing request).
zExpecting one of DSAPublicKey, RSAPublicKey, EllipticCurvePublicKey, Ed25519PublicKey, Ed448PublicKey, X25519PublicKey, or X448PublicKey.z$The public key may only be set once.)rY   r   DSAPublicKeyr   RSAPublicKeyr	   EllipticCurvePublicKeyr   Ed25519PublicKeyr
   Ed448PublicKeyr   X25519PublicKeyr   X448PublicKeyr   r   r3   r   r   r   r   r   r   r   )r!   keys     r$   r   CertificateBuilder.public_key^  s         ))(($$&&""
 
 !  'CDD!""!!
 	
r&   c           	     l   [        U[        5      (       d  [        S5      eU R                  b  [	        S5      eUS::  a  [	        S5      eUR                  5       S:  a  [	        S5      e[        U R                  U R                  U R                  UU R                  U R                  U R                  5      $ )z%
Sets the certificate serial number.
'Serial number must be of integral type.'The serial number may only be set once.r   z%The serial number should be positive.   3The serial number should not be more than 159 bits.)rY   rc   r   r   r3   
bit_lengthr   r   r   r   r   r   r   r!   numbers     r$   r    CertificateBuilder.serial_number  s     &#&&EFF*FGGQ;DEE #%E  """!!
 	
r&   c           	        [        U[        R                  5      (       d  [        S5      eU R                  b  [	        S5      e[        U5      nU[        :  a  [	        S5      eU R                  b  XR                  :  a  [	        S5      e[        U R                  U R                  U R                  U R                  UU R                  U R                  5      $ )z'
Sets the certificate activation time.
Expecting datetime object.z*The not valid before may only be set once.z>The not valid before date must be on or after 1950 January 1).zBThe not valid before date must be before the not valid after date.)rY   r@   r   r   r3   rE   _EARLIEST_UTC_TIMEr   r   r   r   r   r   r   r!   rC   s     r$   r   #CertificateBuilder.not_valid_before  s     $ 1 122899!!-IJJ)$/$$$    ,8M8M1M  "!!
 	
r&   c           	        [        U[        R                  5      (       d  [        S5      eU R                  b  [	        S5      e[        U5      nU[        :  a  [	        S5      eU R                  b  XR                  :  a  [	        S5      e[        U R                  U R                  U R                  U R                  U R                  UU R                  5      $ )z'
Sets the certificate expiration time.
r   z)The not valid after may only be set once.z<The not valid after date must be on or after 1950 January 1.zAThe not valid after date must be after the not valid before date.)rY   r@   r   r   r3   rE   r   r   r   r   r   r   r   r   r   s     r$   r   "CertificateBuilder.not_valid_after  s     $ 1 122899  ,HII)$/$$N  "".---  """
 	
r&   c           
     N   [        U[        5      (       d  [        S5      e[        UR                  X!5      n[        X0R                  5        [        U R                  U R                  U R                  U R                  U R                  U R                  / U R                  QUP5      $ )z-
Adds an X.509 extension to the certificate.
r   )rY   r   r   r   r    r7   r   r   r   r   r   r   r   r   r   s       r$   r    CertificateBuilder.add_extension  s     &-00@AAfjj(;	#I/?/?@!""!!*d*	*
 	
r&   r   c               ~   U R                   c  [        S5      eU R                  c  [        S5      eU R                  c  [        S5      eU R                  c  [        S5      eU R
                  c  [        S5      eU R                  c  [        S5      eUbd  [        U[        R                  [        R                  45      (       d  [        S5      e[        U[        R                  5      (       d  [        S5      eUb*  [        U[        R                  5      (       d  [        S	5      e[         R"                  " U UUUU5      $ )
z3
Signs the certificate using the CA's private key.
z&A certificate must have a subject namez&A certificate must have an issuer namez'A certificate must have a serial numberz/A certificate must have a not valid before timez.A certificate must have a not valid after timez$A certificate must have a public keyr   r   r   )r   r3   r   r   r   r   r   rY   r   r   r   r   r   r   r	   r   r   create_x509_certificater   s         r$   r   CertificateBuilder.sign  s.    %EFF$EFF&FGG!!)NOO  (MNN#CDD"kGKK9I9I+JKK ABBk3+<+<== HII*k2+E+EFFG  00
 	
r&   )r   r   r   r   r   r   r   r   )r   r   r   r   r   z CertificatePublicKeyTypes | Noner   
int | Noner   datetime.datetime | Noner   r   r5   r   r(   r)   )r   r   r(   r   )r   r   r(   r   )r   rc   r(   r   )rC   datetime.datetimer(   r   )r   r   r   rf   r(   r   r   )r   r   r   r   r   r   r   r   r   r   r(   Certificate)r+   r,   r-   r.   __annotations__r   r   r   r   r   r   r   r   r   r/   rj   r&   r$   r   r   $  s   // $($(7;$(594857& & "& 5	&
 "& 3& 2& 3& 
&&
$
$#
&#
 
#
J
6
:
>
#
/3
	
4 #	0
 >B+/0
50
 ,0
 	0
 ;0
 )0
 
0
 0
r&   r   c                      \ rS rSr% S\S'   S\S'   SSS/ / 4         SS jjr    SS jr    SS	 jr    SS
 jr      SS jr	    SS jr
 SSSS.           SS jjjrSrg) CertificateRevocationListBuilderi#  r   r   list[RevokedCertificate]_revoked_certificatesNc                @    Xl         X l        X0l        X@l        XPl        g r   )r   _last_update_next_updater   r   )r!   r   last_updatenext_updater5   revoked_certificatess         r$   r   )CertificateRevocationListBuilder.__init__'  s"     (''%%9"r&   c                    [        U[        5      (       d  [        S5      eU R                  b  [	        S5      e[        UU R                  U R                  U R                  U R                  5      $ )Nr   r   )
rY   r   r   r   r3   r   r   r   r   r   )r!   r   s     r$   r   ,CertificateRevocationListBuilder.issuer_name5  si     +t,,9::(DEE/&&
 	
r&   c                   [        U[        R                  5      (       d  [        S5      eU R                  b  [	        S5      e[        U5      nU[        :  a  [	        S5      eU R                  b  XR                  :  a  [	        S5      e[        U R                  UU R                  U R                  U R                  5      $ )Nr   !Last update may only be set once.8The last update date must be on or after 1950 January 1.z9The last update date must be before the next update date.)rY   r@   r   r   r3   rE   r   r   r   r   r   r   )r!   r   s     r$   r   ,CertificateRevocationListBuilder.last_updateD  s     +x'8'899899(@AA0=++J  ([;L;L-LK  0&&
 	
r&   c                   [        U[        R                  5      (       d  [        S5      eU R                  b  [	        S5      e[        U5      nU[        :  a  [	        S5      eU R                  b  XR                  :  a  [	        S5      e[        U R                  U R                  UU R                  U R                  5      $ )Nr   r  r  z8The next update date must be after the last update date.)rY   r@   r   r   r3   rE   r   r   r   r   r   r   )r!   r   s     r$   r   ,CertificateRevocationListBuilder.next_update\  s     +x'8'899899(@AA0=++J  ([;L;L-LJ  0&&
 	
r&   c                "   [        U[        5      (       d  [        S5      e[        UR                  X!5      n[        X0R                  5        [        U R                  U R                  U R                  / U R                  QUPU R                  5      $ )z=
Adds an X.509 extension to the certificate revocation list.
r   )rY   r   r   r   r    r7   r   r   r   r   r   r   r   s       r$   r   .CertificateRevocationListBuilder.add_extensiont  s     &-00@AAfjj(;	#I/?/?@/*d*	*&&
 	
r&   c                    [        U[        5      (       d  [        S5      e[        U R                  U R
                  U R                  U R                  / U R                  QUP5      $ )z(
Adds a revoked certificate to the CRL.
z)Must be an instance of RevokedCertificate)	rY   RevokedCertificater   r   r   r   r   r   r   )r!   revoked_certificates     r$   add_revoked_certificate8CertificateRevocationListBuilder.add_revoked_certificate  sd     -/ABBGHH/>d((>*=>
 	
r&   r   c                  U R                   c  [        S5      eU R                  c  [        S5      eU R                  c  [        S5      eUbd  [	        U[
        R                  [
        R                  45      (       d  [        S5      e[	        U[        R                  5      (       d  [        S5      eUb*  [	        U[        R                  5      (       d  [        S5      e[        R                  " U UUUU5      $ )NzA CRL must have an issuer namez"A CRL must have a last update timez"A CRL must have a next update timer   r   r   )r   r3   r   r   rY   r   r   r   r   r   r   r	   r   r   create_x509_crlr   s         r$   r   %CertificateRevocationListBuilder.sign  s     $=>>$ABB$ABB"kGKK9I9I+JKK ABBk3+<+<== HII*k2+E+EFFG  ((
 	
r&   )r   r   r   r   r   )
r   r   r   r   r   r   r5   r   r   r   )r   r   r(   r   )r   r   r(   r   )r   r   r(   r   )r   r   r   rf   r(   r   )r  r  r(   r   r   )r   r   r   r   r   r   r   r   r   r   r(   CertificateRevocationList)r+   r,   r-   r.   r   r   r   r   r   r   r  r   r/   rj   r&   r$   r   r   #  s   //33 $(0404579;: : .: .	:
 3: 7:

	)

,
	)
0
,
	)
0
#
/3
	)
&
#5
	)
* #	$
 >B+/$
5$
 ,$
 	$
 ;$
 )$
 
#$
 $
r&   r   c                  r    \ rS rSrSS/ 4     S	S jjrS
S jr    SS jr      SS jrSSS jjrSr	g)RevokedCertificateBuilderi  Nc                (    Xl         X l        X0l        g r   )r   _revocation_dater   )r!   r   revocation_dater5   s       r$   r   "RevokedCertificateBuilder.__init__  s     , /%r&   c                   [        U[        5      (       d  [        S5      eU R                  b  [	        S5      eUS::  a  [	        S5      eUR                  5       S:  a  [	        S5      e[        XR                  U R                  5      $ )Nr   r   r   z$The serial number should be positiver   r   )	rY   rc   r   r   r3   r   r  r  r   r   s     r$   r   'RevokedCertificateBuilder.serial_number  s    &#&&EFF*FGGQ;CDD #%E  )))4+;+;
 	
r&   c                   [        U[        R                  5      (       d  [        S5      eU R                  b  [	        S5      e[        U5      nU[        :  a  [	        S5      e[        U R                  XR                  5      $ )Nr   z)The revocation date may only be set once.z7The revocation date must be on or after 1950 January 1.)
rY   r@   r   r  r3   rE   r   r  r   r   r   s     r$   r  )RevokedCertificateBuilder.revocation_date  s~     $ 1 122899  ,HII)$/$$I  )'7'7
 	
r&   c                    [        U[        5      (       d  [        S5      e[        UR                  X!5      n[        X0R                  5        [        U R                  U R                  / U R                  QUP5      $ )Nr   )
rY   r   r   r   r    r7   r   r  r   r  r   s       r$   r   'RevokedCertificateBuilder.add_extension  sm     &-00@AAfjj(;	#I/?/?@(!!*d*	*
 	
r&   c                    U R                   c  [        S5      eU R                  c  [        S5      e[        R                  " U 5      $ )Nz/A revoked certificate must have a serial numberz1A revoked certificate must have a revocation date)r   r3   r  r   create_revoked_certificate)r!   r   s     r$   buildRevokedCertificateBuilder.build  sI    &NOO  (C  33D99r&   )r   r  r   )r   r   r  r   r5   r   )r   rc   r(   r  )rC   r   r(   r  )r   r   r   rf   r(   r  r   )r   r   r(   r  )
r+   r,   r-   r.   r   r   r  r   r"  r/   rj   r&   r$   r  r    so     %)4857	&!& 2& 3	&
$
%
	"
 
#
/3
	"
: :r&   r  c                 \    [         R                  [        R                  " S5      S5      S-	  $ )N   bigr   )rc   
from_bytesosurandomrj   r&   r$   random_serial_numberr*    s     >>"**R.%0A55r&   )r4   zExtension[ExtensionType]r5   r   r(   r)   )r    r   r9   r   r(   r)   )rC   r   r(   r   rg   )H
__future__r   r@   r(  typingcollections.abcr   cryptographyr   "cryptography.hazmat.bindings._rustr   r   cryptography.hazmat.primitivesr   )cryptography.hazmat.primitives.asymmetricr   r	   r
   r   r   r   r   r   /cryptography.hazmat.primitives.asymmetric.typesr   r   cryptography.x509.extensionsr   r   r   cryptography.x509.namer   r   cryptography.x509.oidr   r   UnionSHA224SHA256SHA384SHA512SHA3_224SHA3_256SHA3_384SHA3_512_AllowedHashTypes	Exceptionr   r7   r<   rE   rG   rl   Enumr}   r   r   r  r  r   load_pem_x509_certificateload_der_x509_certificateload_pem_x509_certificatesload_pem_x509_csrload_der_x509_csrload_pem_x509_crlload_der_x509_crlr   r   r   r  r*  rj   r&   r$   <module>rI     s  
 #  	  $  @ 1	 	 	 
 3 2&&tQ2  LL
MM
MM
MM
MM
OO
OO
OO
OO	 	 E'E.E 
EE	E@E 
E!8 !8HF F(ejj 
-Y - ##11  &?? %??  &?? %?? &AA // // // // m
 m
`|
 |
~Y
 Y
xB: B:J6r&   