a
    !f{                     @   s   d dl Z d dlmZmZmZmZ d dlmZmZ g dZ	dddZ
G dd	 d	eZG d
d deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZdS )    N)byte_stringbbchrbord)long_to_bytesbytes_to_long)	DerObject
DerIntegerDerOctetStringDerNullDerSequenceDerObjectIdDerBitStringDerSetOfFc                 C   s4   d}z| | }W n t y$   Y dS 0 | p2| dkS )Nr   F)	TypeError)xonly_non_negativetest r   U/var/www/html/python-backend/venv/lib/python3.9/site-packages/Cryptodome/Util/asn1.py
_is_number!   s    r   c                   @   s@   e Zd ZdZdd Zdd Zdd Zdd	 Zd
d Zdd Z	dS )BytesIO_EOFzeThis class differs from BytesIO in that a ValueError exception is
    raised whenever EOF is reached.c                 C   s   || _ d| _d | _d S Nr   )_buffer_index	_bookmark)selfZinitial_bytesr   r   r   __init__.   s    zBytesIO_EOF.__init__c                 C   s   | j | _d S N)r   r   r   r   r   r   set_bookmark3   s    zBytesIO_EOF.set_bookmarkc                 C   s    | j d usJ | j| j | j S r   )r   r   r   r   r   r   r   data_since_bookmark6   s    zBytesIO_EOF.data_since_bookmarkc                 C   s   t | j| j S r   )lenr   r   r   r   r   r   remaining_data:   s    zBytesIO_EOF.remaining_datac                 C   sH   | j | }|t| jkr.td|t| jf | j| j | }|| _ |S )Nz@Not enough data for DER decoding: expected %d bytes and found %d)r   r"   r   
ValueError)r   lengthZ	new_indexresultr   r   r   read=   s    
zBytesIO_EOF.readc                 C   s   t | dd S )N   r   )r   r'   r   r   r   r   	read_byteF   s    zBytesIO_EOF.read_byteN)
__name__
__module____qualname____doc__r   r    r!   r#   r'   r)   r   r   r   r   r   *   s   	r   c                   @   sP   e Zd ZdZdddZdd Zed	d
 Zdd Zdd Z	dddZ
dd ZdS )r   zpBase class for defining a single DER object.

        This class should never be directly instantiated.
        N    Fc                 C   s   |du rd| _ dS | |}|| _d||fvr6td|durZdd| B | |B | _ dS |durd| |B | _ d| |B | _dS d| |B | _ dS )a  Initialize the DER object according to a specific ASN.1 type.

                :Parameters:
                  asn1Id : integer
                    The universal DER tag number for this object
                    (e.g. 0x10 for a SEQUENCE).
                    If None, the tag is not known yet.

                  payload : byte string
                    The initial payload of the object (that it,
                    the content octets).
                    If not specified, the payload is empty.

                  implicit : integer
                    The IMPLICIT tag number to use for the encoded object.
                    It overrides the universal tag *asn1Id*.

                  constructed : bool
                    True when the ASN.1 type is *constructed*.
                    False when it is *primitive*.

                  explicit : integer
                    The EXPLICIT tag number to use for the encoded object.
                Nz1Explicit and implicit tags are mutually exclusive          )
_tag_octet_convertTagpayloadr$   _inner_tag_octet)r   Zasn1Idr4   implicitZconstructedexplicitr   r   r   r   P   s    
zDerObject.__init__c                 C   sJ   t |s t|dkr t|d }t |r>d|  kr<dk sFn td|S )zvCheck if *tag* is a real DER tag.
                Convert it from a character to number if necessary.
                r(   r      zWrong DER tag)r   r"   r   r$   )r   tagr   r   r   r3      s    zDerObject._convertTagc                 C   s,   | dkr$t | }tt|d | S t| S )zXBuild length octets according to BER/DER
                definite form.
                   r/   )r   r   r"   )r%   encodingr   r   r   _definite_form   s    zDerObject._definite_formc                 C   sL   | j }t| dr0t| j| t| j  | j  }t| j| t| | S )z?Return this DER element, fully encoded as a binary byte string.r5   )r4   hasattrr   r5   r<   r"   r2   )r   Zoutput_payloadr   r   r   encode   s    
