
    ِ              	         S SK Jr  S SKrS SK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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Jr  S SKJrJrJrJ r   S S	K!J"r"J#r#  S S
K$J%r%  \R                  " SSS5      r&\RN                  \RP                  \RR                  \RT                  \RV                  \RX                  \RZ                  \R\                  \R^                  4   r0 " S S\15      r2      S.S jr3      S/S jr4S0S jr5 " S S5      r6 " S S5      r7 " S S\Rp                  5      r9 " S S\15      r: " S S\Rv                  S9r<\<R{                  \Rx                  5         " S S\Rv                  S9r>\>R{                  \R|                  5         " S S \>5      r? " S! S"\Rv                  S9r@\@R{                  \R                  5         " S# S$\Rv                  S9rA\AR{                  \R                  5        \R                  rB\R                  rC\R                  rD\R                  rE\R                  rF\R                  rG\R                  rH " S% S&5      rI " S' S(5      rJ " S) S*5      rK " S+ S,5      rLS1S- jrMg)2    )annotationsN)utils)x509)hashesserialization)dsaeced448ed25519paddingrsax448x25519) CertificateIssuerPrivateKeyTypesCertificateIssuerPublicKeyTypesCertificatePublicKeyTypes)	Extension
ExtensionsExtensionType_make_sequence_methods)Name	_ASN1Type)ObjectIdentifieri     c                  ,   ^  \ rS rSrSU 4S jjrSrU =r$ )AttributeNotFound8   c                0   > [         TU ]  U5        X l        g N)super__init__oid)selfmsgr"   	__class__s      Qplatform/bundledpythonunix/lib/python3.13/site-packages/cryptography/x509/base.pyr!   AttributeNotFound.__init__9   s        )r"   )r$   strr"   r   returnNone__name__
__module____qualname____firstlineno__r!   __static_attributes____classcell__r%   s   @r&   r   r   8   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_extensionr9   >   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.)r5   )r"   
attributesattr_oid_s       r&   _reject_duplicate_attributer>   H   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)rA   	utcoffsetdatetime	timedeltareplace)timeoffsets     r&   _convert_to_naive_utc_timerH   R   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"   valuerO   s       r&   r!   Attribute.__init__a   s     	
r(   c                    U R                   $ r   )rM   r#   s    r&   r"   Attribute.oidk   s    yyr(   c                    U R                   $ r   )rN   rS   s    r&   rP   Attribute.valueo   s    {{r(   c                >    SU R                    SU R                  < S3$ )Nz<Attribute(oid=z, value=)>)r"   rP   rS   s    r&   __repr__Attribute.__repr__s   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   )
isinstancerJ   NotImplementedr"   rP   rO   r#   others     r&   __eq__Attribute.__eq__v   sV    %++!! HH		! *

ekk)*

ekk)	
r(   c                Z    [        U R                  U R                  U R                  45      $ r   )hashr"   rP   rO   rS   s    r&   __hash__Attribute.__hash__   s     TXXtzz4::677r(   )rM   rO   rN   N)r"   r   rP   bytesrO   intr*   r+   r*   r   r*   rf   r*   r)   r_   objectr*   boolr*   rg   )r-   r.   r/   r0   r   
UTF8StringrP   r!   propertyr"   rY   r`   rd   r1    r(   r&   rJ   rJ   `   sv    
 ))//	  	
 
    D
