Viewing File: /opt/imunify360/venv/lib/python3.11/site-packages/Crypto/Util/__pycache__/asn1.cpython-311.pyc



]jIZddlZddlmZmZmZddlmZmZgdZddZ	Gdde
ZGd	d
e
ZGddeZ
Gd
deZGddeZGddeZGddeZGddeZGddeZGddeZdS)N)byte_stringbchrbord)
long_to_bytes
bytes_to_long)		DerObject
DerInteger
DerBooleanDerOctetStringDerNullDerSequenceDerObjectIdDerBitStringDerSetOfFcHd}	||z}n#t$rYdSwxYw|p|dkS)NrF)	TypeError)xonly_non_negativetests   r/builddir/build/BUILD/imunify360-venv-2.6.3/opt/imunify360/venv/lib64/python3.11/site-packages/Crypto/Util/asn1.py
_is_numberr(sKD4xuu  *AF*s

c6eZdZdZdZdZdZdZdZdZ	dS)	BytesIO_EOFzeThis class differs from BytesIO in that a ValueError exception is
    raised whenever EOF is reached.c0||_d|_d|_dSNr)_buffer_index	_bookmark)self
initial_bytess  r__init__zBytesIO_EOF.__init__5s$c|j|_dSN)rrrs rset_bookmarkzBytesIO_EOF.set_bookmark:sr"cF|jJ|j|j|jSr$)rrrr%s rdata_since_bookmarkzBytesIO_EOF.data_since_bookmark=s&~)))|DN4;677r"c:t|j|jz
Sr$)lenrrr%s rremaining_datazBytesIO_EOF.remaining_dataAs4<  4;..r"c|j|z}|t|jkr&td|t|jfz|j|j|}||_|S)Nz@Not enough data for DER decoding: expected %d bytes and found %d)rr*r
ValueError)rlength	new_indexresults    rreadzBytesIO_EOF.readDsyK&(	s4<((((_clnqrvr~nncAABB
Bdk)34
r"cRt|ddS)Nr)rr1r%s r	read_bytezBytesIO_EOF.read_byteMsDIIaLLO$$$r"N)
__name__
__module____qualname____doc__r!r&r(r+r1r4r"rrr1sx''
%%%888///%%%%%r"rcTeZdZdZ		ddZdZedZdZd	Z	d
d
Z
dZdS)rzpBase class for defining a single DER object.

        This class should never be directly instantiated.
        Nr"Fc<|	d|_dS||}||_|rdnd}d||fvrtd|"d|z||z|_dS|)d||z|_||z|_dS||z|_dS)aInitialize the DER object according to a specific ASN.1 type.

                :Parameters:
                  asn1Id : integer or byte
                    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 or byte
                    The IMPLICIT tag number (< 0x1F) to use for the encoded object.
                    It overrides the universal tag *asn1Id*.
                    It cannot be combined with the ``explicit`` parameter.
                    By default, there is no IMPLICIT tag.

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

                  explicit : integer or byte
                    The EXPLICIT tag number (< 0x1F) to use for the encoded object.
                    It cannot be combined with the ``implicit`` parameter.
                    By default, there is no EXPLICIT tag.
                N rz1Explicit and implicit tags are mutually exclusive)
_tag_octet_convertTagpayloadr-_inner_tag_octet)rasn1IdrAimplicitconstructedexplicitconstructed_bits       rr!zDerObject.__init__Ws>>&*DOF))&11& +6"?$$4(333$&;<<<'&*_&<t?O?OPX?Y?Y&YDOOO)&1D4D4DX4N4N&NDO,;f,DD)))'6&>DOOOr"ct|s(t|dkrt|d}t|rd|cxkrdksntd|S)zCheck if *tag* is a real DER tag (5 bits).
                Convert it from a character to number if necessary.
                r3rz
Wrong DER tag)rr*rr-)rtags  rr@zDerObject._convertTagsg"#+3xx1}}"3q6ll"36AOOOOtOOOO$_555
r"c|dkr1t|}tt|dz|zSt|S)zXBuild length octets according to BER/DER
                definite form.
                r=)rrr*)r.encodings  r_definite_formzDerObject._definite_formsD
