def name(self): result = name_map.get(self.bytes) if not result is None: return result if self.bytes[0] == 0: # SSLv3 or newer cipher suite return SSLv3Cipher.from_stream(struct.pack("BB", *self.bytes[1:3]))[0].name return None
def name(self): result = name_map.get(self.bytes) if not result is None: return result if self.bytes[0] == 0: # SSLv3 or newer cipher suite return SSLv3Cipher.from_stream(struct.pack( "BB", *self.bytes[1:3]))[0].name return None
def from_stream(body): """Parse a Server Hello record from body. Body should start with the byte representation of an RFC 5246 struct Server Hello. Returns a ServerHello and the number of bytes read from body Throws a struct.error or IndexError if there is not enough data to parse properly. """ version, index = Version.from_stream(body) random, read_amt = Random.from_stream(body[index:]) index += read_amt sessionid_length = struct.unpack_from("B", body, index)[0] index += 1 session_id, read_amt = ( parse.parse_tls_list( body[index:], sessionid_length, parse.parse_opaque)) index += read_amt cipher, read_amt = Cipher.from_stream(body[index:]) index += read_amt method, read_amt = CompressionMethod.from_stream(body[index:]) index += read_amt extensions = [] # Check if there are extensions present if len(body) != index: extensions_length = struct.unpack_from("!H", body, index)[0] index += 2 extensions, read_amt = ( parse.parse_tls_list( body[index:], extensions_length, Extension.from_stream)) index += read_amt return ServerHello( version, random, session_id, cipher, method, extensions), index
def from_stream(body): """Parse a Server Hello record from body. Body should start with the byte representation of an RFC 5246 struct Server Hello. Returns a ServerHello and the number of bytes read from body Throws a struct.error or IndexError if there is not enough data to parse properly. """ version, index = Version.from_stream(body) random, read_amt = Random.from_stream(body[index:]) index += read_amt sessionid_length = struct.unpack_from("B", body, index)[0] index += 1 session_id, read_amt = (parse.parse_tls_list(body[index:], sessionid_length, parse.parse_opaque)) index += read_amt cipher, read_amt = Cipher.from_stream(body[index:]) index += read_amt method, read_amt = CompressionMethod.from_stream(body[index:]) index += read_amt extensions = [] # Check if there are extensions present if len(body) != index: extensions_length = struct.unpack_from("!H", body, index)[0] index += 2 extensions, read_amt = (parse.parse_tls_list( body[index:], extensions_length, Extension.from_stream)) index += read_amt return ServerHello(version, random, session_id, cipher, method, extensions), index