%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/dns/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/dns/__pycache__/dnssec.cpython-312.pyc

�

5��e����N�dZddlZddlZddlZddlZddlZddlZddlmZddlm	Z	m
Z
mZmZm
Z
mZmZmZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlmZmZm Z ddlm!Z!m"Z"m#Z#m$Z$ddl%m&Z&ddl'm(Z(dd	l)m*Z*dd
l+m,Z,ddl-m.Z.m/Z/ddl0m1Z1dd
l2m3Z3m4Z4ddl5m6Z6edZ7edZ8e	ejrjtejvjxgdfZ=de>defd�Z?deee@fde>fd�ZAdeee>eBe@fde@fd�ZCdee*e&fde@fd�ZDGd�d�ZEGd�deE�ZFeFej�ej�ej�ej�hej�ej�ej�hej�ej�ej�hej�h�ZNeFeO�eO�eO�eO��ZPeNZQ			d`deej�j�e>fdej�j�deee>fd eej�j�d!eeEd"eVde,fd#�ZW	dadeej�j�e>fdej�j�deee>fd eej�j�de(f
d$�ZXd%e
ej�j�eej�j�ej�j�ffd&e3deee*fd'�Z]d(eejvjxeej�j�ej�j�ffdeej�j�ej�j�ffd)�Z^d*e_d+e_de*ddfd,�Z`			dbd(eejvjxeej�j�ej�j�ffd&e3d%e
ej�j�eej�j�ej�j�ffd eej�j�d-eeBd!eeEddfd.�Za			dbd(eejvjxeej�j�ej�j�ffd/eejvjxeej�j�ej�j�ffd%e
ej�j�eej�j�ej�j�ffd eej�j�d-eeBd!eeEddfd0�Zb						dcd(eejvjxeej�j�ej�j�ffd1e8d2ej�j�d3e*d4eeee>e@eBfd5eeee>e@eBfd6ee@d7eVd!eeEd eej�j�de3fd8�Zc	dad(eejvjxeej�j�ej�j�ffd&e3d eej�j�de_fd9�Zde6j�d:fd;e7dee@e>fd<e@d=e@de*f
d>�Zfe6j�d:fd;e7dee@e>fd<e@d=e@de&f
d?�Zgd@eej�j�e>fdAeee>e_fdBe@dee@e>fde>f
dC�Zh	dad(eejvjxeej�j�ej�j�ffdDe
eee>fd eej�j�dej�j�fdE�ZidFej�j�dej�j�fdG�Zj	dadeej�j�e>fdFej�j�deee>fd eej�j�dej�j�f
dH�ZkdFej�j�dej�j�fdI�Zl					dddJejrjtd(ejvjxd2ej�j�dKeee8e*fdLeee8e*fd4eeee>e@eBfd5eeee>e@eBfd6ee@d!eeEd eej�j�ddfdM�Zm										dedOej�j�dJeejrjtd%eeee8e*fdPeVdQee@d4eeee>e@eBfd5eeee>e@eBfd6ee@dRee1dSee=d!eeEddfdT�Zp	dadOej�j�dJejrjtdSee=ddfdU�ZqdV�Zrej�j�dW�rAddXlumvZvddYlwmxZxddZlwmyZydd[lwmzZzdd\lwm{Z{dd]lwm|Z|dd^l}m~Z~mZdd_l�m�Z�m�Z�ebZ�eaZ�ecZ�efZ�egZ�dNZ�nerZ�erZ�erZ�erZ�erZ�dZ�ej�ZGe�jZ�ej�ZHe�jZ�e�jZ�ej�ZIe�jZ�e�jZ�e�jZ�ej�ZJe�jZ�e�j Z�e�j"Z�e�j$Z�e�j&Z�e�j(Z�e�j*Z�y)fz.Common DNSSEC-related functions and constants.�N)�datetime)�Callable�Dict�List�Optional�Set�Tuple�Union�cast)�	Algorithm�DSDigest�	NSEC3Hash)�AlgorithmKeyMismatch�DeniedByPolicy�UnsupportedAlgorithm�ValidationFailure)�CDNSKEY)�CDS)�DNSKEY)�DS)�NSEC�Bitmap)�
NSEC3PARAM)�RRSIG�sigtime_to_posixtime)�Flag)�GenericPublicKeyzrsa.RSAPublicKeyzec.EllipticCurvePublicKeyzed25519.Ed25519PublicKeyzed448.Ed448PublicKey)�GenericPrivateKeyzrsa.RSAPrivateKeyzec.EllipticCurvePrivateKeyzed25519.Ed25519PrivateKeyzed448.Ed448PrivateKey�text�returnc�,�tj|�S)z�Convert text into a DNSSEC algorithm value.

    *text*, a ``str``, the text to convert to into an algorithm value.

    Returns an ``int``.
    )r�	from_text)rs �,/usr/lib/python3/dist-packages/dns/dnssec.py�algorithm_from_textr$Ls�����t�$�$��valuec�,�tj|�S)z�Convert a DNSSEC algorithm value to text

    *value*, a ``dns.dnssec.Algorithm``.

    Returns a ``str``, the name of a DNSSEC algorithm.
    )r�to_text�r&s r#�algorithm_to_textr*Ws�����U�#�#r%c��t|t�rt|j��St|t�rt|�St|t�rt|�St|t�r|Std��)z%Convert various format to a timestampzUnsupported timestamp type)�
isinstancer�int�	timestamp�strr�float�	TypeErrorr)s r#�to_timestampr2bsb���%��"��5�?�?�$�%�%�	�E�3�	�#�E�*�*�	�E�5�	!��5�z��	�E�3�	����4�5�5r%�keyc�X�|j�}|jtjk(r|ddz|dzSd}t	t|�dz�D]}||d|zdz|d|zdzzz
}�t|�dzdk7r||t|�dz
dzz
}||dz	dzz
}|dzS)	z�Return the key id (a 16-bit number) for the specified key.

    *key*, a ``dns.rdtypes.ANY.DNSKEY.DNSKEY``

    Returns an ``int`` between 0 and 65535
    �������r���i��)�to_wire�	algorithmr�RSAMD5�range�len)r3�rdata�total�is    r#�key_idrCps���
�K�K�M�E�
�}�}�	�(�(�(��b�	�Q��%��)�+�+����s�5�z�Q��'�	<�A��e�A��E�l�a�'�5��Q����+;�;�;�E�	<��u�:��>�Q���U�3�u�:��>�*�a�/�/�E�
�%�2�+��'�'���v�~�r%c�R�eZdZd�Zdedefd�Zdedefd�Zdedefd�Z	dedefd�Z
y)	�Policyc��y�N�)�selfs r#�__init__zPolicy.__init__�s��r%�_r c��y�NFrH�rIrKs  r#�
ok_to_signzPolicy.ok_to_sign����r%c��yrMrHrNs  r#�ok_to_validatezPolicy.ok_to_validate�rPr%c��yrMrHrNs  r#�ok_to_create_dszPolicy.ok_to_create_ds�rPr%c��yrMrHrNs  r#�ok_to_validate_dszPolicy.ok_to_validate_ds�rPr%N)�__name__�
__module__�__qualname__rJr�boolrOrRr
rTrVrHr%r#rErE�sS��
��F��t�����4�����d���8���r%rEc�^��eZdZ�fd�Zdedefd�Zdedefd�Zdedefd�Z	dedefd�Z
�xZS)	�
SimpleDenyc�Z��t�|��||_||_||_||_yrG)�superrJ�
_deny_sign�_deny_validate�_deny_create_ds�_deny_validate_ds)rI�	deny_sign�
deny_validate�deny_create_ds�deny_validate_ds�	__class__s     �r#rJzSimpleDeny.__init__�s-���
����#���+���-���!1��r%r3r c�2�|j|jvSrG)r<r_�rIr3s  r#rOzSimpleDeny.ok_to_sign�s���}�}�D�O�O�3�3r%c�2�|j|jvSrG)r<r`ris  r#rRzSimpleDeny.ok_to_validate�s���}�}�D�$7�$7�7�7r%r<c��||jvSrG)ra�rIr<s  r#rTzSimpleDeny.ok_to_create_ds�s���� 4� 4�4�4r%c��||jvSrG)rbrls  r#rVzSimpleDeny.ok_to_validate_ds�s���� 6� 6�6�6r%)rWrXrYrJrrZrOrRr
rTrV�
__classcell__)rgs@r#r\r\�sT���2�4�f�4��4�8�&�8�T�8�5��5�d�5�7�8�7��7r%r\F�namer<�origin�policy�
validatingc	��|�t}	t|t�rt|j	�}|r
|j}n|j}||�st�t|ttf�std��|tjk(rtj�}n^|tj k(rtj"�}n6|tj$k(rtj&�}nt
d|z��t|t�r t(j*j-||�}|j/�j1�}|�J�|j3|�|j3|j1|���|j5�}	t7j8dt;|�|j<|�|	z}
t(j>jAt(jBjDt(jFjH|
dtK|
��}tMtH|�S#t
$rt
d|z��wxYw)a�Create a DS record for a DNSSEC key.

    *name*, a ``dns.name.Name`` or ``str``, the owner name of the DS record.

    *key*, a ``dns.rdtypes.ANY.DNSKEY.DNSKEY`` or ``dns.rdtypes.ANY.DNSKEY.CDNSKEY``,
    the key the DS is about.

    *algorithm*, a ``str`` or ``int`` specifying the hash algorithm.
    The currently supported hashes are "SHA1", "SHA256", and "SHA384". Case
    does not matter for these strings.

    *origin*, a ``dns.name.Name`` or ``None``.  If *key* is a relative name,
    then it will be made absolute using the specified origin.

    *policy*, a ``dns.dnssec.Policy`` or ``None``.  If ``None``, the default policy,
    ``dns.dnssec.default_policy`` is used; this policy defaults to that of RFC 8624.

    *validating*, a ``bool``.  If ``True``, then policy is checked in
    validating mode, i.e. "Is it ok to validate using this digest algorithm?".
    Otherwise the policy is checked in creating mode, i.e. "Is it ok to create a DS with
    this digest algorithm?".

    Raises ``UnsupportedAlgorithm`` if the algorithm is unknown.

    Raises ``DeniedByPolicy`` if the algorithm is denied by policy.

    Returns a ``dns.rdtypes.ANY.DS.DS``
    �unsupported algorithm "%s"zkey is not a DNSKEY/CDNSKEY�rpz!HBBr)'�default_policyr,r/r
