3 œäL]½#ã@s†dZddlmZmZmZmZddlZddlmZm Z m Z ddl m Z m Z ejdkZdZd d „Zdd d „Zdd„Zddd„Zdd„ZdS)zÈ Functions for parsing and dumping using the ASN.1 DER encoding. Exports the following items: - emit() - parse() - peek() Other type classes are defined that help compose the types listed above. é)Úunicode_literalsÚdivisionÚabsolute_importÚprint_functionNé)Úbyte_clsÚchr_clsÚ type_name)Úint_from_bytesÚ int_to_bytesézO}||d>O}|dkrt|t|dBƒ7}xJ|dkrp|dkrNdnd}|t||d@Bƒ7}|d?}q:Wn|t||Bƒ7}t|ƒ}|dkr¢|t|ƒ7}n$t|ƒ}|tdt|ƒBƒ7}||7}|S) aÇ Constructs the header bytes for an ASN.1 object :param class_: An integer ASN.1 class value: 0 (universal), 1 (application), 2 (context), 3 (private) :param method: An integer ASN.1 method value: 0 (primitive), 1 (constructed) :param tag: An integer ASN.1 tag value :param contents: A byte string of the encoded byte contents :return: A byte string of the ASN.1 DER header r)rr'r(r!r#r"r$)rrr ) rrrrÚheaderZid_numZcontinuation_bitÚlengthZ length_bytesrrrrõs$   r)r )F)rF)Ú__doc__Ú __future__rrrrÚsysÚ_typesrrr Úutilr r Ú version_infor+r*rrrrrrrrrÚ s 1 ' j