class documentation
SSHCiphers represents all the encryption operations that need to occur to encrypt and authenticate the SSH connection.
| Method | __init__ |
Undocumented |
| Method | decrypt |
Decrypt some data. |
| Method | encrypt |
Encrypt some data. |
| Method | make |
Create a message authentication code (MAC) for the given packet using the outgoing MAC values. |
| Method | set |
Set up the ciphers and hashes using the given keys, |
| Method | verify |
Verify an incoming MAC using the incoming MAC values. |
| Class Variable | cipher |
A dictionary mapping SSH encryption names to 3-tuples of (<cryptography.hazmat.primitives.interfaces.CipherAlgorithm>, <block size>, <cryptography.hazmat.primitives.interfaces.Mode>) |
| Class Variable | mac |
A dictionary mapping SSH MAC names to hash modules. |
| Instance Variable | dec |
the block size of the incoming cipher. |
| Instance Variable | decryptor |
Undocumented |
| Instance Variable | enc |
the block size of the outgoing cipher. |
| Instance Variable | encryptor |
Undocumented |
| Instance Variable | in |
the string type of the incoming cipher. |
| Instance Variable | in |
see outMAC, but for the incoming MAC. |
| Instance Variable | in |
Undocumented |
| Instance Variable | in |
the string type of the incoming MAC. |
| Instance Variable | out |
the string type of the outgoing cipher. |
| Instance Variable | out |
a tuple of (<hash module>, <inner key>, <outer key>, <digest size>) representing the outgoing MAC. |
| Instance Variable | out |
the string type of the incoming MAC. |
| Instance Variable | verify |
the size of the incoming MAC. |
| Method | _get |
Creates an initialized cipher object. |
| Method | _get |
Gets a 4-tuple representing the message authentication code. (<hash module>, <inner hash value>, <outer hash value>, <digest size>) |
Create a message authentication code (MAC) for the given packet using the outgoing MAC values.
| Parameters | |
seqid:int | The sequence ID of the outgoing packet. |
data:bytes | The data to create a MAC for. |
| Returns | |
str | The serialized MAC. |
Set up the ciphers and hashes using the given keys,
| Parameters | |
| out | the outgoing initialization vector |
| out | the outgoing encryption key |
| in | the incoming initialization vector |
| in | the incoming encryption key |
| out | the outgoing integrity key |
| in | the incoming integrity key. |
Verify an incoming MAC using the incoming MAC values.
| Parameters | |
seqid:int | The sequence ID of the incoming packet. |
data:bytes | The packet data to verify. |
mac:bytes | The MAC sent with the packet. |
| Returns | |
bool | True if the MAC is valid. |
A dictionary mapping SSH encryption names to 3-tuples of (<cryptography.hazmat.primitives.interfaces.CipherAlgorithm>, <block size>, <cryptography.hazmat.primitives.interfaces.Mode>)
Creates an initialized cipher object.
| Parameters | |
| cip | the name of the cipher, maps into cipherMap |
| iv | the initialzation vector |
| key | the encryption key |
| Returns | |
| the cipher object. |
def _getMAC(self, mac:
bytes, key: bytes) -> tuple[ None, Literal[ b''], Literal[ b''], Literal[ 0]] | _MACParams:
(source)
¶
Gets a 4-tuple representing the message authentication code. (<hash module>, <inner hash value>, <outer hash value>, <digest size>)
| Parameters | |
mac:bytes | a key mapping into macMap |
key:bytes | the MAC key. |
| Returns | |
bytes | The MAC components. |