�upper�	ExceptionrrVrTrrr�
ValueError�SHA1�hashlib�sha1�SHA256�sha256�SHA384�sha384�dnsror"�canonicalizer;�update�digest�struct�packrCr<r@�	from_wire�
rdataclass�IN�	rdatatyperr?r)ror3r<rprqrr�check�dshash�wirer��dsrdata�dss            r#�make_dsr��s���J�~���M��i��%� ����!2�3�I���(�(���&�&��������c�F�G�,�-��6�7�7��H�M�M�!������	�h�o�o�	%����!��	�h�o�o�	%����!��"�#?�)�#K�L�L��$����x�x�!�!�$��/������&�&�(�D�����
�M�M�$��
�M�M�#�+�+�V�+�,�-�
�]�]�_�F��k�k�&�&��+�s�}�}�i�H�6�Q�G�	���	�	������3�=�=�+�+�W�a��W��
�B���B�<���?�M�"�#?�)�#K�L�L�M�s�'H/�/Ic���t||||�}t|jtjj|j
|j|j|j��S)a�Create a CDS record for a DNSSEC key.

    *name*, a ``dns.name.Name`` or ``str``, the owner name of the DS record.

    *key*, a ``dns.rdtypes.ANY.DNSKEY.DNSKEY`` or ``dns.rdtypes.ANY.DNSKEY.CDNSKEY``,
    the key the DS is about.

    *algorithm*, a ``str`` or ``int`` specifying the hash algorithm.
    The currently supported hashes are "SHA1", "SHA256", and "SHA384". Case
    does not matter for these strings.

    *origin*, a ``dns.name.Name`` or ``None``.  If *key* is a relative name,
    then it will be made absolute using the specified origin.

    Raises ``UnsupportedAlgorithm`` if the algorithm is unknown.

    Returns a ``dns.rdtypes.ANY.DS.CDS``
    ��rdclass�rdtype�key_tagr<�digest_typer�)	r�rr�r�r�r�r<r�r�)ror3r<rpr�s     r#�make_cdsr�sQ��2
��s�I�v�	.�B���
�
��}�}� � ��
�
��,�,��N�N��y�y�
�r%�keys�rrsigc�2�|j|j�}t|tjj
�rC|j
tjjtjj�}n|}|�y|D�cgc]�}|j|jk(ret|�|jk(rM|jtj ztj k(r|j"dk(rt%t|����c}Scc}w)N�)�get�signerr,r��node�Node�get_rdatasetr�r�r�rr<rCr��flagsr�ZONE�protocolr)r�r�r&�rdataset�rds     r#�_find_candidate_keysr�(s���
�H�H�U�\�\�"�E��%������'��%�%�c�n�n�&7�&7����9M�9M�N����������
�<�<�5�?�?�*��2�J�%�-�-�'�
�X�X��	�	�
!�d�i�i�/��K�K�1��	
�V�R�����s�BD�rrsetc�R�t|t�r
|d|dfS|j|fS)Nrr9)r,�tuplero)r�s r#�_get_rrname_rdatasetr�<s0���%����Q�x��q��!�!��z�z�5� � r%�sig�datac��t|�j}	|j|�}|j||�y#t$rt	d��wxYw)Nzinvalid public key)�get_algorithm_cls_from_dnskey�
public_cls�from_dnskeyryr�verify)r�r�r3r��
public_keys     r#�_validate_signaturer�EsV��.�s�3�>�>�J�6��+�+�C�0�
����c�4� ���6�� 4�5�5�6�s	�;�A�nowc��|�t}t||�}|�td��|�tj�}|j|krtd��|j
|kDrtd��t
|||�}|D]-}|j|�s�	t|j||�ytd��#ttf$rY�LwxYw)a�Validate an RRset against a single signature rdata, throwing an
    exception if validation is not successful.

    *rrset*, the RRset to validate.  This can be a
    ``dns.rrset.RRset`` or a (``dns.name.Name``, ``dns.rdataset.Rdataset``)
    tuple.

    *rrsig*, a ``dns.rdata.Rdata``, the signature to validate.

    *keys*, the key dictionary, used to find the DNSKEY associated
    with a given name.  The dictionary is keyed by a
    ``dns.name.Name``, and has ``dns.node.Node`` or
    ``dns.rdataset.Rdataset`` values.

    *origin*, a ``dns.name.Name`` or ``None``, the origin to use for relative
    names.

    *now*, a ``float`` or ``None``, the time, in seconds since the epoch, to
    use as the current time when validating.  If ``None``, the actual current
    time is used.

    *policy*, a ``dns.dnssec.Policy`` or ``None``.  If ``None``, the default policy,
    ``dns.dnssec.default_policy`` is used; this policy defaults to that of RFC 8624.

    Raises ``ValidationFailure`` if the signature is expired, not yet valid,
    the public key is invalid, the algorithm is unknown, the verification
    fails, etc.

    Raises ``UnsupportedAlgorithm`` if the algorithm is recognized by
    dnspython but not implemented.
    Nzunknown key�expiredz
not yet validzverify failure)rvr�r�time�
expiration�	inception�_make_rrsig_signature_datarRr��	signature�InvalidSignature)	r�r�r�rpr�rq�candidate_keysr��
candidate_keys	         r#�_validate_rrsigr�Ns���P�~���)�$��6�N����
�.�.�
�{��i�i�k�����#���	�*�*��������0�0�%�e�U�F�;�D�'��
��$�$�]�3��	������}�E����,�
-�-��	!�"3�4�	��	�s�B6�6C�C�rrsigsetc	�D�|�t}t|t�r8tjj|tjj�}t|t�r|d}n|j}t|t�r|d}|d}n|j}|}|j|�}|j|�}||k7rtd��|D]/}	t|	t�std��	t||	||||�ytd��#ttf$rY�NwxYw)a�Validate an RRset against a signature RRset, throwing an exception
    if none of the signatures validate.

    *rrset*, the RRset to validate.  This can be a
    ``dns.rrset.RRset`` or a (``dns.name.Name``, ``dns.rdataset.Rdataset``)
    tuple.

    *rrsigset*, the signature RRset.  This can be a
    ``dns.rrset.RRset`` or a (``dns.name.Name``, ``dns.rdataset.Rdataset``)
    tuple.

    *keys*, the key dictionary, used to find the DNSKEY associated
    with a given name.  The dictionary is keyed by a
    ``dns.name.Name``, and has ``dns.node.Node`` or
    ``dns.rdataset.Rdataset`` values.

    *origin*, a ``dns.name.Name``, the origin to use for relative names;
    defaults to None.

    *now*, an ``int`` or ``None``, the time, in seconds since the epoch, to
    use as the current time when validating.  If ``None``, the actual current
    time is used.

    *policy*, a ``dns.dnssec.Policy`` or ``None``.  If ``None``, the default policy,
    ``dns.dnssec.default_policy`` is used; this policy defaults to that of RFC 8624.

    Raises ``ValidationFailure`` if the signature is expired, not yet valid,
    the public key is invalid, the algorithm is unknown, the verification
    fails, etc.
    Nrr9zowner names do not matchzexpected an RRSIGzno RRSIGs validated)
