← Back
Editing: _der.py
# This file is dual licensed under the terms of the Apache License, Version # 2.0, and the BSD License. See the LICENSE file in the root of this repository # for complete details. import typing from cryptography.utils import int_to_bytes # This module contains a lightweight DER encoder and decoder. See X.690 for the # specification. This module intentionally does not implement the more complex # BER encoding, only DER. # # Note this implementation treats an element's constructed bit as part of the # tag. This is fine for DER, where the bit is always computable from the type. CONSTRUCTED = 0x20 CONTEXT_SPECIFIC = 0x80 INTEGER = 0x02 BIT_STRING = 0x03 OCTET_STRING = 0x04 NULL = 0x05 OBJECT_IDENTIFIER = 0x06 SEQUENCE = 0x10 | CONSTRUCTED SET = 0x11 | CONSTRUCTED PRINTABLE_STRING = 0x13 UTC_TIME = 0x17 GENERALIZED_TIME = 0x18 class DERReader(object): def __init__(self, data): self.data = memoryview(data) def __enter__(self): return self def __exit__(self, exc_type, exc_value, tb): if exc_value is None: self.check_empty() def is_empty(self): return len(self.data) == 0 def check_empty(self): if not self.is_empty(): raise ValueError("Invalid DER input: trailing data") def read_byte(self) -> int: if len(self.data) < 1: raise ValueError("Invalid DER input: insufficient data") ret = self.data[0] self.data = self.data[1:] return ret def read_bytes(self, n) -> memoryview: if len(self.data) < n: raise ValueError("Invalid DER input: insufficient data") ret = self.data[:n] self.data = self.data[n:] return ret def read_any_element(self) -> typing.Tuple[int, "DERReader"]: tag = self.read_byte() # Tag numbers 31 or higher are stored in multiple bytes. No supported # ASN.1 types use such tags, so reject these. if tag & 0x1F == 0x1F: raise ValueError("Invalid DER input: unexpected high tag number") length_byte = self.read_byte() if length_byte & 0x80 == 0: # If the high bit is clear, the first length byte is the length. length = length_byte else: # If the high bit is set, the first length byte encodes the length # of the length. length_byte &= 0x7F if length_byte == 0: raise ValueError( "Invalid DER input: indefinite length form is not allowed " "in DER" ) length = 0 for i in range(length_byte): length <<= 8 length |= self.read_byte() if length == 0: raise ValueError( "Invalid DER input: length was not minimally-encoded" ) if length < 0x80: # If the length could have been encoded in short form, it must # not use long form. raise ValueError( "Invalid DER input: length was not minimally-encoded" ) body = self.read_bytes(length) return tag, DERReader(body) def read_element(self, expected_tag: int) -> "DERReader": tag, body = self.read_any_element() if tag != expected_tag: raise ValueError("Invalid DER input: unexpected tag") return body def read_single_element(self, expected_tag: int) -> "DERReader": with self: return self.read_element(expected_tag) def read_optional_element( self, expected_tag: int ) -> typing.Optional["DERReader"]: if len(self.data) > 0 and self.data[0] == expected_tag: return self.read_element(expected_tag) return None def as_integer(self) -> int: if len(self.data) == 0: raise ValueError("Invalid DER input: empty integer contents") first = self.data[0] if first & 0x80 == 0x80: raise ValueError("Negative DER integers are not supported") # The first 9 bits must not all be zero or all be ones. Otherwise, the # encoding should have been one byte shorter. if len(self.data) > 1: second = self.data[1] if first == 0 and second & 0x80 == 0: raise ValueError( "Invalid DER input: integer not minimally-encoded" ) return int.from_bytes(self.data, "big") def encode_der_integer(x: int) -> bytes: if not isinstance(x, int): raise ValueError("Value must be an integer") if x < 0: raise ValueError("Negative integers are not supported") n = x.bit_length() // 8 + 1 return int_to_bytes(x, n) def encode_der(tag: int, *children: bytes) -> bytes: length = 0 for child in children: length += len(child) chunks = [bytes([tag])] if length < 0x80: chunks.append(bytes([length])) else: length_bytes = int_to_bytes(length) chunks.append(bytes([0x80 | len(length_bytes)])) chunks.append(length_bytes) chunks.extend(children) return b"".join(chunks)
Mainco
https://validator.w3.org/feed/docs/rss2.html
WHALESPRAY CRACK-3 TINTA LIMPIADORA 400ML VERDE WS-3050-S
WHALESPRAY CRACK-2 TINTA REVELADORA 400ML BLANCO WS-1821-S
WHALESPRAY CRACK-1 TINTA PENETRANTE 400ML ROJO WS-1820-S
VIDRIO PARA MIRILLA TUBULAR TEMPLADO 4″
VIDRIO PARA MIRILLA TUBULAR TEMPLADO 21/2″
VIDRIO PARA MIRILLA TEMPLADO DN100 TIPO FLANGE ALTA PRESION
VIDRIO PARA MIRILLA TEMPLADO DN100
VASTAGO MOVIL P/BASE CUADRADA DE 11/2″
VARILLA PARA BOQUILLA SERIE DH/DS SS304 CON BOQUILLA DE PULVERIZADOR AJUSTABLE DE 3PIES
VARILLA LISA REDONDA SS304 3/8″
VARILLA LISA REDONDA SS304 3/4″
VARILLA LISA REDONDA SS304 3/16″
VARILLA LISA REDONDA SS304 1/8″
VARILLA LISA REDONDA SS304 1/4″
VARILLA LISA REDONDA SS304 1/2″
VALVULA SACAMUESTRAS CLAMP 1″-11/2″ SS316L JUNTA SILICON 10 BAR (120°C)
VALVULA SACAMUESTRAS ASEPTICA FARMA SOLDABLE 1″ DQW-01
VALVULA SACAMUESTRAS ASEPTICA FARMA CLAMP 2″ DQW-03 SS316L
VALVULA SACAMUESTRAS 3/4″ IQY-02 SS316L
VALVULA SACAMUESTRAS 1/4″ IQY-02 SS316L
VALVULA SACAMUESTRAS 1/2″ IQY-02 SS316L
VALVULA RETENCION WAFER 8″ H/FUNDIDO DISCO-DOBLE CF8M ASIENTO BUNA 16 BAR (-10°C-100°C)
VALVULA RETENCION WAFER 8″ CF8M DISCO-DOBLE CF8M ASIENTO VITON 25 BAR (-20°C-180°C)
VALVULA RETENCION WAFER 8″ CF8M DISCO CF8M ASIENTO VITON 16 BAR (-20°C-180°C)
VALVULA RETENCION WAFER 6″ H/FUNDIDO DISCO-DOBLE CF8M ASIENTO BUNA 16 BAR (-10°C-100°C)
VALVULA RETENCION WAFER 6″ CF8M DISCO-DOBLE CF8M ASIENTO VITON 25 BAR (-20°C-180°C)
VALVULA RETENCION WAFER 6″ CF8M DISCO CF8M ASIENTO VITON 16 BAR (-20°C-180°C)
VALVULA RETENCION WAFER 4″ H/FUNDIDO DISCO-DOBLE CF8M ASIENTO BUNA 16 BAR (-10°C-100°C)
VALVULA RETENCION WAFER 4″ CF8M DISCO-DOBLE CF8M ASIENTO VITON 25 BAR (-20°C-180°C)
VALVULA RETENCION WAFER 4″ CF8M DISCO CF8M ASIENTO VITON 16 BAR (-20°C-180°C)
VALVULA RETENCION WAFER 4″ CF8M DISCO CF8M 40 BAR (-20°C-240°C)
VALVULA RETENCION WAFER 3″ H/FUNDIDO DISCO-DOBLE CF8M ASIENTO BUNA 16 BAR (-10°C-100°C)
VALVULA RETENCION WAFER 3″ CF8M DISCO-DOBLE CF8M ASIENTO VITON 25 BAR (-20°C-180°C)
VALVULA RETENCION WAFER 3″ CF8M DISCO CF8M ASIENTO VITON 16 BAR (-20°C-180°C)
VALVULA RETENCION WAFER 3″ CF8M DISCO CF8M 40 BAR (-20°C-240°C)
VALVULA RETENCION WAFER 2″ CF8M DISCO CF8M ASIENTO VITON 16 BAR (-20°C-180°C)
VALVULA RETENCION WAFER 2″ CF8M DISCO CF8M 40 BAR (-20°C-240°C)
VALVULA RETENCION WAFER 1″ CF8M DISCO CF8M 40 BAR (-20°C-240°C)
VALVULA RETENCION SOLDABLE-SOCKET 2″ A/FORJADO PISTON F6A JUNTA SS304 140 BAR (-29°C-420°C)
VALVULA RETENCION SOLDABLE-SOCKET 11/2″ A/FORJADO PISTON F6A JUNTA SS304 140 BAR (-29°C-420°C)
VALVULA RETENCION SOLDABLE-SOCKET 1″ A/FORJADO PISTON F6A JUNTA SS304 140 BAR (-29°C-420°C)
VALVULA RETENCION SOLDABLE DN100 SS316L DISCO SS316L JUNTA EPDM 10 BAR (-10°C-120°C)
VALVULA RETENCION SOLDABLE 6″ SS316
VALVULA RETENCION SOLDABLE 4″ SS316
VALVULA RETENCION SOLDABLE 4″ SS304 DISCO SS304 JUNTA SILICON 10 BAR (-10°C-120°C)
VALVULA RETENCION SOLDABLE 3″ SS304 DISCO SS304 JUNTA SILICON 10 BAR (-10°C-120°C)
VALVULA RETENCION SOLDABLE 11/2″ SS316 JUNTA VITON
VALVULA RETENCION SOLDABLE 11/2″ SS316
Inicio
Blog