C<<#0#8#8#CMMC$7888CCF||#r"c,|j}t|drDt|j|t|jz|jz}t|j|t|z|zS)z?Return this DER element, fully encoded as a binary byte string.rB)rAhasattrrrBrNr*r?)routput_payloads  rencodezDerObject.encodes"&4!3444&*4+@&A&A&*&9&9#dl:K:K&L&L'M&*l'3NT_--++C,?,?@@A&'(r"c|}|dkrd||dz}t|ddkrtdt	|}|dkrtd|S)z%Decode DER length octets from a file.rLrz$Invalid DER: length has leading zeroz5Invalid DER: length in long form but smaller than 128)r4r1rr-r)rsr.encoded_lengths    r
_decodeLenzDerObject._decodeLensC<<%&VVFTM%:%:NN1-..!33()OPPP*>::F}}()`aaa
r"ct|stdt|}||||dkrtd|S)aDecode 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.
                zInput is not a byte stringr-Unexpected extra data after the DER structure)rr-r_decodeFromStreamr+)rder_encodedstrictrTs    rdecodezDerObject.decodest#;//C$%ABBB,,&&q&111##%%))$%TUUUr"c2|}|j||jkrtdn||_||}|||_t
|drt|j}|}||jkrtd||}|||_|	dkrtddSdS)z*Decode a complete DER element from a file.NzUnexpected DER tagrBzUnexpected internal DER tagrrX)
r4r?r-rVr1rArPrrBr+)rrTr[idOctetr.pinner_octets       rrYzDerObject._decodeFromStreams++--?.$/11()=>>>2'.DO++ vvf~~4!344
Z#DL11A"#++--K"d&;;;()FGGG!__Q//F#$66&>>DL''))A--()XYYY
Z
Z.-r")Nr"NFNF)r5r6r7r8r!r@staticmethodrNrRrVr\rYr9r"rrrQs		
?C15D	?D	?D	?D	?L
	
	
	
	$	$
	$	(	(	(&
	
	
					.	Z	Z	Z	Z	Zr"rc.eZdZdZd	dZdZd
dZdZdS)r	aClass to model a DER INTEGER.

        An example of encoding is::

          >>> from Crypto.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
        rNcRt|dd|d|||_dS)aUInitialize 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"FNrr!valuerrgrDrFs    rr!zDerInteger.__init__#s4""4sH#((444"


r"c2|j}d|_	tt|dz|jz|_d|cxkrdkrnntd|jz|_d|cxkrdkrnnn|dz}ot|S)zIReturn the DER INTEGER, fully encoded as a
                binary string.r"Tr=ri)rgrArintrrR)rnumbers  rrRzDerInteger.encode3s"!#'FSL(9(9#:#:T\#IDLf+++++++++'+DzzDL'@v,,,,,,,,,qLF
!!''---r"Fc<t|||S)aDecode a DER-encoded INTEGER, and re-initializes this
                object with it.

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

                Raises:
                  ValueError: in case of parsing errors.
                r[rr\rrZr[s   rr\zDerInteger.decodeBs!''k&'IIIr"c0t||||rzt|jdkrt	dt|jdkr;tjd|jddddkrt	dd|_d}|jD]4}|xjd	zc_|xjt|z
c_|d
z}5|jr/t|jddzr|xj|zc_dSdSdS)z*Decode a complete DER INTEGER from a file.rz/Invalid encoding for DER INTEGER: empty payloadrez>HNr=z.Invalid encoding for DER INTEGER: leading zeror3rk)	rrYr*rAr-structunpackrgr)rrTr[bitsis     rrYzDerInteger._decodeFromStreamOs4++D!V<<<[4<((A--()Z[[[4<((A--&-dlSUTUSUFV2W2WXY2Z]a2a2a()YZZZ
AJJ#%JJJJ$q'')JJQJDD<'Da$9$9D$@'JJ$&JJJJ''''r")rNNrar5r6r7r8r!rRr\rYr9r"rr	r	sh		6	#	#	#	# 
	.
	.
	.	J	J	J	J	'	'	'	'	'r"r	c.eZdZdZddZdZd	dZdZdS)
r
aRClass to model a DER-encoded BOOLEAN.

    An example of encoding is::

    >>> from Crypto.Util.asn1 import DerBoolean
    >>> bool_der = DerBoolean(True)
    >>> print(bool_der.encode().hex())

    which will show ``0101ff``, the DER encoding of True.

    And for decoding::

    >>> s = bytes.fromhex('0101ff')
    >>> try:
    >>>   bool_der = DerBoolean()
    >>>   bool_der.decode(s)
    >>>   print(bool_der.value)
    >>> except ValueError:
    >>>   print "Not a valid DER BOOLEAN"

    the output will be ``True``.

    :ivar value: The boolean value
    :vartype value: boolean
    FNcRt|dd|d|||_dS)aInitialize the DER object as a BOOLEAN.

        Args:
          value (boolean):
            The value of the boolean. Default is False.

          implicit (integer or byte):
            The IMPLICIT tag number (< 0x1F) to use for the encoded object.
            It overrides the universal tag for BOOLEAN (1).
            It cannot be combined with the ``explicit`` parameter.
            By default, there is no IMPLICIT tag.

          explicit (integer or byte):
            The EXPLICIT tag number (< 0x1F) to use for the encoded object.
            It cannot be combined with the ``implicit`` parameter.
            By default, there is no EXPLICIT tag.
        r3r"FNrfrhs    rr!zDerBoolean.__init__s-&	4sHeXFFF


r"cV|jrdnd|_t|S)z9Return the DER BOOLEAN, fully encoded as a binary string.rgrArrRr%s rrRzDerBoolean.encodes*#'*9ww'%%%r"c:t|||S)zDecode a DER-encoded BOOLEAN, and re-initializes this object with it.

        Args:
            der_encoded (byte string): A DER-encoded BOOLEAN.

        Raises:
            ValueError: in case of parsing errors.
        rprqs   rr\zDerBoolean.decodesk6:::r"cBt|||t|jdkrt	dt|jddkr	d|_dSt|jddkr	d|_dSt	d)	z)Decode a DER-encoded BOOLEAN from a file.r3z7Invalid encoding for DER BOOLEAN: payload is not 1 byterFrjTzInvalid payload for DER BOOLEANN)rrYr*rAr-rrgrrTr[s   rrYzDerBoolean._decodeFromStreams	##D!V444t|!!VWWWQ  A%%DJJJ
$,q/
"
"d
*
*DJJJ>???r")FNNrarxr9r"rr
r
fsi2,&&&
;
;
;
;@@@@@r"r
czeZdZdZddZdZdZdZdZdZ	d	Z
d
ZdZdZ
d
ZddZddZdZddZdZdS)r
aClass 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 Crypto.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'']

        Ncht|dd|d||	g|_dS||_dS)aCInitialize the DER object as a SEQUENCE.

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

                  implicit : integer or byte
                    The IMPLICIT tag number (< 0x1F) to use for the encoded object.
                    It overrides the universal tag for SEQUENCE (16).
                    It cannot be combined with the ``explicit`` parameter.
                    By default, there is no IMPLICIT tag.

                  explicit : integer or byte
                    The EXPLICIT tag number (< 0x1F) to use for the encoded object.
                    It cannot be combined with the ``implicit`` parameter.
                    By default, there is no EXPLICIT tag.
                r"TN)rr!_seq)rstartSeqrDrFs    rr!zDerSequence.__init__s>(""4sHdHMMM# "DIII (DIIIr"c|j|=dSr$rrns  r__delitem__zDerSequence.__delitem__sIaLLLr"c|j|Sr$rrs  r__getitem__zDerSequence.__getitem__sy|#r"c||j|<dSr$r)rkeyrgs   r__setitem__zDerSequence.__setitem__s!&	#r"c||j||<dSr$r)rrwjsequences    r__setslice__zDerSequence.__setslice__	s!)	!A#r"c|j||=dSr$rrrwrs   r__delslice__zDerSequence.__delslice__sIacNNNr"cX|jtd|td|Sr)rmaxrs   r__getslice__zDerSequence.__getslice__s$yQ3q!99!455r"c*t|jSr$r*rr%s r__len__zDerSequence.__len__s49~~%r"c:|j||Sr$rappendritems  r__iadd__zDerSequence.__iadd__	  &&&r"c:|j||Sr$rrs  rrzDerSequence.appendrr"c<|j|||Sr$)rinsert)rindexrs   rrzDerSequence.inserts	  ---r"TcHfd|jD}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.
                c4g|]}t||Sr9)r).0rrs  r
<listcomp>z'DerSequence.hasInts.<locals>.<listcomp>*s)RRRqA?P1Q1QRRRRr")rr*)rritemss ` rhasIntszDerSequence.hasInts!s-SRRRDIRRR5zz!r"cf|jo*||t|jkS)aReturn ``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``.)rrr*)rrs  rhasOnlyIntszDerSequence.hasOnlyInts-s+yVT\\2C%D%DDI%VVr"cZd|_|jD]}t|r|xj|z
c_"t|r0|xjt	|z
c_a|xj|z
c_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")rArrrr	rRrrs  rrRzDerSequence.encode:s # I66D"4((6,#D))6
4(8(8(?(?(A(AA

5 ''---r"Fc||_t|||}|r#|st	d|S)a9Decode 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.
                rozSome members are not INTEGERs)_nr_elementsrr\rr-)rrZr[nr_elementsonly_ints_expectedr0s      rr\zDerSequence.decodeLsW*%0!"))$F)KK%Fd.>.>.@.@F$%DEEE
r"cVg|_t|||t|j}|dkr|t}||||jdkr-|j|	nXt}|	}||||j|j|dkd}|j
J	t|j|j
v}n-#t$r t|j|j
k}YnwxYw|s$t!dt|jzdS)z+Decode a complete DER SEQUENCE from a file.rreroTNz1Unexpected number of members (%d) in the sequence)rrrYrrAr+r&r?rr(r	r\rgrr*rr-)rrTr[r_derderIntdataoks        rrYzDerSequence._decodeFromStreamis	++D!V<<< --&&((1,,NN$$$#++C))!V444~--	(()>)>)@)@AAAA!+ 4466

d6
:::	((666&&((1,,$0A ^^t/@@$AAA ^^t/@@AJ$&8:=di..&IJJJJJs:E'F?F)NNN)T)FNF)r5r6r7r8r!rrrrrrrrrrrrrRr\rYr9r"rr
r
s,(	(	T	)	)	)	)8	!	!	!	$	$	$	'	'	'	*	*	*	#	#	#	6	6	6	&	&	&									
	"
	"
	"
	"	W	W	W	W	.	.	.$				:"	J"	J"	J"	J"	Jr"r
ceZdZdZddZdS)raClass to model a DER OCTET STRING.

    An example of encoding is:

    >>> from Crypto.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"NcBt|d||ddS)ahInitialize 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).
        FNrr!)rrgrDs   rr!zDerOctetString.__init__s&	4uh>>>>>r")r"Nr5r6r7r8r!r9r"rrrs2:??????r"rceZdZdZdZdS)rz"Class to model a DER NULL element.cBt|dddddS)z$Initialize the DER object as a NULL.r"NFrr%s rr!zDerNull.__init__s&	4sD%88888r"Nrr9r"rrrs),,99999r"rc.eZdZdZd	dZdZd
dZdZdS)ra(Class to model a DER OBJECT ID.

    An example of encoding is:

    >>> from Crypto.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
    NcRt|dd|d|||_dS)aInitialize 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"FNrfrhs    rr!zDerObjectId.__init__s-	4sHeXFFF


r"cd|jdD}t|dkrtd|ddkrtd|ddkr|ddkrtd	d
|dz|dzg|ddz}g}t	|D]C}||dz|d
z}|r"||dzdz|d
z}|"Dddt	|D|_t	|S)zCReturn the DER OBJECT ID, fully encoded as a
        binary string.c,g|]}t|Sr9)rlrrs  rrz&DerObjectId.encode.<locals>.<listcomp>s777AQ777r".rez$Not a valid Object Identifier stringrz!First component must be 0, 1 or 2r3'z#Second component must be 39 at most(NrLr=r"c,g|]}t|Sr9)rrs  rrz&DerObjectId.encode.<locals>.<listcomp>s E E EQa E E Er")