rvr,r/r�ror"�rootr��choose_relativityrrr�r)
r�r�r�rpr�rq�rrname�	rrsigname�
rrsigrdatasetr�s
          r#�	_validater��s��N�~����&�#�����#�#�F�C�H�H�M�M�:���%����q��������(�E�"��Q�K�	� ���
��M�M�	� �
�
�
%�
%�f�
-�F��+�+�F�3�I�
���� :�;�;�����%��'�#�$7�8�8�	��E�5�$���V�D����1�
2�2��"�#7�8�	��	�s�/D
�
D�D�private_keyr��dnskeyr�r��lifetimer�c

���|�t}|j|�st�t|t�r3|dj
}
|dj}|d}|dj}
n0|j
}
|j}|j}|j}
|�t|�}nttj��}|�t|�}n|�||z}ntd��|	�|j|	�}t|�dz
}|j�r|dz}t!|
t"j$j ||j&||
||t)|�|d��}t"j*j-|||	�}t|t.�r|}n	t1|�}||��}|j7||�}t9t |j;|���S#t2$rt5d��wxYw)	aSign RRset using private key.

    *rrset*, the RRset to validate.  This can be a
    ``dns.rrset.RRset`` or a (``dns.name.Name``, ``dns.rdataset.Rdataset``)
    tuple.

    *private_key*, the private key to use for signing, a
    ``cryptography.hazmat.primitives.asymmetric`` private key class applicable
    for DNSSEC.

    *signer*, a ``dns.name.Name``, the Signer's name.

    *dnskey*, a ``DNSKEY`` matching ``private_key``.

    *inception*, a ``datetime``, ``str``, ``int``, ``float`` or ``None``, the
    signature inception time.  If ``None``, the current time is used.  If a ``str``, the
    format is "YYYYMMDDHHMMSS" or alternatively the number of seconds since the UNIX
    epoch in text form; this is the same the RRSIG rdata's text form.
    Values of type `int` or `float` are interpreted as seconds since the UNIX epoch.

    *expiration*, a ``datetime``, ``str``, ``int``, ``float`` or ``None``, the signature
    expiration time.  If ``None``, the expiration time will be the inception time plus
    the value of the *lifetime* parameter.  See the description of *inception* above
    for how the various parameter types are interpreted.

    *lifetime*, an ``int`` or ``None``, the signature lifetime in seconds.  This
    parameter is only meaningful if *expiration* is ``None``.

    *verify*, a ``bool``.  If set to ``True``, the signer will verify signatures
    after they are created; the default is ``False``.

    *policy*, a ``dns.dnssec.Policy`` or ``None``.  If ``None``, the default policy,
    ``dns.dnssec.default_policy`` is used; this policy defaults to that of RFC 8624.

    *origin*, a ``dns.name.Name`` or ``None``.  If ``None``, the default, then all
    names in the rrset (including its owner name) must be absolute; otherwise the
    specified origin will be used to make names absolute when signing.

    Raises ``DeniedByPolicy`` if the signature is denied by policy.
    r9rz(expiration or lifetime must be specifiedr%)r�r��type_coveredr<�labels�original_ttlr�r�r�r�r��r3zUnsupported key algorithm)r�)rvrOrr,r�r�r��ttlror2r-r�ry�derelativizer?�is_wildrr�r�r<rC�dnssecr�rr�rr1�signr�replace)r�r�r�r�r�r�r�r�rqrpr�r�r�r��rrsig_inception�rrsig_expirationr��rrsig_templater��signing_key�private_clsr�s                      r#�_signr��s���j�~������V�$����%�����(�"�"���q������q����Q�x�|�|���-�-�����������y�y����&�y�1���d�i�i�k�*����'�
�3��	�	�*�X�5���C�D�D����$�$�V�,��
��[�1�_�F��~�~���!������}�}�"�"���"�"��!�#�!��v�����N��:�:�0�0����O�D��+�0�1�!��	9�7��?�K�%�+�6�K�� � ��v�.�I���~�-�-�	�-�B�C�C��$�	9��7�8�8�	9�s�G�G&c��t|t�r8tjj	|tjj
�}|j}|j�s|�td��|j|�}t|�\}}d}||j|��ddz
}||jj|�z
}|j�s|�td��|j|�}t|�}|j�r|j|dz
k7rtd��|dz
|jkrtd	��|j|dz
krA|j!|jdz�d}tjj	d
|�}|j�}	t#j$d|j&|j(|j*�}
|D�cgc]}|j|���}}t-|�D]5}||	z
}||
z
}t#j$dt|��}
||
z
}||z
}�7|Scc}w)
a�Create signature rdata.

    *rrset*, the RRset to sign/validate.  This can be a
    ``dns.rrset.RRset`` or a (``dns.name.Name``, ``dns.rdataset.Rdataset``)
    tuple.

    *rrsig*, a ``dns.rdata.Rdata``, the signature to validate, or the
    signature template used when signing.

    *origin*, a ``dns.name.Name`` or ``None``, the origin to use for relative
    names.

    Raises ``UnsupportedAlgorithm`` if the algorithm is recognized by
    dnspython but not implemented.
    Nz,relative RR name without an origin specifiedr%ru�r8z&wild owner name has wrong label lengthr9z#owner name longer than RRSIG labels�*z!HHIz!H)r,r/r�ror"r�r��is_absoluterr�r�r;�
