File: //home/arjun/projects/env/lib/python3.10/site-packages/Crypto/Util/__pycache__/asn1.cpython-310.pyc
o
we�{ � @ s� d dl Z d dlmZmZmZmZ d dlmZmZ g d�Z ddd�Z
G dd � d e�ZG d
d� de�Z
G dd
� d
e
�ZG dd� de
�ZG dd� de
�ZG dd� de
�ZG dd� de
�ZG dd� de
�ZG dd� de
�ZdS )� 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 dS w | p| dkS )Nr F)� TypeError)�x�only_non_negative�test� r �I/home/arjun/projects/env/lib/python3.10/site-packages/Crypto/Util/asn1.py�
_is_number! s �r c @ s@ e Zd ZdZdd� Zdd� Zdd� Zdd � Zd
d� Zdd
� Z dS )�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)�self�
initial_bytesr r r �__init__. s
zBytesIO_EOF.__init__c C s | j | _d S �N)r r �r r r r �set_bookmark3 � zBytesIO_EOF.set_bookmarkc C s | j d usJ �| j| j | j� S r )r r r r r r r �data_since_bookmark6 s zBytesIO_EOF.data_since_bookmarkc C s t | j�| j S r )�lenr r r r r r �remaining_data: � zBytesIO_EOF.remaining_datac C sH | j | }|t| j�krtd|t| j�f ��| j| j |� }|| _ |S )Nz@Not enough data for DER decoding: expected %d bytes and found %d)r r$ r �
ValueError)r �length� new_index�resultr r r �read= s
zBytesIO_EOF.readc C s t | �d�d �S )N� r )r r+ r r r r � read_byteF � zBytesIO_EOF.read_byteN)
�__name__�
__module__�__qualname__�__doc__r r! r# r% r+ r- r r r r r * s r c @ sT e Zd ZdZ ddd�Zdd� Zed d
� �Zdd� Zd
d� Z ddd�Z
dd� ZdS )r zpBase class for defining a single DER object.
This class should never be directly instantiated.
N� Fc C s� |du r d| _ dS | �|�}|| _d||fvrtd��|dur-dd| B | �|�B | _ dS |durBd| �|�B | _ d| |B | _dS d| |B | _ dS )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'