rgsplitr*r-reversedrjoinrArrR)rcompssubcompsrMvs     rrRzDerObjectId.encodesa87!1!1#!6!6777u::>>CDDD8a<<@AAA8a<<E!HrMMBCCCqME!H,-abb	9(##		AOOAH%%%
!GA
TT 1222a
xx E E(82D2D E E EFF%%%r"Fc:t|||S)abDecode 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.
        rprqs   rr\zDerObjectId.decodesk6:::r"cZt|||t|j}g}d}|rO|}|dz|dzz}|dzs||d}|Ot|dkrtd|ddkrd|dg|dd<n1|dd	krd|ddz
g|dd<nd
|dd	z
g|dd<d	d|D|_
dS)
z,Decode a complete DER OBJECT ID from a file.rrrLr=z
Empty payloadrNr3Prerc,g|]}t|Sr9)strrs  rrz1DerObjectId._decodeFromStream.<locals>.<listcomp>7s888!s1vv888r")rrYrrAr+r4rr*r-rrg)rrTr[r_rrcs       rrYzDerObjectId._decodeFromStreamsX	##D!V444
%%
  	

AaAH%AH
"""  	x==A_---A;x{+HRaRLL
a[2

x{R/0HRaRLLx{R/0HRaRLXX88x88899


r")rNNrarxr9r"rrrsd:



&&&4;;;; :::::r"rc.eZdZdZd	dZdZd
dZdZdS)raClass to model a DER BIT STRING.

    An example of encoding is:

    >>> from Crypto.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"Nct|dd|d|t|tr||_dS||_dS)aInitialize 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 BIT STRING (3).
          explicit : integer
            The EXPLICIT tag to use for the encoded object.
        r"FN)rr!
isinstancerRrgrhs    rr!zDerBitString.__init__WsT	4sHeXFFFeY''	DJJJDJJJr"cTd|jz|_t|S)zBReturn the DER BIT STRING, fully encoded as a
        byte string.r}r~r%s rrRzDerBitString.encodels&
+%%%r"Fc:t|||S)aTDecode 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.
        rprqs   rr\zDerBitString.decodetsk6:::r"ct||||jr-t|jddkrt	dd|_|jr|jdd|_dSdS)z1Decode a complete DER BIT STRING DER from a file.rzNot a valid BIT STRINGr"r3N)rrYrArr-rgrs   rrYzDerBitString._decodeFromStreams	##D!V444<	7Da11Q665666
<	*abb)DJJJ	*	*r")r"NNrarxr9r"rrr:sd8*&&&
;
;
;
;
*
*
*
*
*r"rcFeZdZdZddZdZdZdZdZd
d	Z	d
Z
dZdS)raClass to model a DER SET OF.

    An example of encoding is:

    >>> from Crypto.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]``.
    Nct|dd|dg|_d|_|r|D]}||dSdS)a9Initialize 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)rr!r
_elemOctetadd)rstartSetrDes    rr!zDerSetOf.__init__sl	4sHd;;;		

		

r"c|j|Sr$rrs  rrzDerSetOf.__getitem__sy|r"c*t|jSr$)iterrr%s r__iter__zDerSetOf.__iter__sDIr"c*t|jSr$rr%s rrzDerSetOf.__len__s49~~r"c(t|rd}n2t|tr|j}nt	|d}|j|kr|jt
d||_||jvr|j|dSdS)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.
        rerNz&New element does not belong to the set)	rrrr?rrr-rr)relemeos   rrzDerSetOf.addsd	BB
i
(
(	BBd1gB?b  * !IJJJ DOty  IT"""""! r"Fc:t|||S)aDecode 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.
        rprqs   rr\zDerSetOf.decodes k6:::r"cg|_t|||t|j}d}|dkr|t}||||dkr|j}n||jkrtd|dkr-|j	|
