o
    <‘ðii<  ã                   @  s<  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 rEd dlZej	Z	ejdk r8ej
Z
ejZejZejZne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d	�Ze d
¡Zejde	d�Zejdd�G dd„ dejeef ƒƒZejZejZd:dd„Zd;dd„Zd<dd „Zd=d#d$„Z d>d(d)„Z!d?d-d.„Z"d?d/d0„Z#ejdk rÒej$dd1�d@d2d3„ƒZ%ej$dd1�d@d4d5„ƒZ&nej$dd1�d@d6d3„ƒZ%ej$dd1�d@d7d5„ƒZ&ejdd�G d8d9„ d9eje ƒƒZ'ej(Z(ej)j*Z*ej)j+Z+ej,Z,ej-Z-ej.Z.ej/Z/ej0Z0ej1Z1ej2Z3ej4Z4dS )Aé    )ÚannotationsN)é   é   )r   é	   ©r   é
   )Údeclarative_asn1ÚTT)Ú	covariantÚUÚTag)Úbound)Úfrozenc                   @  s"   e Zd ZU dZded< ded< dS )Ú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__© r   r   ú\/root/parts/websockify/install/lib/python3.10/site-packages/cryptography/hazmat/asn1/asn1.pyr   2   s   
 r   Ú
field_typeÚtypeÚreturnÚboolc                 C  s*   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)r   Úunion_typesr   r   r   Ú	_is_unionM   s
   ÿýr%   ÚmetadataÚtupleÚ