to_digestabler?r�r��splitr�r�r�r�r��sorted)r�r�rpr�r�r�r��name_len�suffix�	rrnamebuf�rrfixedr@�rdatas�rrlens              r#r�r�Us��*�&�#�����#�#�F�C�H�H�M�M�:��
�\�\�F������>�#�$R�S�S��$�$�V�,��,�E�2��F�H��D��E�M�M��M�(��"�-�-�D��E�L�L�&�&�v�.�.�D������>�#�$R�S�S��$�$�V�,���6�{�H�
�~�~��E�L�L�H�q�L�8�� H�I�I��!�|�e�l�l�"�� E�F�F�	����1��	$����e�l�l�Q�.�/��2�����#�#�C��0���$�$�&�I��k�k�&�(�/�/�8�3C�3C�U�EW�EW�X�G�7?�
@�e�e�!�!�&�)�
@�F�
@�������	����������D�#�e�*�-����
����
����K��As�)Ir�r�r�r�c���tj|�}t|t�r|j	||��St|�j}||��j	||��S)a�Convert a public key to DNSKEY Rdata

    *public_key*, a ``PublicKey`` (``GenericPublicKey`` or
    ``cryptography.hazmat.primitives.asymmetric``) to convert.

    *algorithm*, a ``str`` or ``int`` specifying the DNSKEY algorithm.

    *flags*: DNSKEY flags field as an integer.

    *protocol*: DNSKEY protocol field as an integer.

    Raises ``ValueError`` if the specified key algorithm parameters are not
    unsupported, ``TypeError`` if the key type is unsupported,
    `UnsupportedAlgorithm` if the algorithm is unknown and
    `AlgorithmKeyMismatch` if the algorithm does not match the key type.

    Return DNSKEY ``Rdata``.
    )r�r�r�)r�maker,r�	to_dnskey�get_algorithm_clsr�)r�r<r�r�r�s     r#�_make_dnskeyr��s^��2���y�)�I��*�.�/��#�#�%�(�#�C�C�&�y�1�<�<�
��j�)�3�3�%�(�3�S�Sr%c���t||||�}t|jtjj|j
|j|j|j��S)a�Convert a public key to CDNSKEY Rdata

    *public_key*, the public key to convert, a
    ``cryptography.hazmat.primitives.asymmetric`` public key class applicable
    for DNSSEC.

    *algorithm*, a ``str`` or ``int`` specifying the DNSKEY algorithm.

    *flags*: DNSKEY flags field as an integer.

    *protocol*: DNSKEY protocol field as an integer.

    Raises ``ValueError`` if the specified key algorithm parameters are not
    unsupported, ``TypeError`` if the key type is unsupported,
    `UnsupportedAlgorithm` if the algorithm is unknown and
    `AlgorithmKeyMismatch` if the algorithm does not match the key type.

    Return CDNSKEY ``Rdata``.
    �r�r�r�r�r<r3)	r�rr�r�r�r�r�r<r3)r�r<r�r�r�s     r#�
_make_cdnskeyr��sS��4�*�i���
A�F������}�}�$�$��l�l�����"�"��J�J�
�r%�domain�salt�
iterationsc�l�tjdd�}	t|t�rt|j	�}|tjk7rt
d��|�d}nDt|t�r2t|�dzdk(rtj|�}n
t
d��|}t|tjj�stjj|�}|j�j!�}|�J�t#j$||z�j'�}t)|�D](}t#j$||z�j'�}�*t+j,|�j/d�}	|	j1|�}	|	S#t
$rt
d��wxYw)	a�
    Calculate the NSEC3 hash, according to
    https://tools.ietf.org/html/rfc5155#section-5

    *domain*, a ``dns.name.Name`` or ``str``, the name to hash.

    *salt*, a ``str``, ``bytes``, or ``None``, the hash salt.  If a
    string, it is decoded as a hex string.

    *iterations*, an ``int``, the number of iterations.

    *algorithm*, a ``str`` or ``int``, the hash algorithm.
    The only defined algorithm is SHA1.

    Returns a ``str``, the encoded NSEC3 hash.
    � ABCDEFGHIJKLMNOPQRSTUVWXYZ234567� 0123456789ABCDEFGHIJKLMNOPQRSTUVz-Wrong hash algorithm (only SHA1 is supported)r%r8rzInvalid salt lengthzutf-8)r/�	maketransr,rrwrxryrzr?�bytes�fromhexr�ro�Namer"r�r;r{r|r�r>�base64�	b32encode�decode�	translate)
r�r�r�r<�b32_conversion�salt_encoded�domain_encodedr�rK�outputs
          r#�
