XjJRddlmZddlZddlZddlZddlZddlZddlZejdkrddl Z e jZ n ejZ ddl m Z ddl m Zejdkr edZn ej Zej"dd Zej"d Zej"d e Zej*d Gddej,eefZe j0Ze j2Zej4ej6ej8fZ d!dZd"dZd#dZ d$dZ! d%dZ" d&dZ# d'dZ$d(dZ%d(dZ&ejdkr5e jNdd)dZ(e jNdd)dZ)n4ejNdd)dZ(ejNdd)dZ) d*dZ*ej*d Gdd ej,eZ+e jXZ,e jZj\Z.e jZj^Z/e j`Z0e jbZ1e jdZ2e jfZ3e jhZ4e jjZ5e jlZ7e jpZ8y)+) annotationsN) )declarative_asn1)x509r TT) covariantUTag)bound)frozenc&eZdZUdZded<ded<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 valuestrtagN)__name__ __module__ __qualname____doc____annotations__q/mnt/ssd/data/Dropbox/adrian/vault-secondbrain/venv/lib/python3.12/site-packages/cryptography/hazmat/asn1/asn1.pyrr"s" H Hrrch|tvr*t|jtrt d|dyy)Nfield 'zY' has an IMPLICIT annotation, but IMPLICIT annotations are not supported for X.509 types.) _X509_TYPES isinstanceencodingImplicit TypeError) field_type annotation field_names r_check_x509_field_annotationsr'DsD [ Z 0C0CX%Nj\"F F  &O rcttdr tjtjfntjf}tj ||vS)N UnionType)hasattrtypesr)typingUnion get_origin)r$ union_typess r _is_unionr0PsF 5+ & &,,'ll_   Z (K 77rcvtjdkr|St|tjr'|j }t|tjr'tj |}td|D}||k(r|St|rtj|Stj||S)N)r c32K|]}t|ywN)_resolve_type_aliases).0args r z(_resolve_type_aliases..isE/4Es) sys version_infor r, TypeAliasType __value__get_argstupler0r-r.)r$args resolved_argss rr5r5\s  '! Z!5!5 6))  Z!5!5 6 ??: &DEEEM||M**   Z ( 77rczd}d}d}|D]}t|tr|td|d|j}1t|tj r|td|d|}_t|tj r|td|d|}td|t j|||S)Nz-multiple DEFAULT annotations found in field ''z7multiple IMPLICIT/EXPLICIT annotations found in field 'z*multiple SIZE annotations found in field 'zunsupported annotation: )defaultr!size)r Defaultr#rrEncodingSize Annotation)metadatar&rCr!rDraw_annotations r_extract_annotationrKsGH D"I ng .""|1&%**G (8(A(A B#"|1&&H (8(=(= >@ AN"D6~6FGH H-I0  & &( rc t|}tj|tjur.t |j |}tj |^}}ntj}|jktj|tjtfvr@|tjtjtt t"fvrt%d|d|t&urDt)|j*t,rt%d|d|j.t%d|dt1|||t3|dr|j4}t)|tj6j8tj6j:tj6j<fst%d|tj>tj@tj6||StC|rtj |}tE|dk(rtF|vr|dtIdur|d n|d}|t&ur t%d t1|||tK||}|jLjOs t%d |j. t%d tj6jQ|}nt)|j*t,r t%d |D cgc]} | tIdur tS| |} } | d jTdutWfd| Dr t%dr;| D chc]} | jT} } tE| tE| k7r t%dtj6jY| } tF|vrEtj6jQtj>| tjn| }ntj|tjurBtKtj |d |}tj6j[|}nrtj|turBtKtj |d |}tj6j|}ntj\|}tj>||Scc} wcc} w)Nrz' 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__zunsupported root type: rz=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 annotationc3@K|]}|jduk7ywr4)tag_name)r6vare_union_types_taggeds rr8z(_normalize_field_type..s(4',BBszbWhen 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)/r5r,r. AnnotatedrK __metadata__r=rrHrDbuiltinslistSetOfbytesr BitString IA5StringPrintableStringr#TLVr r!r"rCr'r*rMTypeSequenceSetValueSet AnnotatedTypecastr0lenNoneTypetype_normalize_field_typer%is_emptyOption_type_to_variantrQanyChoice SequenceOfnon_root_python_to_rust)r$r&r%_ root_type union_args optional_typeannotated_typerust_field_typer7variantsrRtagsrust_choice_type inner_typerSs @rrgrgs'z2J$(8(88()@)@*M 4 Q%002 "*%hmmU-CC  NN LL      j\"* *  S j))8 4*&HH    +*&GG  "*j*Ez?+,,   %%.. %%)) %%..  5i[AB B-- KK(--y 9:   : __Z0 z?a H $:",A$t*!< 1 *Q- #* *z: 3=*MN!,,557? !!-! /33::>JO*--x8! &d4j(!j1H&.a[%9%9%E "! E &,45q 55x=CI-#) 044;;HE z) !%%,,$22(*:*E*E*G &    : &(-- 7* OOJ ' *J +//:::F   : &% /* OOJ ' *J +//55jA*BB:N  ) )/: FFg&6s < S)S.ctj|tju}|rtj|dn|}tj|turtj|\}}tj|tj ur t dtj|d}t|dr |j}ntj|}|r+tj|t|j|}n(tj|tj}tjt||Stj|t||dS)NrzWhen using `asn1.Variant` in a type annotation, the second type parameter must be a `typing.Literal` type. E.g: `Variant[int, typing.Literal["MyInt"]]`.rM)r,r.rTr=rLiteralr#r*rMrrnrbrKrUrHrg) tr& is_annotatedrx value_type tag_literalrQ rust_typeann_types rrjrj@sB$$Q'6+;+;;L*6#A&AJ$/"(//*"= K   [ ) ?;  ??;/2 : /"00I(@@LI '55#ANNJ?H (55 ++-H  ''8DD ''  !!Z 0   rc\i}|jD]\}}t||}|||<|Sr4)itemsrg) raw_fieldsfieldsr&r$annotated_field_types r_annotate_fieldsrksFF","2"2"42 J 5ZL1z 2 Mrctj|d}tjj |t |}t |d|yNT)include_extrasrM)r,get_type_hintsrr^r_rsetattrclsrroots r_register_asn1_sequencerxs>&&s4@J  ) )#/? /K LD C$'rctj|d}tjj |t |}t |d|yr)r,rrr^r`rrrs r_register_asn1_setrs>&&s4@J  $ $S*::*F GD C$'r)kw_only_defaultctjdk\r tjdddd|}ntjdd|}t ||SNrFTrepreq match_argskw_only)rr)r9r: dataclasses dataclassrr dataclass_clss rsequencerst   w & K11!  MK11M .rctjdk\r tjdddd|}ntjdd|}t ||Sr)r9r:rrrrs rsetrst   w & K11!  MK11M =)rcZtjdddd|}t||SNFTr)rrrrs rrrs< --    .rcZtjdddd|}t||Sr)rrrrs rrrs< --    =)rcBtjdfd }|S)a" A class decorator that registers an `enum.Enum` subclass as an ASN.1 value set of the given underlying type. All the member values must be instances of `value_type`. Members are encoded as their value; decoding fails if the decoded value does not match any member. c ht|tjs tdt |}|std|j d|D]k}t |jrtd|jd|j dj dt|jj d tjtj}|Dcic]}|j|}}tjj|||}t|d ||Scc}w) Nz8value sets can only be defined from enum.Enum subclassesz value set 'z' must have at least one memberzmember 'z' of value set 'z' must have a value of type 'z ', got: 'rBrM) issubclassenumEnumr#rWrr rnamerfrrbrHr^rar)rmembersmemberinner value_maprrr}s r decoratorzvalue_set..decorators3#tyy)J s)cll^+JK  FfllJ7v{{m+;CLL>J"++,-V\\*334A7 !.. '224  9@@fV\\6)@ @$$--c5)D_d+ As)D/rtype[U]returnr)rrn)r}rrs` @r value_setrs"!88DI: rceZdZUded<y)rEr rN)rrrrrrrrErEs HrrE)r$ typing.Anyr%declarative_asn1.Annotationr&rrNone)r$rfrbool)r$rrr)rIr>r&rrr)r$rr&rrzdeclarative_asn1.AnnotatedType)r{rr&rrzdeclarative_asn1.Variant)rzdict[str, type]rz)dict[str, declarative_asn1.AnnotatedType])rrrrr)r}rfrz#typing.Callable[[type[U]], type[U]])9 __future__rrVrrr9r+r,r:typing_extensions LiteralString"cryptography.hazmat.bindings._rustrr rust_x509rfreTypeVarr r r rGenericr decode_der encode_der CertificateCertificateSigningRequestCertificateRevocationListrr'r0r5rKrgrjrrrdataclass_transformrrrrErXrFExplicitr"rGr\r[UTCTimeGeneralizedTimerZTlvr]Nullrrrrs' # g%33M((M?@gDzH~~HFNN3$'FNN3fnnU-0d# fnnQV$ $ , ( (  ( (  '' ''     +       8!8H  !$   FXGXG(+XG#XGz( ( "( ( V  . ((g***4@A,+**4@A0 V5 6  V5 6 ))()Zd# fnnQ $    $ $ - -  $ $ - -"22  & &  " ""22  & & r