o
    vh                     @   s   d dl Z d dlmZ d dlmZmZ d dlmZ d dlm	Z	 ddl
mZmZ dd	lmZmZmZmZmZ g d
Ze jG dd de jZeddG dd dZeddG dd dZG dd deZG dd deZG dd deZdS )    N)	dataclass)IterableOptional)cms)TimeStamper   )CMSAttributeProviderTSTProvider   )CertifiedAttributeChoicesCommitmentTypeIdentifierCommitmentTypeIndicationSignaturePolicyIdentifierSignerAttributesV2)GenericCommitmentCAdESSignedAttrSpecSignerAttrSpecc                   @   sN   e Zd Ze Ze Ze Ze Ze Z	e Z
edefddZdS )r   returnc                 C   s   t dt| j iS )Ncommitment_type_id)r   r   namelower)self r   S/var/www/html/hyperkenya/venv/lib/python3.10/site-packages/pyhanko/sign/ades/api.pyasn1    s   zGenericCommitment.asn1N)__name__
__module____qualname__enumautoPROOF_OF_ORIGINPROOF_OF_RECEIPTPROOF_OF_DELIVERYPROOF_OF_SENDERPROOF_OF_APPROVALPROOF_OF_CREATIONpropertyr   r   r   r   r   r   r      s    r   T)frozenc                   @   s0   e Zd ZU dZeej ed< 	 eej ed< dS )r   aO  
    Class that controls the ``signer-attributes-v2`` signed CAdES attribute.

    These represent attributes of the signing entity, not the signature or
    signed content.

    .. note::
        Out of the box, only basic claimed attributes and certified attributes
        through V2 X.509 attribute certificates are supported.
    claimed_attrscertified_attrsN)	r   r   r   __doc__r   r   AttCertAttribute__annotations__AttributeCertificateV2r   r   r   r   r   '   s   
 r   c                   @   sl   e Zd ZU dZdZee ed< 	 dZe	ed< 	 dZ
ee ed< 	 dZee ed< 	 	ddee fd	d
ZdS )r   zI
    Class that controls signed CAdES attributes on a PDF signature.
    Ncommitment_typeFtimestamp_contentsignature_policy_identifiersigner_attributestimestamperc                 c   sn    | j r|d urt|||dddV  | jd urt| jV  | jd ur(t| jV  | jd ur5t| jV  d S d S )Ncontent_time_stampT)digest_algorithm
data_to_tsr2   	attr_type	prehashed)r/   r	   r0   SigPolicyIDProviderr.   CommitmentTypeProviderr1   SignerAttributesProvider)r   message_digestmd_algorithmr2   r   r   r   prepare_providersh   s    


z%CAdESSignedAttrSpec.prepare_providersN)r   r   r   r*   r.   r   r   r,   r/   boolr0   r   r1   r   r   r=   r   r   r   r   r   ?   s   
 
	r   c                   @   s.   e Zd ZdZdefddZd	defddZdS )
r9   r.   c                 C   
   || _ d S r>   r.   )r   r.   r   r   r   __init__      
zCommitmentTypeProvider.__init__Fr   c                       | j S r>   rA   r   dry_runr   r   r   build_attr_value   s   z'CommitmentTypeProvider.build_attr_valueNF)r   r   r   attribute_typer   rB   rG   r   r   r   r   r9   ~       r9   c                   @   s0   e Zd ZdZdefddZ	d
defddZd	S )r8   r0   	policy_idc                 C   r@   r>   rK   )r   rK   r   r   r   rB      rC   zSigPolicyIDProvider.__init__Fr   c                    rD   r>   rL   rE   r   r   r   rG      s   z$SigPolicyIDProvider.build_attr_valueNrH   )r   r   r   rI   r   rB   rG   r   r   r   r   r8      s    r8   c                   @   s.   e Zd ZdZdefddZd
defddZd	S )r:   signer_attributes_v2signer_attr_specc                 C   r@   r>   )rN   )r   rN   r   r   r   rB      rC   z!SignerAttributesProvider.__init__Fr   c                    sJ   | j }t|j}t|j}i }|r||d< |r!dd |D |d< t|S )Nclaimed_attributesc                 S   s   g | ]}t d |dqS )	attr_cert)r   value)r   ).0rP   r   r   r   
<listcomp>   s    
z=SignerAttributesProvider.build_attr_value.<locals>.<listcomp>certified_attributes_v2)rN   listr(   r)   r   )r   rF   specclaimed	certifiedresultr   r   r   rG      s   


z)SignerAttributesProvider.build_attr_valueNrH   )r   r   r   rI   r   rB   r   rG   r   r   r   r   r:      rJ   r:   )r   dataclassesr   typingr   r   
asn1cryptor   pyhanko.sign.timestampsr   
attributesr   r	   
cades_asn1r   r   r   r   r   __all__uniqueEnumr   r   r   r9   r8   r:   r   r   r   r   <module>   s"    >