nsec3_hashr�s|��.�]�]�*�,N��N�J��i��%�!�)�/�/�"3�4�I��I�N�N�"��H�I�I��|���	�D�#�	��t�9�q�=�A�� �=�=��.�L��2�3�3����f�c�h�h�m�m�,����#�#�F�+���(�(�*�2�2�4�N��%�%�%�
�\�\�.�<�7�
8�
?�
?�
A�F�
�:�
�>�����f�|�3�4�;�;�=��>��
�
�f�
%�
,�
,�W�
5�F�
�
�
�n�
-�F��M��9�J��H�I�I�J�s�'F�F3�
algorithmsc	��t|�\}}|jtjjtjj
tjjfvrtd��t�}|D];}	t|t�rt|j�}|j|��=|jtjjk(rug}t!|�D]"}|j"|vs�|j%|��$t'|�dk(rtd��tj(j+|j,|�Sg}|D]}|j/t1||||���!tj(j+|j,|�S#t$rtd|z��wxYw)aCreate a DS record from DNSKEY/CDNSKEY/CDS.

    *rrset*, the RRset to create DS Rdataset for.  This can be a
    ``dns.rrset.RRset`` or a (``dns.name.Name``, ``dns.rdataset.Rdataset``)
    tuple.

    *algorithms*, a set of ``str`` or ``int`` specifying the hash algorithms.
    The currently supported hashes are "SHA1", "SHA256", and "SHA384". Case
    does not matter for these strings. If the RRset is a CDS, only digest
    algorithms matching algorithms are accepted.

    *origin*, a ``dns.name.Name`` or ``None``.  If `key` is a relative name,
    then it will be made absolute using the specified origin.

    Raises ``UnsupportedAlgorithm`` if any of the algorithms are unknown and
    ``ValueError`` if the given RRset is not usable.

    Returns a ``dns.rdataset.Rdataset``
    zrrset not a DNSKEY/CDNSKEY/CDSrtrzno acceptable CDS rdata found)r�r�r�r�rrrry�setr,r/r
rwrxr�add�cds_rdataset_to_ds_rdatasetr��appendr?r��from_rdata_listr��extend�dnskey_rdataset_to_cds_rdataset)	r�rrpr�r��_algorithmsr<�resr@s	         r#�make_ds_rdatasetrs���2,�E�2��F�H�����
�
����
�
����
�
�����
�9�:�:��%�K��#�	�	Q��)�S�)�$�Y�_�_�%6�7�	�	���	�"�
#����#�-�-�+�+�+���0��:�	"�E�� � �K�/��
�
�5�!�	"��s�8�q�=��<�=�=��|�|�+�+�H�L�L�#�>�>�
�C� �Y�	��
�
�2�6�8�Y�PV�W�X�Y��<�<�'�'����c�:�:��!�	Q�&�'C�i�'O�P�P�	Q�s�'F)�)Gr�c��|jtjjk7rt	d��g}|D]l}|jt|jtjj|j|j|j|j����ntjj|j|�S)z�Create a CDS record from DS.

    *rdataset*, a ``dns.rdataset.Rdataset``, to create DS Rdataset for.

    Raises ``ValueError`` if the rdataset is not CDS.

    Returns a ``dns.rdataset.Rdataset``
    zrdataset not a CDSr�)r�r�r�rryr	r�rr�r<r�r�r�r
r��r�rr@s   r#rrUs������#�-�-�+�+�+��-�.�.�
�C��

���
�
���
�
��}�}�'�'��
�
��/�/�!�-�-��|�|�

�		
�

��<�<�'�'����c�:�:r%c	�8�|jtjjtjjfvrtd��g}|D]}|j
t||||���!tjj|j|�S)a�Create a CDS record from DNSKEY/CDNSKEY.

    *name*, a ``dns.name.Name`` or ``str``, the owner name of the CDS record.

    *rdataset*, a ``dns.rdataset.Rdataset``, to create DS Rdataset for.

    *algorithm*, a ``str`` or ``int`` specifying the hash algorithm.
    The currently supported hashes are "SHA1", "SHA256", and "SHA384". Case
    does not matter for these strings.

    *origin*, a ``dns.name.Name`` or ``None``.  If `key` is a relative name,
    then it will be made absolute using the specified origin.

    Raises ``UnsupportedAlgorithm`` if the algorithm is unknown or
    ``ValueError`` if the rdataset is not DNSKEY/CDNSKEY.

    Returns a ``dns.rdataset.Rdataset``
    zrdataset not a DNSKEY/CDNSKEY)r�r�r�rrryr	r�r�r
