o
    Þ­j„9  ã                   @  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 r'd dlZej	Z	nej	Z	d dl
mZ ejdk r:edƒZnej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d9dd„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ejdk r¨ejdd0�d?d1d2„ƒZejdd0�d?d3d4„ƒZ nejdd0�d?d5d2„ƒZejdd0�d?d6d4„ƒZ ejdd�G d7d8„ d8e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j*Z*ej+Z+ej,Z-ej.Z.dS )@é    )ÚannotationsN)é   é   )Údeclarative_asn1©r   é
   Ú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   úZ/var/www/html/CropPilot/venv/lib/python3.10/site-packages/cryptography/hazmat/asn1/asn1.pyr       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_origin)r   Úunion_typesr   r   r   Ú	_is_union;   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_annotationG   s<   
ÿÿÿÿ
ÿÿr4   ú
typing.Anyúdeclarative_asn1.AnnotatedTypec                   sÄ  t  | ¡t ju rt| jˆƒ}t  | ¡^} }nt ¡ }|jd ur<t  | ¡t	j
tfvr<| t	jt	jtttfvr<tdˆ› d�ƒ‚| tu r[t|jtƒrNtdˆ› d�ƒ‚|jd ur[tdˆ› d�ƒ‚t| dƒr€| j}t|tjjtjjfƒsut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|}n8t  | ¡t	j
u �r>t"t  | ¡d	 ˆƒ}tj )|¡}nt  | ¡tu �rWt"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?   rA   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    r"   Ú	Annotatedr4   Ú__metadata__Úget_argsr   r2   r,   ÚbuiltinsÚlistÚSetOfÚbytesr   Ú	BitStringÚ	IA5StringÚPrintableStringr/   ÚTLVr-   r+   ÚImplicitr*   r   r7   ÚTypeÚSequenceÚSetÚAnnotatedTypeÚcastr$   ÚlenÚNoneTyper   Ú_normalize_field_typeÚ
annotationÚis_emptyÚOptionr@   ÚanyÚChoiceÚ
SequenceOfÚnon_root_python_to_rust)r   r'   rZ   Ú_Ú	root_typeÚ
union_argsÚoptional_typeÚannotated_typeÚrust_field_typeÚvariantsÚtagsÚrust_choice_typeÚ
inner_typer   )rC   r'   r   rY   j   sÀ   
ûÿ	
ÿ
ÿ

ÿ
þÿ

ÿÿ

ÿ
ÿÿ
þþÿÿ
ûÿÿù
ÿÿ
rY   Útúdeclarative_asn1.Variantc           	      C  sÐ   t  | ¡t ju }|rt  | ¡d n| }t  |¡tu r^t  |¡\}}t  |¡t jur-tdƒ‚t  |¡d }t|dƒr=|j}nt	 
|¡}|rOt	 |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"]]`.r7   )r    r"   rF   rH   r   ÚLiteralr/   r   r7   r   r`   rU   r4   rG   r2   rY   )	rk   r'   Úis_annotatedrj   Ú
value_typeÚtag_literalr@   Ú	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:   )ÚitemsrY   )rs   Úfieldsr'   r   Úannotated_field_typer   r   r   Ú_annotate_fields%  s
   

ry   Úclsútype[U]ÚNonec                 C  ó0   t j| dd�}tj | t|ƒ¡}t| d|ƒ d S ©NT)Úinclude_extrasr7   )r    Úget_type_hintsr   rR   rS   ry   Úsetattr©rz   rs   Úrootr   r   r   Ú_register_asn1_sequence2  ó   r„   c                 C  r}   r~   )r    r€   r   rR   rT   ry   r�   r‚   r   r   r   Ú_register_asn1_set9  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„   ©rz   Údataclass_clsr   r   r   ÚsequenceF  ó"   
ø	÷þýr•   c                 C  rˆ   r‰   )r�   r�   r‘   r’   r†   r“   r   r   r   Úset]  r–   r—   c                 C  ó"   t jddddd�| ƒ}t|ƒ |S ©NFTrŠ   )r‘   r’   r„   r“   r   r   r   r•   v  ó   üû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   r5   r'   r   r   r6   )rk   r5   r'   r   r   rl   )rs   rt   r   ru   )rz   r{   r   r|   )rz   r{   r   r{   )/Ú
__future__r   rI   r‘   r�   r   r    r�   Útyping_extensionsÚLiteralStringÚ"cryptography.hazmat.bindings._rustr   r   rX   ÚTypeVarr   r
   r   r’   ÚGenericr   Ú
decode_derÚ
encode_derr$   r4   rY   r;   ry   r„   r†   Údataclass_transformr•   r—   r.   rK   r0   ÚExplicitrQ   r1   rO   rN   ÚUTCTimeÚGeneralizedTimerM   ÚTlvrP   ÚNullr   r   r   r   Ú<module>   sf   







# 

+