zDerObject.encodec                 C   sR   |  }|dkrN||d@ }t|d dkr6tdt|}|dkrNtd|S )z%Decode DER length octets from a file.r:   r   z$Invalid DER: length has leading zeroz5Invalid DER: length in long form but smaller than 128)r)   r'   r   r$   r   )r   sr%   Zencoded_lengthr   r   r   
_decodeLen   s    zDerObject._decodeLenc                 C   s<   t |stdt|}| || | dkr8td| S )a  Decode a complete DER element, and re-initializes this
                object with it.

                Args:
                  der_encoded (byte string): A complete DER element.

                Raises:
                  ValueError: in case of parsing errors.
                zInput is not a byte stringr   -Unexpected extra data after the DER structure)r   r$   r   _decodeFromStreamr#   )r   der_encodedstrictr?   r   r   r   decode   s    zDerObject.decodec                 C   s   |  }| jdur&|| jkr,tdn|| _| |}||| _t| drt| j}|  }|| jkrptd| |}||| _|	 dkrtddS )z*Decode a complete DER element from a file.NzUnexpected DER tagr5   zUnexpected internal DER tagr   rA   )
r)   r2   r$   r@   r'   r4   r=   r   r5   r#   )r   r?   rD   ZidOctetr%   pZinner_octetr   r   r   rB      s     







zDerObject._decodeFromStream)Nr.   NFN)F)r*   r+   r,   r-   r   r3   staticmethodr<   r>   r@   rE   rB   r   r   r   r   r   J   s     
?
	