r�)ror�r<rprr@s      r#rrrs{��2���s�}�}�3�3�S�]�]�5J�5J�K�K��8�9�9�
�C��=���
�
�8�D�%��F�;�<�=��<�<�'�'����c�:�:r%c��|jtjjk7rt	d��g}|D]^}|jt
|j|j|j|j|j|j����`tjj|j|�S)z�Create a CDNSKEY record from DNSKEY.

    *rdataset*, a ``dns.rdataset.Rdataset``, to create CDNSKEY Rdataset for.

    Returns a ``dns.rdataset.Rdataset``
    zrdataset not a DNSKEYr�)r�r�r�rryr	rr�r�r�r<r3r�r
r�rs   r#�#dnskey_rdataset_to_cdnskey_rdatasetr�s������#�-�-�.�.�.��0�1�1�
�C��

���
�
�� �(�(�����k�k�����/�/��I�I�

�		
�

��<�<�'�'����c�:�:r%�txn�ksks�zsksc
��|jttjjj
tjjjtjjjg�vr|}
n|}
|
D]T\}}tjj|||||||||	��	}
|j|j|j|
��Vy)zDefault RRset signer)	r�r�r�r�r�r�r�rqrpN)
r�rr�r��	RdataTyperrrr�r�rror�)rr�r�rrr�r�r�rqrpr�r�r�r�s              r#�default_rrset_signerr�s���
�|�|�s��M�M�#�#�*�*��M�M�#�#�'�'��M�M�#�#�+�+�	
�������#�.���V��
�
����#���!����� �

��	����
�
�E�I�I�u�-�.r%T�zone�
add_dnskey�
dnskey_ttl�nsec3�rrset_signerc�<�g}g}|rS|D]E}
|
djtjzr|j|
��5|j|
��G|s|}|s|}ng}|rt	j
|�}n|j
�}|5}|r�|��|j|jtjj�}|r
|j}n@|j|jtjj�}|j}|D]"\}}|j|j||��$|rtd��|	xs6t!j"t$|j||||||
|j��	}t'|||�cddd�S#1swYyxYw)a?Sign zone.

    *zone*, a ``dns.zone.Zone``, the zone to sign.

    *txn*, a ``dns.transaction.Transaction``, an optional transaction to use for
    signing.

    *keys*, a list of (``PrivateKey``, ``DNSKEY``) tuples, to use for signing. KSK/ZSK
    roles are assigned automatically if the SEP flag is used, otherwise all RRsets are
    signed by all keys.

    *add_dnskey*, a ``bool``.  If ``True``, the default, all specified DNSKEYs are
    automatically added to the zone on signing.

    *dnskey_ttl*, a``int``, specifies the TTL for DNSKEY RRs. If not specified the TTL
    of the existing DNSKEY RRset used or the TTL of the SOA RRset.

    *inception*, a ``datetime``, ``str``, ``int``, ``float`` or ``None``, the signature
    inception time.  If ``None``, the current time is used.  If a ``str``, the format is
    "YYYYMMDDHHMMSS" or alternatively the number of seconds since the UNIX epoch in text
    form; this is the same the RRSIG rdata's text form. Values of type `int` or `float`
    are interpreted as seconds since the UNIX epoch.

    *expiration*, a ``datetime``, ``str``, ``int``, ``float`` or ``None``, the signature
    expiration time.  If ``None``, the expiration time will be the inception time plus
    the value of the *lifetime* parameter.  See the description of *inception* above for
    how the various parameter types are interpreted.

    *lifetime*, an ``int`` or ``None``, the signature lifetime in seconds.  This
    parameter is only meaningful if *expiration* is ``None``.

    *nsec3*, a ``NSEC3PARAM`` Rdata, configures signing using NSEC3. Not yet
    implemented.

    *rrset_signer*, a ``Callable``, an optional function for signing RRsets. The
    function requires two arguments: transaction and RRset. If the not specified,
    ``dns.dnssec.default_rrset_signer`` will be used.

    Returns ``None``.
    r9Nz&Signing with NSEC3 not yet implemented)r�rrr�r�r�rqrp)r�r�SEPr	�
contextlib�nullcontext�writerr�rpr�r�rr��SOAr�NotImplementedError�	functools�partialr�_sign_zone_nsec)rrr�rrr�r�r�rrrqrrr3�cm�_txnr��soarK�
_rrset_signers                    r#�	sign_zoner.�sx��l�D�
�D���	!�C��1�v�|�|�d�h�h�&����C� ����C� �		!�
��D���D���
�0:�0F�0F�s�0K��
�[�[�]��	�>�t���!����$�+�+�s�}�}�/C�/C�D���!'���J��(�(�4�;�;��
�
�0A�0A�B�C�!$���J�!�
:�	��6�������j�&�9�
:��%�&N�O�O�(�
�I�,=�,=�$��{�{���#�%�!���{�{�
-�M�#�4��}�=�5>�>�>�s
�DF�Fc��	d
dtjjdtjjdt
tjjdtjjdtdt
tddfd	�}|j�j}d}d}t|j��D�]}|r|j|�r�|j|tj j"�r||j$k7r|}nd}|r�|j'|�}|r�|j(D]�}	|	j*tj j,k(r�+|r(|	j*tj j.k7r�Utj0j2||	j4g|	���}
|||
���|�|||||j6||�|}��|r"||||j$|j6||�yy)zNSEC zone signerNrro�next_securer�r�rr c
�T�ttjjjtjjj
g�}|j
|�}|r�|r�t|jD�cgc]}|j��c}�|z}	tjt|	��}
tjj||t|tjjj
||
���}|j|�|r
|||�yyyycc}w)zNSEC zone signer helper)r�r��next�windowsN)rr�r�rrr�get_node�	rdatasetsr�r�from_rdtypes�listr��
from_rdatar)rror0r�r�r�mandatory_typesr�r��typesr3r�s            r#�
_txn_add_nsecz&_sign_zone_nsec.<locals>._txn_add_nsecGs����
�]�]�
$�
$�
*�
*�C�M�M�,C�,C�,H�,H�I�
���|�|�D�!���K��T�^�^�D��X�_�_�D�E��W�
��)�)�$�u�+�6�G��I�I�(�(����#��=�=�2�2�7�7�$�#�	�	�E�
�G�G�E�N���S�%�(��! �4��Ds�:D%rG)r��transaction�Transactionror�rr��
RdataClassr-�RRsetSigner�get_soa�minimumr��
iterate_names�is_subdomainr�r��NSrpr4r5r�rrr�r8r�r�)rrrr;�	rrsig_ttl�
delegation�last_secureror�r�r�s           r#r)r)@s���/3�
)�
�_�_�
(�
(�)��h�h�m�m�)��c�h�h�m�m�,�)����*�*�	)�
�)��{�+�
)�
�)�@����&�&�I��J��K��s�(�(�*�+����$�+�+�J�7��
�W�W�T�3�=�=�+�+�
,�����1D��J��J���<�<��%�D�� $���	1�H����#�-�-�*=�*=�=� �#����3�=�=�;K�;K�(K� � #�	�	� 4� 4�T�8�<�<� S�(� S��$�S�%�0�	1��"��#�{�D�$�,�,�	�<�X���9�<����d�k�k�4�<�<��L�	
�r%c��td��)Nz.DNSSEC validation requires python cryptography)�ImportError)�args�kwargss  r#�
_need_pycarL�s��
�8��r%r�)r�)�dsa)�ec)�ed448)�rsa)�ed25519)r�r�)rr)NNFrG)NNN)NNNFNN)NNNNN)
NNTNNNNNNN)��__doc__r�r"r'r{r�r�r�typingrrrrrr	r
r�
dns._featuresr��
dns.exception�dns.name�dns.node�	dns.rdata�dns.rdataclass�dns.rdataset�
dns.rdatatype�	dns.rrset�dns.transaction�dns.zone�dns.dnssectypesrr
rrrrr�dns.rdtypes.ANY.CDNSKEYr�dns.rdtypes.ANY.CDSr�dns.rdtypes.ANY.DNSKEYr�dns.rdtypes.ANY.DSr�dns.rdtypes.ANY.NSECrr�dns.rdtypes.ANY.NSEC3PARAMr�dns.rdtypes.ANY.RRSIGrr�dns.rdtypes.dnskeybaser�	PublicKey�
PrivateKeyr<r=r��RRsetr?r/r$r-r*r0r2rCrEr\r=�DSA�DSANSEC3SHA1�ECCGOST�NULLrz�GOST�rfc_8624_policyr�allow_all_policyrvror�r@�RdatarZr�r�r��Rdatasetr�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrrr�Zoner.r)rL�	_features�have�cryptography.exceptionsr��)cryptography.hazmat.primitives.asymmetricrMrNrOrPrQ�dns.dnssecalgsr�r��dns.dnssecalgs.baserr�validate�validate_rrsigr��make_dnskey�make_cdnskey�
_have_pyca�DH�ECC�RSASHA1�RSASHA1NSEC3SHA1�	RSASHA256�	RSASHA512�ECDSAP256SHA256�ECDSAP384SHA384�ED25519�ED448�INDIRECT�
PRIVATEDNS�
PRIVATEOIDrHr%r#�<module>r�s���$5�����
���J�J�J������������:�:���,�#�)�!�-�1�=�'���
�	����
�����3�3�S�Y�Y�_�_�E�t�K�L��%�c�%�i�%�$�U�9�c�>�2�$�s�$�6��h��U�C�7�8�6�S�6���f�g�o�&��3��*��"7��7�*����y�}�}�i�&<�&<�i�>O�>O�P����y�}�}�i�&<�&<�=�
�]�]�H�M�M�8�=�=�1�
�]�]�O�	���c�e�S�U�C�E�3�5�9��!��'+�#��
I�
����
�
�s�"�
#�I�	�����I��X�s�]�#�I�
�S�X�X�]�]�#�	I�

�V��I��
I��I�`'+�	!�
����
�
�s�"�
#�!�	�����!��X�s�]�#�!�
�S�X�X�]�]�#�	!�
	�!�H�
