packet: Introduce a new function to access crypto

And remove most of the direct access to the structure throughout the code

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Daiki Ueno <dueno@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
Jakub Jelen
2018-11-22 15:57:37 +01:00
committed by Andreas Schneider
parent 8d90266661
commit 8e0c047031
11 changed files with 150 additions and 92 deletions

View File

@@ -136,6 +136,7 @@ struct ssh_crypto_struct {
char *kex_methods[SSH_KEX_METHODS];
enum ssh_key_exchange_e kex_type;
enum ssh_mac_e mac_type; /* Mac operations to use for key gen */
enum ssh_crypto_direction_e used; /* Is this crypto still used for either of directions? */
};
struct ssh_cipher_struct {

View File

@@ -83,5 +83,7 @@ unsigned char *ssh_packet_encrypt(ssh_session session,
unsigned int len);
int ssh_packet_hmac_verify(ssh_session session,ssh_buffer buffer,
unsigned char *mac, enum ssh_hmac_e type);
struct ssh_crypto_struct *ssh_packet_get_current_crypto(ssh_session session,
enum ssh_crypto_direction_e direction);
#endif /* PACKET_H_ */

View File

@@ -61,6 +61,12 @@ struct ssh_hmac_struct {
enum ssh_hmac_e hmac_type;
};
enum ssh_crypto_direction_e {
SSH_DIRECTION_IN = 1,
SSH_DIRECTION_OUT = 2,
SSH_DIRECTION_BOTH = 3,
};
struct ssh_cipher_struct;
typedef struct ssh_mac_ctx_struct *ssh_mac_ctx;