
    2ii<                       d dl mZ d dlZd dlZd dlZd dlZd dlZej                  dk  rd dlZej                  Z	ej                  dk  r1ej                  Z
ej                  Zej                  Zej                  Znmej                  Z
ej                  Zej                  Zej                  Zn<ej                  Z
ej                  Zej                  Zej                  Zej                  Z	ej                  dk  r	 ed      Znej"                  Zd dlmZ  ej(                  dd	      Z ej(                  d
      Z ej(                  de	      Z ej0                  d       G d dej2                  eef                Zej6                  Zej8                  ZddZ	 	 	 	 	 	 ddZ	 	 	 	 	 	 d dZ	 	 	 	 	 	 d!dZ 	 	 	 	 d"dZ!d#dZ"d#dZ#ej                  dk  r5 ejH                  d      d$d       Z% ejH                  d      d$d       Z&n4 ejH                  d      d$d       Z% ejH                  d      d$d       Z& ej0                  d       G d dej2                  e                Z'ejP                  Z(ejR                  jT                  Z*ejR                  jV                  Z+ejX                  Z,ejZ                  Z-ej\                  Z.ej^                  Z/ej`                  Z0ejb                  Z1ejd                  Z3ejh                  Z4y)%    )annotationsN)      )r   	   r   
   )declarative_asn1TT)	covariantUTag)bound)frozenc                  &    e Zd ZU dZded<   ded<   y)Varianta  
    A tagged variant for CHOICE fields with the same underlying type.

    Use this when you have multiple CHOICE alternatives with the same type
    and need to distinguish between them:

        foo: (
            Annotated[Variant[int, typing.Literal["IntA"]], Implicit(0)]
            | Annotated[Variant[int, typing.Literal["IntB"]], Implicit(1)]
        )

    Usage:
        example = Example(foo=Variant(5, "IntA"))
        decoded.foo.value  # The int value
        decoded.foo.tag    # "IntA" or "IntB"
    r   valuestrtagN)__name__
__module____qualname____doc____annotations__     S/var/www/html/qr/venv/lib/python3.12/site-packages/cryptography/hazmat/asn1/asn1.pyr   r   2   s    " H	Hr   r   c                    t        t        d      r t        j                  t        j                  fnt        j                  f}t        |       |v S )N	UnionType)hasattrtypesr   typingUnionget_type_origin)
field_typeunion_typess     r   	_is_unionr&   M   s@     5+& 
&,,'ll_ 
 :&+55r   c                z   d }d }d }| D ]  }t        |t              r|t        d| d      |j                  }1t        |t        j
                        r|t        d| d      |}_t        |t        j                        r|t        d| d      |}t        d|        t	        j                  |||      S )Nz-multiple DEFAULT annotations found in field ''z7multiple IMPLICIT/EXPLICIT annotations found in field 'z*multiple SIZE annotations found in field 'zunsupported annotation: )defaultencodingsize)
isinstanceDefault	TypeErrorr   r	   EncodingSize
Annotation)metadata
field_namer)   r*   r+   raw_annotations         r   _extract_annotationr5   Y   s    GHD" Ing.""|1&  %**G(8(A(AB#"|1&  &H(8(=(=>@AN  "D6~6FGHH-I0 &&( r   c                   t        |       t        u r$t        | j                  |      }t	        |       ^} }nt        j                         }|j                  at        |       t        j                  t        fvr@| t        j                  t        j                  t        t        t        fvrt!        d| d      | t"        u rDt%        |j&                  t(              rt!        d| d      |j*                  t!        d| d      t-        | d      r| j.                  }t%        |t
        j0                  j2                  t
        j0                  j4                  f      st!        d|       t        j6                  t9        j:                  t
        j0                  |      |      S t=        |       rt	        |       }t?        |      dk(  rt@        |v r|d   tC        d       u r|d	   n|d   }|t"        u rt!        d
      tE        ||      }|jF                  jI                         st!        d      |j*                  t!        d      t
        j0                  jK                  |      }nt%        |j&                  t(              rt!        d      |D 	cg c]  }	|	tC        d       urtM        |	|       }
}	|
d	   jN                  d utQ        fd|
D              rt!        d      r;|
D ch c]  }|jN                   }}t?        |
      t?        |      k7  rt!        d      t
        j0                  jS                  |
      }t@        |v rEt
        j0                  jK                  t        j6                  |t        j                                     n|}nt        |       t        j                  u r8tE        t	        |       d	   |      }t
        j0                  jU                  |      }n^t        |       t        u r8tE        t	        |       d	   |      }t
        j0                  j                  |      }nt        jV                  |       }t        j6                  ||      S c c}	w c c}w )Nzfield 'z' has a SIZE annotation, but SIZE annotations are only supported for fields of types: [SEQUENCE OF, SET OF, BIT STRING, OCTET STRING, UTF8String, PrintableString, IA5String]zW' has an IMPLICIT annotation, but IMPLICIT annotations are not supported for TLV types.zT' has a DEFAULT annotation, but DEFAULT annotations are not supported for TLV types.__asn1_root__zunsupported root type:       r   z=optional TLV types (`TLV | None`) are not currently supportedzoptional (`X | None`) types cannot have `X` annotated: annotations must apply to the union (i.e: `Annotated[X | None, annotation]`)z@optional (`X | None`) types should not have a DEFAULT annotationzCCHOICE (`X | Y | ...`) types should not have an IMPLICIT annotationc              3  @   K   | ]  }|j                   d uk7    y wN)tag_name).0vare_union_types_taggeds     r   	<genexpr>z(_normalize_field_type.<locals>.<genexpr>   s(       4',BBs   zbWhen using `asn1.Variant` in a union, all the other types in the union must also be `asn1.Variant`zBWhen using `asn1.Variant` in a union, the tags used must be unique),r#   	Annotatedr5   __metadata__get_type_argsr	   r1   r+   builtinslistSetOfbytesr   	BitString	IA5StringPrintableStringr.   TLVr,   r*   Implicitr)   r   r7   TypeSequenceSetAnnotatedTyper!   castr&   lenNoneTypetype_normalize_field_type
annotationis_emptyOption_type_to_variantr<   anyChoice
SequenceOfnon_root_python_to_rust)r$   r3   rV   _	root_type
union_argsoptional_typeannotated_typerust_field_typeargvariantsr>   tagsrust_choice_type
inner_typer?   s                  @r   rU   rU   |   sC   
 z"i/()@)@*M
&z2
Q%002
"
#HMM5+AANNLL

 j\ "* *
 	
 Sj))84* &H H  +* &G G 
 z?+,,	""++-=-B-B-F-FG
 5i[ABB--KK(--y9:
 	
 
:	":.
z?aH
$: ",A$t*!<
1*Q-  #*  3=*MN!,,557?  !!-! 
 /33::>JO *--x8!  &d4j( !j1H  &.a[%9%9%E" !   E 
 &,45q

55x=CI-#) 
  044;;HE z) !%%,,$22(*:*E*E*G &  
	$	5**%a(*

 +//:::F		$	-**%a(*

 +//55jA*BB:N))/:FFg& 6s    Q$Qc                l   t        |       t        u }|rt        |       d   n| }t        |      t        u rt        |      \  }}t        |      t        j
                  urt        d      t        |      d   }t        |d      r|j                  }nt        j                  |      }|r+t        j                  |t        | j                  |            }n(t        j                  |t        j                               }t        j                  t        ||      S t        j                  |t        | |      d       S )Nr   zWhen using `asn1.Variant` in a type annotation, the second type parameter must be a `typing.Literal` type. E.g: `Variant[int, typing.Literal["MyInt"]]`.r7   )r#   rA   rC   r   r!   Literalr.   r   r7   r	   r]   rP   r5   rB   r1   rU   )	tr3   is_annotatedrh   
