def _getData(self) -> bytes:
     data = b''
     # Add public key
     data += prependedLen(self.public_key, 1)
     # Prepend hanshake record
     data = b'\x10' + prependedLen(data, 3)
     return data
Exemple #2
0
 def __init__(self, hostnames: [str]):
     data = formattedArray([
         b'\0'  # Byte to indicate entry type is DNS Hostname
         + prependedLen(bytes(hostname, 'ascii', 'strict'))
         for hostname in hostnames
     ])
     super().__init__(SERVER_NAME_EXTENSION, data)
 def _getData(self) -> bytes:
     data = b''
     # Add client version
     data += b'\x03\x03'
     # Add random bytes
     data += self.randomness
     # Add session id
     data += b'\0'
     # Add ciphersuites
     data += prependedLen(b''.join(self.ciphersuites))
     # Add compression methods (We don't want any)
     data += b'\x01\x00'
     # Add extensions
     data += prependedLen(b''.join([bytes(e) for e in self.extensions]))
     # Prepend handshake header
     data = b'\x01' + prependedLen(data, 3)
     return data
Exemple #4
0
 def __init__(self, sigAlgos=[]):
     if not sigAlgos:
         sigAlgos = [RSA_PKCS1_SHA256]
     data = prependedLen(b''.join(sigAlgos))
     super().__init__(SIGNATURE_ALGORITHMS, data)
Exemple #5
0
 def __init__(self):
     data = prependedLen(b'\x00', 1)
     super().__init__(EC_POINT_FORMATS, data)
Exemple #6
0
 def __init__(self):
     # Hardcoded now to only support curve 25519.
     data = prependedLen(b'\x00\x1d')
     super().__init__(SUPPORTED_GROUPS, data)
Exemple #7
0
 def __bytes__(self):
     return self.extension_type + prependedLen(self.data)
 def __bytes__(self):
     # Prepend record header
     return self.content_type + self.version + prependedLen(self.data)