File: //opt/alt/python37/lib/python3.7/site-packages/asn1crypto/__pycache__/core.cpython-37.pyc
B
    ]��X�K �               @   s�  d Z ddlmZmZmZmZ ddlmZmZ ddlZddl	Z	ddl
Z
ddlZddlZddl
mZ ddlmZ ddlmZ dd	lmZmZmZmZmZ dd
lmZmZ ddlmZmZmZm Z  ej!dkr�dd
l"m#Z$ e%Z&dZ'nddl(m$Z$ dZ'e�)�  ddddd�Z*ddddddddd�Z+ddd�Z,e�-d�Z.i Z/d�dd�Z0G dd � d e1�Z2G d!d"� d"�Z3G d#d$� d$e1�Z4G d%d&� d&e1�Z5G d'd(� d(e2�Z6e6� Z7G d)d*� d*e2�Z8G d+d,� d,e2�Z9G d-d.� d.e1�Z:G d/d0� d0e2�Z;G d1d2� d2e5e;�Z<G d3d4� d4e;�Z=G d5d6� d6e;e3�Z>G d7d8� d8e5e4e;e3e1�Z?G d9d:� d:e5e4e;�Z@G d;d<� d<e5e4e;�ZAG d=d>� d>e5e4e;�ZBG d?d@� d@e5e4e;�ZCG dAdB� dBe5e4e;�ZDG dCdD� dDeD�ZEG dEdF� dFe;�ZFG dGdH� dHe;e3�ZGG dIdJ� dJe;�ZHG dKdL� dLe;�ZIG dMdN� dNe;�ZJG dOdP� dPe>�ZKG dQdR� dRe<�ZLG dSdT� dTeG�ZMG dUdV� dVe2�ZNG dWdX� dXe2�ZOG dYdZ� dZeN�ZPG d[d\� d\eO�ZQG d]d^� d^eN�ZRG d_d`� d`e<�ZSG dadb� dbe<�ZTG dcdd� dde<�ZUG dedf� dfeB�ZVG dgdh� dhe<�ZWG didj� dje<�ZXG dkdl� dleX�ZYG dmdn� dneX�ZZG dodp� dpe<�Z[G dqdr� dre<�Z\G dsdt� dte<�Z]G dudv� dve<�Z^G dwdx� dxe<�Z_G dydz� dze<�Z`d{d|� Zad}d~� Zbdd�� Zce=e>e?eBeFeGeHeIeJeKeReLeMeNePeSeTeUeVeWeYeZe[e\e]e^e_e`d��Zdd�d�d��Zed�d�d��ZfdS )�a  
ASN.1 type classes for universal types. Exports the following items:
 - load()
 - Any()
 - Asn1Value()
 - BitString()
 - BMPString()
 - Boolean()
 - CharacterString()
 - Choice()
 - EmbeddedPdv()
 - Enumerated()
 - GeneralizedTime()
 - GeneralString()
 - GraphicString()
 - IA5String()
 - InstanceOf()
 - Integer()
 - IntegerBitString()
 - IntegerOctetString()
 - Null()
 - NumericString()
 - ObjectDescriptor()
 - ObjectIdentifier()
 - OctetBitString()
 - OctetString()
 - PrintableString()
 - Real()
 - RelativeOid()
 - Sequence()
 - SequenceOf()
 - Set()
 - SetOf()
 - TeletexString()
 - UniversalString()
 - UTCTime()
 - UTF8String()
 - VideotexString()
 - VisibleString()
 - VOID
 - Void()
Other type classes are defined that help compose the types listed above.
�    )�unicode_literals�division�absolute_import�print_function)�datetime�	timedeltaN�   )�_teletex_codec)�unwrap)�OrderedDict)�	type_name�str_cls�byte_cls�	int_types�chr_cls)�_parse�_dump_header)�int_to_bytes�int_from_bytes�timezone�extended_datetime)�   )�StringIOT)�BytesIOF�	universal�application�context�private)r   r   �   r   r   r   )r   r   r   r   r   r   r   r   Z	primitiveZconstructed)r   r   z
^\d+(\.\d+)*$c             C   s   t j| |d�S )a5  
    Loads a BER/DER-encoded byte string and construct a universal object based
    on the tag value:
     - 1: Boolean
     - 2: Integer
     - 3: BitString
     - 4: OctetString
     - 5: Null
     - 6: ObjectIdentifier
     - 7: ObjectDescriptor
     - 8: InstanceOf
     - 9: Real
     - 10: Enumerated
     - 11: EmbeddedPdv
     - 12: UTF8String
     - 13: RelativeOid
     - 16: Sequence,
     - 17: Set
     - 18: NumericString
     - 19: PrintableString
     - 20: TeletexString
     - 21: VideotexString
     - 22: IA5String
     - 23: UTCTime
     - 24: GeneralizedTime
     - 25: GraphicString
     - 26: VisibleString
     - 27: GeneralString
     - 28: UniversalString
     - 29: CharacterString
     - 30: BMPString
    :param encoded_data:
        A byte string of BER or DER-encoded data
    :param strict:
        A boolean indicating if trailing data should be forbidden - if so, a
        ValueError will be raised when trailing data exists
    :raises:
        ValueError - when strict is True and trailing data is present
        ValueError - when the encoded value tag a tag other than listed above
        ValueError - when the ASN.1 header length is longer than the data
        TypeError - when encoded_data is not a byte string
    :return:
        An instance of the one of the universal classes
    )�strict)�	Asn1Value�load)�encoded_datar   � r#   �@/opt/alt/python37/lib/python3.7/site-packages/asn1crypto/core.pyr!   r   s    3r!   c               @   s�   e Zd ZdZdZdZdZdZdZdZ	dZ
dZdZdZ
dZed$dd��Zd%dd�Zd	d
� Zdd� Zd
d� Zdd� Zdd� Zdd� Zdd� Zdd� Zdd� Zdd� Zdd� Zd&d d!�Zd'd"d#�ZdS )(r    z'
    The basis of all ASN.1 values
    N�    Fc             K   sD   t |t�stdt|� ��d}| jdk	r,| }t||||d�\}}|S )a�  
        Loads a BER/DER-encoded byte string using the current class as the spec
        :param encoded_data:
            A byte string of BER or DER-encoded data
        :param strict:
            A boolean indicating if trailing data should be forbidden - if so, a
            ValueError will be raised when trailing data exists
        :return:
            An instance of the current class
        z*encoded_data must be a byte string, not %sN)�spec�spec_paramsr   )�
isinstancer   �	TypeErrorr   �tag�_parse_build)�clsr"