value_typetag_literalr<   	rust_typeann_types	            r   rY   rY     s    #1%2L(4q!!$!J z"g-"/
";
K;'v~~=; 
 !-a0:/"00I(@@LI'55#ANNJ?H
 (55 ++-H
  ''8DD  ''!!Z0
 	
r   c                \    i }| j                         D ]  \  }}t        ||      }|||<    |S r;   )itemsrU   )
raw_fieldsfieldsr3   r$   annotated_field_types        r   _annotate_fieldsrv   7  sF     F","2"2"4 2
J  5ZL1z	2 Mr   c                    t        | d      }t        j                  j                  | t	        |            }t        | d|       y NT)include_extrasr7   )get_type_hintsr	   rM   rN   rv   setattrclsrs   roots      r   _register_asn1_sequencer   D  s8    D9J  ))#/?
/KLDC$'r   c                    t        | d      }t        j                  j                  | t	        |            }t        | d|       y rx   )rz   r	   rM   rO   rv   r{   r|   s      r   _register_asn1_setr   K  s8    D9J  $$S*::*FGDC$'r   )kw_only_defaultc                    t         j                  dk\  r  t        j                  dddd      |       }n t        j                  dd      |       }t	        |       |S Nr   FTrepreq
match_argskw_only)r   r   )sysversion_infodataclasses	dataclassr   r}   dataclass_clss     r   sequencer   Z  st     w&	K11 ! 	 	MK11 M 	 .r   c                    t         j                  dk\  r  t        j                  dddd      |       }n t        j                  dd      |       }t	        |       |S r   )r   r   r   r   r   r   s     r   setr   q  st     w&	K11 ! 	 	MK11 M 	=)r   c                Z     t        j                  dddd      |       }t        |       |S NFTr   )r   r   r   r   s     r   r   r     s<    
--	

  	 .r   c                Z     t        j                  dddd      |       }t        |       |S r   )r   r   r   r   s     r   r   r     s<    
--	

  	=)r   c                      e Zd ZU ded<   y)r-   r   r   N)r   r   r   r   r   r   r   r-   r-     s    Hr   r-   )r$   rT   returnbool)r2   tupler3   r   r   zdeclarative_asn1.Annotation)r$   
typing.Anyr3   r   r   zdeclarative_asn1.AnnotatedType)rk   r   r3   r   r   zdeclarative_asn1.Variant)rs   zdict[str, type]r   z)dict[str, declarative_asn1.AnnotatedType])r}   type[U]r   None)r}   r   r   r   )5
__future__r   rD   r   r   r    r!   r   typing_extensionsLiteralStringrz   get_argsrC   
get_originr#   rA   rT   rS   "cryptography.hazmat.bindings._rustr	   TypeVarr
   r   r   r   Genericr   
decode_der
encode_derr&   r5   rU   rY   rv   r   r   dataclass_transformr   r   r-   rF   r/   ExplicitrL   r0   rJ   rI   UTCTimeGeneralizedTimerH   TlvrK   Nullr   r   r   <module>r      sH  
 #   
  g%33M
 & *99)22+66%//	.. ++$$	**NOOM''O  I((MgDzH~~H ?FNN3$'FNN3fnnU-0 d#fnnQV$  $, ((
((
	6  !$   FKGKG(+KG#KG`(
(
"(
(
V

.
(( g***4@ A, +**4@ A0  V5
 6
  V5
 6
 d#fnnQ  $ 	$$--$$--"22&&	

"
""22&&	r   