r   c                   @   s4   e Zd ZdZdddZdd Zdd	d
Zdd ZdS )r	   a  Class to model a DER INTEGER.

        An example of encoding is::

          >>> from Cryptodome.Util.asn1 import DerInteger
          >>> from binascii import hexlify, unhexlify
          >>> int_der = DerInteger(9)
          >>> print hexlify(int_der.encode())

        which will show ``020109``, the DER encoding of 9.

        And for decoding::

          >>> s = unhexlify(b'020109')
          >>> try:
          >>>   int_der = DerInteger()
          >>>   int_der.decode(s)
          >>>   print int_der.value
          >>> except ValueError:
          >>>   print "Not a valid DER INTEGER"

        the output will be ``9``.

        :ivar value: The integer value
        :vartype value: integer
        r   Nc                 C   s   t | dd|d| || _dS )aU  Initialize the DER object as an INTEGER.

                :Parameters:
                  value : integer
                    The value of the integer.

                  implicit : integer
                    The IMPLICIT tag to use for the encoded object.
                    It overrides the universal tag for INTEGER (2).
                   r.   FNr   r   valuer   rJ   r6   r7   r   r   r   r     s    zDerInteger.__init__c                 C   sz   | j }d| _tt|d@ | j | _d|  kr8dkrLn ntd| j | _d|  kr`dkrfqp nqp|dL }qt| S )zIReturn the DER INTEGER, fully encoded as a
                binary string.r.      r/   r   i   )rJ   r4   r   intr   r>   )r   numberr   r   r   r>   %  s    
zDerInteger.encodeFc                 C   s   t j| ||dS )a!  Decode a complete DER INTEGER DER, and re-initializes this
                object with it.

                Args:
                  der_encoded (byte string): A complete INTEGER DER element.

                Raises:
                  ValueError: in case of parsing errors.
                rD   r   rE   r   rC   rD   r   r   r   rE   4  s    zDerInteger.decodec                 C   s   t | || |r\t| jdkr(tdt| jdkr\td| jdd d dk r\tdd| _d}| jD ],}|  jd	9  _|  jt|7  _|d
K }ql| jrt| jd d@ r|  j|8  _dS )z*Decode a complete DER INTEGER from a file.r   z/Invalid encoding for DER INTEGER: empty payloadrH   z>HNr/   z.Invalid encoding for DER INTEGER: leading zeror(      rM   )	r   rB   r"   r4   r$   structunpackrJ   r   )r   r?   rD   bitsir   r   r   rB   A  s    ,

zDerInteger._decodeFromStream)r   NN)Fr*   r+   r,   r-   r   r>   rE   rB   r   r   r   r   r	      s
   

r	   c                   @   s   e Zd ZdZd#ddZdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd Zdd Zdd Zd$ddZd%ddZdd Zd&dd Zd!d" ZdS )'r   a  Class to model a DER SEQUENCE.

        This object behaves like a dynamic Python sequence.

        Sub-elements that are INTEGERs behave like Python integers.

        Any other sub-element is a binary string encoded as a complete DER
        sub-element (TLV).

        An example of encoding is:

          >>> from Cryptodome.Util.asn1 import DerSequence, DerInteger
          >>> from binascii import hexlify, unhexlify
          >>> obj_der = unhexlify('070102')
          >>> seq_der = DerSequence([4])
          >>> seq_der.append(9)
          >>> seq_der.append(obj_der.encode())
          >>> print hexlify(seq_der.encode())

        which will show ``3009020104020109070102``, the DER encoding of the
        sequence containing ``4``, ``9``, and the object with payload ``02``.

        For decoding:

          >>> s = unhexlify(b'3009020104020109070102')
          >>> try:
          >>>   seq_der = DerSequence()
          >>>   seq_der.decode(s)
          >>>   print len(seq_der)
          >>>   print seq_der[0]
          >>>   print seq_der[:]
          >>> except ValueError:
          >>>   print "Not a valid DER SEQUENCE"

        the output will be::

          3
          4
          [4, 9, b'']

        Nc                 C   s,   t | dd|d |du r"g | _n|| _dS )a  Initialize the DER object as a SEQUENCE.

                :Parameters:
                  startSeq : Python sequence
                    A sequence whose element are either integers or
                    other DER objects.

                  implicit : integer
                    The IMPLICIT tag to use for the encoded object.
                    It overrides the universal tag for SEQUENCE (16).
                   r.   TN)r   r   _seq)r   ZstartSeqr6   r   r   r   r     s    zDerSequence.__init__c                 C   s   | j |= d S r   rZ   r   nr   r   r   __delitem__  s    zDerSequence.__delitem__c                 C   s
   | j | S r   r[   r\   r   r   r   __getitem__  s    zDerSequence.__getitem__c                 C   s   || j |< d S r   r[   )r   keyrJ   r   r   r   __setitem__  s    zDerSequence.__setitem__c                 C   s   || j ||< d S r   r[   )r   rW   jsequencer   r   r   __setslice__  s    zDerSequence.__setslice__c                 C   s   | j ||= d S r   r[   r   rW   rb   r   r   r   __delslice__  s    zDerSequence.__delslice__c                 C   s   | j td|td| S r   )rZ   maxre   r   r   r   __getslice__  s    zDerSequence.__getslice__c                 C   s
   t | jS r   r"   rZ   r   r   r   r   __len__  s    zDerSequence.__len__c                 C   s   | j | | S r   rZ   appendr   itemr   r   r   __iadd__  s    zDerSequence.__iadd__c                 C   s   | j | | S r   rk   rm   r   r   r   rl     s    zDerSequence.appendTc                    s    fdd| j D }t|S )zReturn the number of items in this sequence that are
                integers.

                Args:
                  only_non_negative (boolean):
                    If ``True``, negative integers are not counted in.
                c                    s   g | ]}t | r|qS r   )r   .0r   r   r   r   
<listcomp>  r.   z'DerSequence.hasInts.<locals>.<listcomp>)rZ   r"   )r   r   itemsr   rr   r   hasInts  s    	zDerSequence.hasIntsc                 C   s   | j o| |t| j kS )a  Return ``True`` if all items in this sequence are integers
                or non-negative integers.

                This function returns False is the sequence is empty,
                or at least one member is not an integer.

                Args:
                  only_non_negative (boolean):
                    If ``True``, the presence of negative integers
                    causes the method to return ``False``.)rZ   ru   r"   )r   r   r   r   r   hasOnlyInts  s    zDerSequence.hasOnlyIntsc                 C   sf   d| _ | jD ]N}t|r(|  j |7  _ qt|rH|  j t| 7  _ q|  j | 7  _ qt| S )zReturn this DER SEQUENCE, fully encoded as a
                binary string.

                Raises:
                  ValueError: if some elements in the sequence are neither integers
                              nor byte strings.
                r.   )r4   rZ   r   r   r	   r>   r   rm   r   r   r   r>     s    
zDerSequence.encodeFc                 C   s.   || _ tj| ||d}|r*|  s*td|S )a9  Decode a complete DER SEQUENCE, and re-initializes this
                object with it.

                Args:
                  der_encoded (byte string):
                    A complete SEQUENCE DER element.
                  nr_elements (None or integer or list of integers):
                    The number of members the SEQUENCE can have
                  only_ints_expected (boolean):
                    Whether the SEQUENCE is expected to contain only integers.
                  strict (boolean):
                    Whether decoding must check for strict DER compliancy.

                Raises:
                  ValueError: in case of parsing errors.

                DER INTEGERs are decoded into Python integers. Any other DER
                element is not decoded. Its validity is not checked.
                rP   zSome members are not INTEGERs)_nr_elementsr   rE   rv   r$   )r   rC   rD   Znr_elementsZonly_ints_expectedr&   r   r   r   rE     s
    zDerSequence.decodec                 C   s   g | _ t| || t| j}| dkr|  t }||| |jdkr`| j |	  qt
 }|	 }|j||d | j |j qd}| jdurzt| j | jv }W n" ty   t| j | jk}Y n0 |stdt| j  dS )z+Decode a complete DER SEQUENCE from a file.r   rH   rP   TNz1Unexpected number of members (%d) in the sequence)rZ   r   rB   r   r4   r#   r    r2   rl   r!   r	   rE   rJ   rw   r"   r   r$   )r   r?   rD   rF   derderIntdataokr   r   r   rB     s.    