field_namer   údeclarative_asn1.Annotationc                 C  s°   d }d }d }| D ]G}t |tƒr|d urtd|› d�ƒ‚|j}qt |tjƒr4|d ur1td|› d�ƒ‚|}qt |tjƒrI|d urFtd|› d�ƒ‚|}qtd|› �ƒ‚tj|||d�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)r&   r(   r+   r,   r-   Úraw_annotationr   r   r   Ú_extract_annotationY   s<   
ÿÿÿÿ
ÿÿr5   ú
typing.Anyúdeclarative_asn1.AnnotatedTypec                   s²  t | ƒtu rt| jˆƒ}t| ƒ^} }nt ¡ }|jd ur8t | ƒtj	t
fvr8| tjtjtttfvr8tdˆ› d�ƒ‚| tu rWt|jtƒrJtdˆ› d�ƒ‚|jd urWtdˆ› d�ƒ‚t| dƒr|| j}t|tjjtjjfƒsqtd|› �ƒ‚t t tj|¡|¡S t| ƒ�rt| ƒ}t|ƒdkrÅt |v rÅ|d t!d ƒu r›|d	 n|d }|tu r§td
ƒ‚t"|ˆƒ}|j# $¡ sµtdƒ‚|jd ur¾tdƒ‚tj %|¡}nŽt|jtƒrÏtdƒ‚‡fdd„|D ƒ}	|	d	 j&d u‰ t'‡ fdd„|	D ƒƒrîtdƒ‚ˆ �rdd„ |	D ƒ}
t|	ƒt|
ƒk�rtdƒ‚tj (|	¡}t |v �rtj %t |t ¡ ¡¡n|}n4t | ƒtj	u �r7t"t| ƒd	 ˆƒ}tj )|¡}nt | ƒt
u �rNt"t| ƒd	 ˆƒ}tj 
|¡}nt *| ¡}t ||¡S )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 supportedzƒoptional (`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                   s"   g | ]}|t d ƒurt|ˆ ƒ‘qS ©N)r   Ú_type_to_variant)Ú.0Úarg)r(   r   r   Ú
<listcomp>Ô   s
    þz)_normalize_field_type.<locals>.<listcomp>c                 3  s   � | ]
}|j d uˆ kV  qd S r;   ©Útag_name©r=   Úv)Úare_union_types_taggedr   r   Ú	<genexpr>Ý   s
   € ÿ
ÿz(_normalize_field_type.<locals>.<genexpr>zbWhen using `asn1.Variant` in a union, all the other types in the union must also be `asn1.Variant`c                 S  s   h | ]}|j ’qS r   r@   rB   r   r   r   Ú	<setcomp>ç   s    z(_normalize_field_type.<locals>.<setcomp>zBWhen using `asn1.Variant` in a union, the tags used must be unique)+r#   Ú	Annotatedr5   Ú__metadata__Úget_type_argsr   r3   r-   ÚbuiltinsÚlistÚSetOfÚbytesr   Ú	BitStringÚ	IA5StringÚPrintableStringr0   ÚTLVr.   r,   ÚImplicitr+   r   r8   ÚTypeÚSequenceÚSetÚAnnotatedTyper!   Úcastr%   ÚlenÚNoneTyper   Ú_normalize_field_typeÚ
annotationÚis_emptyÚOptionrA   ÚanyÚChoiceÚ
SequenceOfÚnon_root_python_to_rust)r   r(   r[   Ú_Ú	root_typeÚ
union_argsÚoptional_typeÚannotated_typeÚrust_field_typeÚvariantsÚtagsÚrust_choice_typeÚ
inner_typer   )rD   r(   r   rZ   |   sÀ   
ûÿ	
ÿ
ÿ

ÿ
þÿ
ÿÿ

ÿ
ÿÿ
þþÿÿ
ûÿÿù
ÿÿ
rZ   Útúdeclarative_asn1.Variantc           	      C  sÂ   t | ƒtu }|rt| ƒd n| }t |ƒtu rWt|ƒ\}}t |ƒtjur'tdƒ‚t|ƒd }t|dƒr6|j}nt	 
|¡}|rHt	 |t| j|ƒ¡}nt	 |t	 ¡ ¡}t	 t||¡S t	 |t| |ƒd ¡S )Nr   z˜When using `asn1.Variant` in a type annotation, the second type parameter must be a `typing.Literal` type. E.g: `Variant[int, typing.Literal["MyInt"]]`.r8   )r#   rG   rI   r   r!   ÚLiteralr0   r   r8   r   ra   rV   r5   rH   r3   rZ   )	rl   r(   Úis_annotatedrk   Ú
value_typeÚtag_literalrA   Ú	rust_typeÚann_typer   r   r   r<     s6   ÿ


þþýr<   Ú
raw_fieldsúdict[str, type]ú)dict[str, declarative_asn1.AnnotatedType]c                 C  s,   i }|   ¡ D ]\}}t||ƒ}|||< q|S r;   )ÚitemsrZ   )rt   Úfieldsr(   r   Úannotated_field_typer   r   r   Ú_annotate_fields7  s
   

rz   Úclsútype[U]ÚNonec                 C  ó.   t | dd�}tj | t|ƒ¡}t| d|ƒ d S ©NT)Úinclude_extrasr8   )Úget_type_hintsr   rS   rT   rz   Úsetattr©r{   rt   Úrootr   r   r   Ú_register_asn1_sequenceD  ó   r…   c                 C  r~   r   )r�   r   rS   rU   rz   r‚   rƒ   r   r   r   Ú_register_asn1_setK  r†   r‡   )Úkw_only_defaultc                 C  ó@   t jdkrtjddddd�| ƒ}n	tjddd�| ƒ}t|ƒ |S ©Nr   FT©ÚreprÚeqÚ
match_argsÚkw_only)rŒ   r�   )ÚsysÚversion_infoÚdataclassesÚ	dataclassr…   ©r{   Údataclass_clsr   r   r   ÚsequenceZ  ó"   
ø	÷þýr–   c                 C  r‰   rŠ   )r�   r‘   r’   r“   r‡   r”   r   r   r   Úsetq  r—   r˜   c                 C  ó"   t jddddd�| ƒ}t|ƒ |S ©NFTr‹   )r’   r“   r…   r”   r   r   r   r–   Š  ó   üûc                 C  r™   rš   )r’   r“   r‡   r”   r   r   r   r˜   —  r›   c                   @  s   e Zd ZU ded< dS )r/   r   r   N)r   r   r   r   r   r   r   r   r/   ¦  s   
 r/   )r   r   r   r   )r&   r'   r(   r   r   r)   )r   r6   r(   r   r   r7   )rl   r6   r(   r   r   rm   )rt   ru   r   rv   )r{   r|   r   r}   )r{   r|   r   r|   )5Ú
__future__r   rJ   r’   r�   r    r!   r‘   Útyping_extensionsÚLiteralStringr�   Úget_argsrI   Ú
get_originr#   rG   r   rY   Ú"cryptography.hazmat.bindings._rustr   ÚTypeVarr	   r   r   r“   ÚGenericr   Ú
decode_derÚ
encode_derr%   r5   rZ   r<   rz   r…   r‡   Údataclass_transformr–   r˜   r/   rL   r1   ÚExplicitrR   r2   rP   rO   ÚUTCTimeÚGeneralizedTimerN   ÚTlvrQ   ÚNullr   r   r   r   Ú<module>   s€   








# 

+