8r(   rJ   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#   r;   s     r&   r!   Attributes.__init__   s      
+r(   rw   c                "    SU R                    S3$ )Nz<Attributes(rX   rw   rS   s    r&   rY   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(   rz   N)r;   ztyping.Iterable[Attribute]r*   r+   rj   )r"   r   r*   rJ   )r-   r.   r/   r0   r!   r   __len____iter____getitem__rY   r~   r1   rq   r(   r&   rs   rs      s7    ,., 
, &<M%J"GX{3Fr(   rs   c                      \ rS rSrSrSrSrg)Version   r      rq   N)r-   r.   r/   r0   v1v3r1   rq   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   rg   r*   r+   r,   r3   s   @r&   r   r      s    - -r(   r   c                  ,   \ rS rSr\R
                  SS j5       r\\R
                  SS j5       5       r\\R
                  SS j5       5       r	\R
                  SS j5       r
\\R
                  SS j5       5       r\\R
                  SS j5       5       r\\R
                  SS j5       5       r\\R
                  SS	 j5       5       r\\R
                  SS
 j5       5       r\\R
                  S S j5       5       r\\R
                  S S j5       5       r\\R
                    S!S j5       5       r\\R
                  SS j5       5       r\\R
                    S"S j5       5       r\\R
                  S#S j5       5       r\\R
                  S$S j5       5       r\\R
                  S$S j5       5       r\\R
                  S$S j5       5       r\R
                  S%S j5       r\R
                  SS j5       r\R
                  S&S j5       r\R
                  S'S j5       rSrg)(Certificate   c                    gz$
Returns bytes using digest passed.
Nrq   r#   	algorithms     r&   fingerprintCertificate.fingerprint       r(   c                    g)z#
Returns certificate serial number
Nrq   rS   s    r&   serial_numberCertificate.serial_number   r   r(   c                    g)z!
Returns the certificate version
Nrq   rS   s    r&   versionCertificate.version   r   r(   c                    gz
Returns the public key
Nrq   rS   s    r&   
public_keyCertificate.public_key   r   r(   c                    g)z1
Returns the ObjectIdentifier of the public key.
Nrq   rS   s    r&   public_key_algorithm_oid$Certificate.public_key_algorithm_oid   r   r(   c                    g)z/
Not before time (represented as UTC datetime)
Nrq   rS   s    r&   not_valid_beforeCertificate.not_valid_before   r   r(   c                    g)z;
Not before time (represented as a non-naive UTC datetime)
Nrq   rS   s    r&   not_valid_before_utc Certificate.not_valid_before_utc   r   r(   c                    g)z.
Not after time (represented as UTC datetime)
Nrq   rS   s    r&   not_valid_afterCertificate.not_valid_after   r   r(   c                    g)z:
Not after time (represented as a non-naive UTC datetime)
Nrq   rS   s    r&   not_valid_after_utcCertificate.not_valid_after_utc   r   r(   c                    g)z!
Returns the issuer name object.
Nrq   rS   s    r&   issuerCertificate.issuer   r   r(   c                    gz"
Returns the subject name object.
Nrq   rS   s    r&   subjectCertificate.subject   r   r(   c                    gz\
Returns a HashAlgorithm corresponding to the type of the digest signed
in the certificate.
Nrq   rS   s    r&   signature_hash_algorithm$Certificate.signature_hash_algorithm   r   r(   c                    gz:
Returns the ObjectIdentifier of the signature algorithm.
Nrq   rS   s    r&   signature_algorithm_oid#Certificate.signature_algorithm_oid   r   r(   c                    gz-
Returns the signature algorithm parameters.
Nrq   rS   s    r&   signature_algorithm_parameters*Certificate.signature_algorithm_parameters   r   r(   c                    g)z
Returns an Extensions object.
Nrq   rS   s    r&   r7   Certificate.extensions	  r   r(   c                    gz
Returns the signature bytes.
Nrq   rS   s    r&   	signatureCertificate.signature  r   r(   c                    g)zB
Returns the tbsCertificate payload bytes as defined in RFC 5280.
Nrq   rS   s    r&   tbs_certificate_bytes!Certificate.tbs_certificate_bytes  r   r(   c                    g)zP
Returns the tbsCertificate payload bytes with the SCT list extension
stripped.
Nrq   rS   s    r&   tbs_precertificate_bytes$Certificate.tbs_precertificate_bytes  r   r(   c                    gz
Checks equality.
Nrq   r^   s     r&   r`   Certificate.__eq__&  r   r(   c                    gz
Computes a hash.
Nrq   rS   s    r&   rd   Certificate.__hash__,  r   r(   c                    g)z2
Serializes the certificate to PEM or DER format.
Nrq   r#   encodings     r&   public_bytesCertificate.public_bytes2  r   r(   c                    g)z
This method verifies that certificate issuer name matches the
issuer subject name and that the certificate is signed by the
issuer's private key. No other validation is performed.
Nrq   )r#   r   s     r&   verify_directly_issued_by%Certificate.verify_directly_issued_by8  r   r(   rq   Nr   zhashes.HashAlgorithmr*   rf   rn   )r*   r   r*   r   rh   r*   datetime.datetimer*   r   r*   zhashes.HashAlgorithm | Noner*   z0None | padding.PSS | padding.PKCS1v15 | ec.ECDSAr*   r   ri   rk   r   zserialization.Encodingr*   rf   )r   r   r*   r+   )r-   r.   r/   r0   abcabstractmethodr   rp   r   r   r   r   r   r   r   r   r   r   r   r   r   r7   r   r   r   r`   rd   r   r   r1   rq   r(   r&   r   r      s    
   
   
 	 
   
   
   
   
   
   
   
 	$     
 	9     
   
   
    	 
 	 
 	 
 	 r(   r   )	metaclassc                      \ rS rSr\\R                  SS j5       5       r\\R                  S	S j5       5       r\\R                  S	S j5       5       r	\\R                  S
S j5       5       r
Srg)RevokedCertificateiE  c                    g)z7
Returns the serial number of the revoked certificate.
Nrq   rS   s    r&   r    RevokedCertificate.serial_numberF  r   r(   c                    g)z8
Returns the date of when this certificate was revoked.
Nrq   rS   s    r&   revocation_date"RevokedCertificate.revocation_dateM  r   r(   c                    g)zT
Returns the date of when this certificate was revoked as a non-naive
UTC datetime.
Nrq   rS   s    r&   revocation_date_utc&RevokedCertificate.revocation_date_utcT  r   r(   c                    g)zG
Returns an Extensions object containing a list of Revoked extensions.
Nrq   rS   s    r&   r7   RevokedCertificate.extensions\  r   r(   rq   Nrn   r   r   )r-   r.   r/   r0   rp   r   r   r   r   r   r7   r1   rq   r(   r&   r   r   E  s      
   
      r(   r   c                  z    \ rS rSr      S	S jr\S
S j5       r\SS j5       r\SS j5       r\SS j5       r	Sr
g)_RawRevokedCertificateih  c                (    Xl         X l        X0l        g r   _serial_number_revocation_date_extensionsr#   r   r   r7   s       r&   r!   _RawRevokedCertificate.__init__i       , /%r(   c                    U R                   $ r   )r   rS   s    r&   r   $_RawRevokedCertificate.serial_numbers  s    """r(   c                b    [         R                  " S[        R                  SS9  U R                  $ )Nuk   Properties that return a naïve datetime object have been deprecated. Please switch to revocation_date_utc.r   )
stacklevel)warningswarnr   DeprecatedIn42r   rS   s    r&   r   &_RawRevokedCertificate.revocation_datew  s.    @  		
 $$$r(   c                d    U R                   R                  [        R                  R                  S9$ )Nr@   )r   rE   rC   timezoneutcrS   s    r&   r   *_RawRevokedCertificate.revocation_date_utc  s(    $$,,H4E4E4I4I,JJr(   c                    U R                   $ r   )r   rS   s    r&   r7   !_RawRevokedCertificate.extensions  s    r(   r   r   r   N)r   rg   r   r   r7   r   rn   r   r   )r-   r.   r/   r0   r!   rp   r   r   r   r7   r1   rq   r(   r&   r   r   h  su    && +& 	& # # % % K K    r(   r   c                     \ rS rSr\R
                  SS j5       r\R
                  SS j5       r\R
                      SS j5       r\	\R
                    SS j5       5       r
\	\R
                  SS j5       5       r\	\R
                    SS j5       5       r\	\R
                  SS j5       5       r\	\R
                  S S	 j5       5       r\	\R
                  S S
 j5       5       r\	\R
                  S!S j5       5       r\	\R
                  S!S j5       5       r\	\R
                  S"S j5       5       r\	\R
                  S#S j5       5       r\	\R
                  S#S j5       5       r\R
                  S$S j5       r\R
                  S%S j5       r\R0                  S&S j5       r\R0                  S'S j5       r\R
                      S(S j5       r\R
                  S)S j5       r\R
                      S*S j5       rSrg)+CertificateRevocationListi  c                    g)z*
Serializes the CRL to PEM or DER format.
Nrq   r   s     r&   r   &CertificateRevocationList.public_bytes  r   r(   c                    gr   rq   r   s     r&   r   %CertificateRevocationList.fingerprint  r   r(   c                    g)z[
Returns an instance of RevokedCertificate or None if the serial_number
is not in the CRL.
Nrq   )r#   r   s     r&   (get_revoked_certificate_by_serial_numberBCertificateRevocationList.get_revoked_certificate_by_serial_number  r   r(   c                    gr   rq   rS   s    r&   r   2CertificateRevocationList.signature_hash_algorithm  r   r(   c                    gr   rq   rS   s    r&   r   1CertificateRevocationList.signature_algorithm_oid  r   r(   c                    gr   rq   rS   s    r&   r   8CertificateRevocationList.signature_algorithm_parameters  r   r(   c                    g)z3
Returns the X509Name with the issuer of this CRL.
Nrq   rS   s    r&   r    CertificateRevocationList.issuer  r   r(   c                    g)z/
Returns the date of next update for this CRL.
Nrq   rS   s    r&   next_update%CertificateRevocationList.next_update  r   r(   c                    g)zK
Returns the date of next update for this CRL as a non-naive UTC
datetime.
Nrq   rS   s    r&   next_update_utc)CertificateRevocationList.next_update_utc  r   r(   c                    g)z/
Returns the date of last update for this CRL.
Nrq   rS   s    r&   last_update%CertificateRevocationList.last_update  r   r(   c                    g)zK
Returns the date of last update for this CRL as a non-naive UTC
datetime.
Nrq   rS   s    r&   last_update_utc)CertificateRevocationList.last_update_utc  r   r(   c                    g)zC
Returns an Extensions object containing a list of CRL extensions.
Nrq   rS   s    r&   r7   $CertificateRevocationList.extensions  r   r(   c                    gr   rq   rS   s    r&   r   #CertificateRevocationList.signature  r   r(   c                    g)z?
Returns the tbsCertList payload bytes as defined in RFC 5280.
Nrq   rS   s    r&   tbs_certlist_bytes,CertificateRevocationList.tbs_certlist_bytes  r   r(   c                    gr   rq   r^   s     r&   r`    CertificateRevocationList.__eq__  r   r(   c                    g)z,
Number of revoked certificates in the CRL.
Nrq   rS   s    r&   r   !CertificateRevocationList.__len__  r   r(   c                    g r   rq   r#   idxs     r&   r   %CertificateRevocationList.__getitem__   s    ;>r(   c                    g r   rq   r9  s     r&   r   r;    s    CFr(   c                    g)zC
Returns a revoked certificate (or slice of revoked certificates).
Nrq   r9  s     r&   r   r;    r   r(   c                    g)z(
Iterator over the revoked certificates
Nrq   rS   s    r&   r   "CertificateRevocationList.__iter__  r   r(   c                    g)zA
Verifies signature of revocation list against given public key.
Nrq   )r#   r   s     r&   is_signature_valid,CertificateRevocationList.is_signature_valid  r   r(   rq   Nr   r   )r   rg   r*   zRevokedCertificate | Noner   rh   r   r   )r*   datetime.datetime | Noner   r   ri   rk   rn   )r:  rg   r*   r   )r:  slicer*   list[RevokedCertificate])r:  zint | slicer*   z-RevokedCertificate | list[RevokedCertificate])r*   z#typing.Iterator[RevokedCertificate])r   r   r*   rm   )r-   r.   r/   r0   r   r   r   r   r  rp   r   r   r   r   r"  r%  r(  r+  r7   r   r2  r`   r   typingoverloadr   r   rA  r1   rq   r(   r&   r  r    s    
 	 
 	 	"  	$     
 	9     
   
      
      
   
   
 	 
 	 
 __> >__F F	6  	 
 	9	 r(   r  c                     \ rS rSr\R
                  SS j5       r\R
                  SS j5       r\R
                  SS j5       r\	\R
                  SS j5       5       r
\	\R
                    SS j5       5       r\	\R
                  SS j5       5       r\	\R
                    SS j5       5       r\	\R
                  SS	 j5       5       r\	\R
                  SS
 j5       5       r\R
                  SS j5       r\	\R
                  SS j5       5       r\	\R
                  SS j5       5       r\	\R
                  SS j5       5       r\R
                  SS j5       rSrg)CertificateSigningRequesti   c                    gr   rq   r^   s     r&   r`    CertificateSigningRequest.__eq__!  r   r(   c                    gr   rq   rS   s    r&   rd   "CertificateSigningRequest.__hash__'  r   r(   c                    gr   rq   rS   s    r&   r   $CertificateSigningRequest.public_key-  r   r(   c                    gr   rq   rS   s    r&   r   !CertificateSigningRequest.subject3  r   r(   c                    gr   rq   rS   s    r&   r   2CertificateSigningRequest.signature_hash_algorithm:  r   r(   c                    gr   rq   rS   s    r&   r   1CertificateSigningRequest.signature_algorithm_oidD  r   r(   c                    gr   rq   rS   s    r&   r   8CertificateSigningRequest.signature_algorithm_parametersK  r   r(   c                    g)z0
Returns the extensions in the signing request.
Nrq   rS   s    r&   r7   $CertificateSigningRequest.extensionsT  r   r(   c                    g)z
Returns an Attributes object.
Nrq   rS   s    r&   r;   $CertificateSigningRequest.attributes[  r   r(   c                    g)z+
Encodes the request to PEM or DER format.
Nrq   r   s     r&   r   &CertificateSigningRequest.public_bytesb  r   r(   c                    gr   rq   rS   s    r&   r   #CertificateSigningRequest.signatureh  r   r(   c                    g)zL
Returns the PKCS#10 CertificationRequestInfo bytes as defined in RFC
2986.
Nrq   rS   s    r&   tbs_certrequest_bytes/CertificateSigningRequest.tbs_certrequest_byteso  r   r(   c                    g)z(
Verifies signature of signing request.
Nrq   rS   s    r&   rA  ,CertificateSigningRequest.is_signature_validw  r   r(   c                    g)z*
Get the attribute value for a given OID.
Nrq   )r#   r"   s     r&   r~   /CertificateSigningRequest.get_attribute_for_oid~  r   r(   rq   Nrk   rn   r   r   r   rh   r   r   )r*   rs   r   ri   )r*   rm   )r"   r   r*   rf   )r-   r.   r/   r0   r   r   r`   rd   r   rp   r   r   r   r   r7   r;   r   r   ra  rA  r~   r1   rq   r(   r&   rI  rI     s    
 	 
 	 
   
 	$     
 	9     
   
 	 
   
      
 	 r(   rI  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	 jjjrS
r	g) CertificateSigningRequestBuilderi  Nc                (    Xl         X l        X0l        g)z2
Creates an empty X.509 certificate request (v1).
N)_subject_namer   rw   )r#   subject_namer7   r;   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.)r\   r   	TypeErrorrj  r5   rh  r   rw   r#   names     r&   rk  -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)
r\   r   rp  r   r"   r9   r   rh  rj  rw   r#   extvalcriticalr6   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)r\   r   rp  rf   r   r>   rw   rP   rh  rj  r   )r#   r"   rP   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_paddingc               .   U R                   c  [        S5      eUbd  [        U[        R                  [        R
                  45      (       d  [        S5      e[        U[        R                  5      (       d  [        S5      e[        R                  " XX$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 keys)rj  r5   r\   r   PSSPKCS1v15rp  r   RSAPrivateKey	rust_x509create_x509_csrr#   private_keyr   backendr  s        r&   sign%CertificateSigningRequestBuilder.sign  s     %NOO"kGKK9I9I+JKK ABBk3+<+<== HII((y
 	
r(   )rw   r   rj  )rk  Name | Noner7   list[Extension[ExtensionType]]r;   0list[tuple[ObjectIdentifier, bytes, int | None]])rr  r   r*   rh  )rw  r   rx  rm   r*   rh  )r"   r   rP   rf   r{  z_ASN1Type | Noner*   rh  r   )
r  r   r   _AllowedHashTypes | Noner  
typing.Anyr  %padding.PSS | padding.PKCS1v15 | Noner*   rI  )
r-   r.   r/   r0   r!   rk  ry  r~  r  r1   rq   r(   r&   rh  rh    s     %)57GI	&!& 3& E	&


#
/3
	)
. "&

 

 
 
*
H #	
 >B
5
 ,
 	
 ;
 
#
 
r(   rh  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 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_namerj  _public_keyr   _not_valid_before_not_valid_afterr   )r#   issuer_namerk  r   r   r   r   r7   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.
rn  %The issuer name may only be set once.)r\   r   rp  r  r5   r  rj  r  r   r  r  r   rq  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.
rn  ro  )r\   r   rp  rj  r5   r  r  r  r   r  r  r   rq  s     r&   rk  CertificateBuilder.subject_name"  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.)r\   r   DSAPublicKeyr   RSAPublicKeyr	   EllipticCurvePublicKeyr   Ed25519PublicKeyr
   Ed448PublicKeyr   X25519PublicKeyr   X448PublicKeyrp  r  r5   r  r  rj  r   r  r  r   )r#   keys     r&   r   CertificateBuilder.public_key4  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.)r\   rg   rp  r   r5   
bit_lengthr  r  rj  r  r  r  r   r#   numbers     r&   r    CertificateBuilder.serial_numberY  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.)r\   rC   rp  r  r5   rH   _EARLIEST_UTC_TIMEr  r  r  rj  r  r   r   r#   rF   s     r&   r   #CertificateBuilder.not_valid_beforet  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.)r\   rC   rp  r  r5   rH   r  r  r  r  rj  r  r   r   r  s     r&   r   "CertificateBuilder.not_valid_after  s     $ 1 122899  ,HII)$/$$# 
 "".---  """
 	
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.
ru  )r\   r   rp  r   r"   r9   r   r  r  rj  r  r   r  r  rv  s       r&   ry   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[        R                  " XX$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  )rj  r5   r  r   r  r  r  r\   r   r  r  rp  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00y
 	
r(   )r   r  r  r  r  r   rj  r  )r  r  rk  r  r   z CertificatePublicKeyTypes | Noner   
int | Noner   rC  r   rC  r7   r  r*   r+   )rr  r   r*   r  )r  r   r*   r  )r  rg   r*   r  )rF   r   r*   r  )rw  r   rx  rm   r*   r  r   )
r  r   r   r  r  r  r  r  r*   r   )r-   r.   r/   r0   __annotations__r!   r  rk  r   r   r   r   ry  r  r1   rq   r(   r&   r  r    s   // $($(7;$(594857& & "& 5	&
 "& 3& 2& 3& 
&&
$
$#
&#
 
#
J
6
:
@
#
/3
	
4 #	%
 >B%
5%
 ,%
 	%
 ;%
 
%
 %
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 jjjrSrg) CertificateRevocationListBuilderi  r  r   rE  _revoked_certificatesNc                @    Xl         X l        X0l        X@l        XPl        g r   )r  _last_update_next_updater   r  )r#   r  r(  r"  r7   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      $ )Nrn  r  )
r\   r   rp  r  r5   r  r  r  r   r  )r#   r  s     r&   r  ,CertificateRevocationListBuilder.issuer_name  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.)r\   rC   rp  r  r5   rH   r  r  r  r  r   r  )r#   r(  s     r&   r(  ,CertificateRevocationListBuilder.last_update  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.)r\   rC   rp  r  r5   rH   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.
ru  )r\   r   rp  r   r"   r9   r   r  r  r  r  r  rv  s       r&   ry  .CertificateRevocationListBuilder.add_extension@  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)	r\   r   rp  r  r  r  r  r   r  )r#   revoked_certificates     r&   add_revoked_certificate8CertificateRevocationListBuilder.add_revoked_certificateS  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[        R                  " XX$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  r5   r  r  r\   r   r  r  rp  r   r  r  create_x509_crlr  s        r&   r  %CertificateRevocationListBuilder.signd  s     $=>>$ABB$ABB"kGKK9I9I+JKK ABBk3+<+<== HII((y
 	
r(   )r   r  r  r  r  )
r  r  r(  rC  r"  rC  r7   r  r  rE  )r  r   r*   r  )r(  r   r*   r  )r"  r   r*   r  )rw  r   rx  rm   r*   r  )r  r   r*   r  r   )
r  r   r   r  r  r  r  r  r*   r  )r-   r.   r/   r0   r  r!   r  r(  r"  ry  r  r  r1   rq   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   r   s       r&   r!   "RevokedCertificateBuilder.__init__  r   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  )	r\   rg   rp  r   r5   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.)
r\   rC   rp  r   r5   rH   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      $ )Nru  )
r\   r   rp  r   r"   r9   r   r  r   r   rv  s       r&   ry  '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[        U R                   U R                  [	        U R
                  5      5      $ )Nz/A revoked certificate must have a serial numberz1A revoked certificate must have a revocation date)r   r5   r   r   r   r   )r#   r  s     r&   buildRevokedCertificateBuilder.build  se    &NOO  (C  &!!t''(
 	
r(   r  )r   r  r   rC  r7   r  )r  rg   r*   r  )rF   r   r*   r  )rw  r   rx  rm   r*   r  r   )r  r  r*   r   )
r-   r.   r/   r0   r!   r   r   ry  r  r1   rq   r(   r&   r  r    so     %)4857	&!& 2& 3	&
$
%
	"
 
#
/3
	"

 
r(   r  c                 \    [         R                  [        R                  " S5      S5      S-	  $ )N   bigr   )rg   
from_bytesosurandomrq   r(   r&   random_serial_numberr    s     >>"**R.%0A55r(   )r6   zExtension[ExtensionType]r7   r  r*   r+   )r"   r   r;   r  r*   r+   )rF   r   r*   r   rn   )N
__future__r   r   rC   r  rF  r  cryptographyr   "cryptography.hazmat.bindings._rustr   r  cryptography.hazmat.primitivesr   r   )cryptography.hazmat.primitives.asymmetricr   r	   r
   r   r   r   r   r   /cryptography.hazmat.primitives.asymmetric.typesr   r   r   cryptography.x509.extensionsr   r   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   r9   r>   rH   rJ   rs   Enumr   r   ABCMetar   registerr   r   r  rI  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_crlrh  r  r  r  r  rq   r(   r&   <module>r     sy  
 # 
  	    @ @	 	 	 
  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 -[CKK [~   Y** +3;; @   I88 9 /  DP#++ Pf  " "9#F#F Gb#++ bL  " "9#F#F G &?? %?? &AA // // // // b
 b
Jr
 r
jN
 N
bF
 F
R6r(   