zDerSequence._decodeFromStream)NN)T)T)FNF)r*   r+   r,   r-   r   r^   r_   ra   rd   rf   rh   rj   ro   rl   ru   rv   r>   rE   rB   r   r   r   r   r   X  s    *



r   c                   @   s   e Zd ZdZdddZdS )r
   a  Class to model a DER OCTET STRING.

    An example of encoding is:

    >>> from Cryptodome.Util.asn1 import DerOctetString
    >>> from binascii import hexlify, unhexlify
    >>> os_der = DerOctetString(b'\xaa')
    >>> os_der.payload += b'\xbb'
    >>> print hexlify(os_der.encode())

    which will show ``0402aabb``, the DER encoding for the byte string
    ``b'\xAA\xBB'``.

    For decoding:

    >>> s = unhexlify(b'0402aabb')
    >>> try:
    >>>   os_der = DerOctetString()
    >>>   os_der.decode(s)
    >>>   print hexlify(os_der.payload)
    >>> except ValueError:
    >>>   print "Not a valid DER OCTET STRING"

    the output will be ``aabb``.

    :ivar payload: The content of the string
    :vartype payload: byte string
    r.   Nc                 C   s   t | d||d dS )ah  Initialize the DER object as an OCTET STRING.

        :Parameters:
          value : byte string
            The initial payload of the object.
            If not specified, the payload is empty.

          implicit : integer
            The IMPLICIT tag to use for the encoded object.
            It overrides the universal tag for OCTET STRING (4).
           FNr   r   )r   rJ   r6   r   r   r   r   A  s    zDerOctetString.__init__)r.   Nr*   r+   r,   r-   r   r   r   r   r   r
   #  s   r
   c                   @   s   e Zd ZdZdd ZdS )r   z"Class to model a DER NULL element.c                 C   s   t | dddd dS )z$Initialize the DER object as a NULL.   r.   NFr}   r   r   r   r   r   S  s    zDerNull.__init__Nr~   r   r   r   r   r   P  s   r   c                   @   s4   e Zd ZdZdddZdd Zdd	d
Zdd ZdS )r   a,  Class to model a DER OBJECT ID.

    An example of encoding is:

    >>> from Cryptodome.Util.asn1 import DerObjectId
    >>> from binascii import hexlify, unhexlify
    >>> oid_der = DerObjectId("1.2")
    >>> oid_der.value += ".840.113549.1.1.1"
    >>> print hexlify(oid_der.encode())

    which will show ``06092a864886f70d010101``, the DER encoding for the
    RSA Object Identifier ``1.2.840.113549.1.1.1``.

    For decoding:

    >>> s = unhexlify(b'06092a864886f70d010101')
    >>> try:
    >>>   oid_der = DerObjectId()
    >>>   oid_der.decode(s)
    >>>   print oid_der.value
    >>> except ValueError:
    >>>   print "Not a valid DER OBJECT ID"

    the output will be ``1.2.840.113549.1.1.1``.

    :ivar value: The Object ID (OID), a dot separated list of integers
    :vartype value: string
     Nc                 C   s   t | dd|d| || _dS )a  Initialize the DER object as an OBJECT ID.

        :Parameters:
          value : string
            The initial Object Identifier (e.g. "1.2.0.0.6.2").
          implicit : integer
            The IMPLICIT tag to use for the encoded object.
            It overrides the universal tag for OBJECT ID (6).
          explicit : integer
            The EXPLICIT tag to use for the encoded object.
           r.   FNrI   rK   r   r   r   r   w  s    zDerObjectId.__init__c                 C   s   dd | j dD }t|dk r*tdtd|d  |d  | _|dd	 D ]h}|dkrddg}n6g }|r|d|d