�s�x�x�}�}�e�C�L�L�$9�$9�3�8�8�=�=�$H�I�I�
J��SX��
�d�6�l���(!�������%����
�
�s�|�|�7L�7L�(L�"M�M�N�!�
�3�8�8�=�=�#�,�,�/�/�/�0�!�!�U�!�%�!�f�!��!�'+��#�
B.�������%����
�
�s�|�|�7L�7L�(L�"M�M�N�B.��B.��s�x�x�}�}�e�C�H�H�M�M�3�<�<�3H�3H�$H�I�I�
J�B.�
�S�X�X�]�]�#�	B.�

�%��B.�
�V��
B.�
�B.�R'+��#�
F3�������%����
�
�s�|�|�7L�7L�(L�"M�M�N�F3��C�I�I�O�O�U�3�8�8�=�=�#�,�,�:O�:O�+O�%P�P�Q�F3��s�x�x�}�}�e�C�H�H�M�M�3�<�<�3H�3H�$H�I�I�
J�F3�
�S�X�X�]�]�#�	F3�

�%��F3�
�V��
F3�
�F3�\=A�=A�"��#�&*�vD�������%����
�
�s�|�|�7L�7L�(L�"M�M�N�vD��vD�
�H�H�M�M�vD�
�	vD�
��h��S�%�7�8�9�vD���x��c�5�8�9�:�
vD��s�m�vD�
�vD�
�V��vD�
�S�X�X�]�]�#�vD��vD�x'+�>�������%����
�
�s�|�|�7L�7L�(L�"M�M�N�>��>�
�S�X�X�]�]�#�>��	>�H����	T��T��S�#�X��T��T��	T�
�T�J����	#��#��S�#�X��#��#��	#�

�#�L:��#�(�(�-�-��$�%�:�
�5��e��$�
%�:��:��S�#�X��	:�
	�:�@'+�7;�������%����
�
�s�|�|�7L�7L�(L�"M�M�N�7;��E�(�C�-�(�)�7;�
�S�X�X�]�]�#�7;�	�\�\���	7;�t;��l�l�#�#�;��\�\���;�B'+�	;�
����
�
�s�"�
#�;��l�l�#�#�;��X�s�]�#�;�
�S�X�X�]�]�#�	;�
	�\�\���;�B;��l�l�#�#�;��\�\���;�B=A�=A�"�#�&*�%.�	���	$�	$�%.��9�9�?�?�%.�
�H�H�M�M�%.��u�Z��'�(�
)�	%.�
�u�Z��'�(�
)�%.���h��S�%�7�8�9�
%.���x��c�5�8�9�:�%.��s�m�%.�
�V��%.�
�S�X�X�]�]�#�%.�
�%.�T26�6:�� $�<@�=A�"�"&�*.�#�g>�

�(�(�-�-�g>�	�#�/�/�-�-�	.�g>��4��j�&�0�1�2�
3�g>��	g>�
��
�g>���h��S�%�7�8�9�
g>���x��c�5�8�9�:�g>��s�m�g>��J��g>��;�'�g>�
�V��g>�
�g>�Z+/�L
�

�(�(�-�-�L
�	���	$�	$�L
��;�'�L
�
�	L
�^��=�=���h��8�=�<�?�=���H��H�$�N��D��K� �L��J��H��N��D��K��L��J�
�	�	���\�\���m�m���m�m��
�
�
���%�%���-�-�����	����	�
�
�
���+�+���+�+��
�
�
����������
�
!�
!�
�
�
!�
!�
r%

Zerion Mini Shell 1.0