nUt}||
||j	|j
|dkdSdS)z)Decode a complete DER SET OF from a file.rz)Not all elements are of the same DER typereN)rrrYrrAr+r&r?r-rr(r	r\rg)rrTr[r_
setIdOctetrrs       rrYzDerSetOf._decodeFromStreamsI		##D!V444
%%
  1$$
NN++C!!!V,,,A~~ ^

//$%PQQQT!!	  !6!6!8!89999#

a3355v>>>	  ...'  1$$$$$$r"cg}|jD]t}t|r"t|}n,t	|t
r|}n|}||u|d||_	t
|S)zRReturn this SET OF DER element, fully encoded as a
        binary string.
        r")
rrr	rRrrrsortrrA)rorderedrbyss    rrRzDerSetOf.encodesI	 	 D$
 &&--//D),,
kkmmNN3xx((%%%r")NNra)r5r6r7r8r!rrrrr\rYrRr9r"rrrs4*###0;;;;$///B&&&&&r"rra)rtCrypto.Util.py3compatrrrCrypto.Util.numberrr__all__robjectrrr	r
r
rrrrrr9r"r<module>rsv.


9999999999;;;;;;;;PPP++++%%%%%&%%%@sZsZsZsZsZsZsZsZl\'\'\'\'\'\'\'\'~P@P@P@P@P@P@P@P@fRJRJRJRJRJ)RJRJRJj*?*?*?*?*?Y*?*?*?Z99999i999s:s:s:s:s:)s:s:s:lV*V*V*V*V*9V*V*V*rU&U&U&U&U&yU&U&U&U&U&r"
Back to Directory File Manager