@ dB  |dL }qh|d  d
M  < |  jddd |D 7  _qPt	| S )zCReturn the DER OBJECT ID, fully encoded as a
        binary string.c                 S   s   g | ]}t |qS r   )rN   rp   r   r   r   rs     r.   z&DerObjectId.encode.<locals>.<listcomp>.rH   z$Not a valid Object Identifier string(   r   r(   Nr:   r/      r.   c                 S   s   g | ]}t |qS r   )r   rp   r   r   r   rs     r.   )
rJ   splitr"   r$   r   r4   insertjoinr   r>   )r   compsvencr   r   r   r>     s    
 zDerObjectId.encodeFc                 C   s   t | ||S )ab  Decode a complete DER OBJECT ID, and re-initializes this
        object with it.

        Args:
            der_encoded (byte string):
                A complete DER OBJECT ID.
            strict (boolean):
                Whether decoding must check for strict DER compliancy.

        Raises:
            ValueError: in case of parsing errors.
        rQ   rR   r   r   r   rE     s    zDerObjectId.decodec                 C   s   t | || t| j}dd t| dD }d}| rp| }|d |d@  }|d@ s4|t| d}q4d	|| _
dS )	z,Decode a complete DER OBJECT ID from a file.c                 S   s   g | ]}t |qS r   )strrp   r   r   r   rs     r.   z1DerObjectId._decodeFromStream.<locals>.<listcomp>r   r   r/   r:   r   N)r   rB   r   r4   divmodr)   r#   rl   r   r   rJ   )r   r?   rD   rF   r   r   cr   r   r   rB     s    
zDerObjectId._decodeFromStream)r   NN)FrX   r   r   r   r   r   Y  s
   

r   c                   @   s4   e Zd ZdZdddZdd Zdd	d
Zdd ZdS )r   a  Class to model a DER BIT STRING.

    An example of encoding is:

    >>> from Cryptodome.Util.asn1 import DerBitString
    >>> bs_der = DerBitString(b'\xAA')
    >>> bs_der.value += b'\xBB'
    >>> print(bs_der.encode().hex())

    which will show ``030300aabb``, the DER encoding for the bit string
    ``b'\xAA\xBB'``.

    For decoding:

    >>> s = bytes.fromhex('030300aabb')
    >>> try:
    >>>   bs_der = DerBitString()
    >>>   bs_der.decode(s)
    >>>   print(bs_der.value.hex())
    >>> except ValueError:
    >>>   print "Not a valid DER BIT STRING"

    the output will be ``aabb``.

    :ivar value: The content of the string
    :vartype value: byte string
    r.   Nc                 C   s4   t | dd|d| t|t r*| | _n|| _dS )a  Initialize the DER object as a BIT STRING.

        :Parameters:
          value : byte string or DER object
            The initial, packed bit string.
            If not specified, the bit string is empty.
          implicit : integer
            The IMPLICIT tag to use for the encoded object.
            It overrides the universal tag for OCTET STRING (3).
          explicit : integer
            The EXPLICIT tag to use for the encoded object.
           r.   FN)r   r   
isinstancer>   rJ   rK   r   r   r   r     s    
zDerBitString.__init__c                 C   s   d| j  | _t| S )zBReturn the DER BIT STRING, fully encoded as a
        byte string.    )rJ   r4   r   r>   r   r   r   r   r>     s    zDerBitString.encodeFc                 C   s   t | ||S )aT  Decode a complete DER BIT STRING, and re-initializes this
        object with it.

        Args:
            der_encoded (byte string): a complete DER BIT STRING.
            strict (boolean):
                Whether decoding must check for strict DER compliancy.

        Raises:
            ValueError: in case of parsing errors.
        rQ   rR   r   r   r   rE     s    zDerBitString.decodec                 C   sN   t | || | jr.t| jd dkr.tdd| _| jrJ| jdd | _dS )z1Decode a complete DER BIT STRING DER from a file.r   zNot a valid BIT STRINGr.   r(   N)r   rB   r4   r   r$   rJ   )r   r?   rD   r   r   r   rB     s    zDerBitString._decodeFromStream)r.   NN)FrX   r   r   r   r   r     s
   

r   c                   @   sT   e Zd ZdZdddZdd Zdd Zd	d
 Zdd ZdddZ	dd Z
dd ZdS )r   a  Class to model a DER SET OF.

    An example of encoding is:

    >>> from Cryptodome.Util.asn1 import DerBitString
    >>> from binascii import hexlify, unhexlify
    >>> so_der = DerSetOf([4,5])
    >>> so_der.add(6)
    >>> print hexlify(so_der.encode())

    which will show ``3109020104020105020106``, the DER encoding
    of a SET OF with items 4,5, and 6.

    For decoding:

    >>> s = unhexlify(b'3109020104020105020106')
    >>> try:
    >>>   so_der = DerSetOf()
    >>>   so_der.decode(s)
    >>>   print [x for x in so_der]
    >>> except ValueError:
    >>>   print "Not a valid DER SET OF"

    the output will be ``[4, 5, 6]``.
    Nc                 C   s:   t | dd|d g | _d| _|r6|D ]}| | q&dS )a9  Initialize the DER object as a SET OF.

        :Parameters:
          startSet : container
            The initial set of integers or DER encoded objects.
          implicit : integer
            The IMPLICIT tag to use for the encoded object.
            It overrides the universal tag for SET OF (17).
           r.   TN)r   r   rZ   
_elemOctetadd)r   ZstartSetr6   er   r   r   r   1  s    
zDerSetOf.__init__c                 C   s
   | j | S r   r[   r\   r   r   r   r_   F  s    zDerSetOf.__getitem__c                 C   s
   t | jS r   )iterrZ   r   r   r   r   __iter__I  s    zDerSetOf.__iter__c                 C   s
   t | jS r   ri   r   r   r   r   rj   L  s    zDerSetOf.__len__c                 C   sh   t |rd}nt|tr | j}nt|d }| j|krN| jdurHtd|| _|| jvrd| j| dS )zAdd an element to the set.

        Args:
            elem (byte string or integer):
              An element of the same type of objects already in the set.
              It can be an integer or a DER encoded object.
        rH   r   Nz&New element does not belong to the set)	r   r   r   r2   r   r   r$   rZ   rl   )r   elemeor   r   r   r   O  s    	



zDerSetOf.addFc                 C   s   t | ||S )a  Decode a complete SET OF DER element, and re-initializes this
        object with it.

        DER INTEGERs are decoded into Python integers. Any other DER
        element is left undecoded; its validity is not checked.

        Args:
            der_encoded (byte string): a complete DER BIT SET OF.
            strict (boolean):
                Whether decoding must check for strict DER compliancy.

        Raises:
            ValueError: in case of parsing errors.
        rQ   rR   r   r   r   rE   g  s    zDerSetOf.decodec                 C   s   g | _ t| || t| j}d}| dkr|  t }||| |dk rX|j}n||jkrjtd|dkr| j 	|
  q"t }||
 | | j 	|j q"dS )z)Decode a complete DER SET OF from a file.r   r   z)Not all elements are of the same DER typerH   N)rZ   r   rB   r   r4   r#   r    r2   r$   rl   r!   r	   rE   rJ   )r   r?   rD   rF   Z
setIdOctetrx   ry   r   r   r   rB   y  s"    

zDerSetOf._decodeFromStreamc                 C   sf   g }| j D ]<}t|r$t| }nt|tr8| }n|}|| q
|  d|| _	t| S )zRReturn this SET OF DER element, fully encoded as a
        binary string.
        r.   )
rZ   r   r	   r>   r   r   rl   sortr   r4   )r   Zorderedrn   Zbysr   r   r   r>     s    


zDerSetOf.encode)NN)F)r*   r+   r,   r-   r   r_   r   rj   r   rE   rB   r>   r   r   r   r   r     s   

!r   )F)rT   ZCryptodome.Util.py3compatr   r   r   r   ZCryptodome.Util.numberr   r   __all__r   objectr   r   r	   r   r
   r   r   r   r   r   r   r   r   <module>   s   
	  0_ L-	dY