Skip to content
Snippets Groups Projects
Commit 7b0f897a authored by Deucе's avatar Deucе :ok_hand_tone4:
Browse files

Add the "none" encryption mac and compression drivers

This is not the "hard part" I meantioned earlier. :D
parent 02be7ecc
No related branches found
No related tags found
No related merge requests found
Pipeline #7350 passed
......@@ -32,7 +32,7 @@ target_link_libraries(deuce-ssh_static INTERFACE stdthreads)
target_link_libraries(deuce-ssh_shared PRIVATE ${OPENSSL_CRYPTO_LIBRARIES})
target_link_libraries(deuce-ssh_shared PRIVATE stdthreads)
add_executable(client EXCLUDE_FROM_ALL client.c)
add_executable(client EXCLUDE_FROM_ALL client.c enc/none.c mac/none.c comp/none.c)
target_link_libraries(client PRIVATE stdthreads deuce-ssh)
install(TARGETS deuce-ssh FILE_SET HEADERS)
......@@ -9,6 +9,9 @@
#include <threads.h>
#include "ssh.h"
#include "enc/none.h"
#include "mac/none.h"
#include "comp/none.h"
int sock = -1;
size_t txbufsz;
......@@ -175,6 +178,12 @@ int main(int argc, char **argv)
return 1;
if (deuce_ssh_transport_set_callbacks(tx, rx, rxline, extra_line) != 0)
return 1;
if (register_none_enc() != 0)
return 1;
if (register_none_mac() != 0)
return 1;
if (register_none_comp() != 0)
return 1;
thrd_t thr;
thrd_create(&thr, tx_thread, NULL);
deuce_ssh_session_init(&sess);
......
#include "ssh-trans.h"
static int
compress(uint8_t *buf, uint8_t *bufsz, deuce_ssh_session_t sess)
{
return 0;
}
static int
uncompress(uint8_t *buf, uint8_t *bufsz, deuce_ssh_session_t sess)
{
return 0;
}
static void
cleanup(deuce_ssh_session_t sess)
{
return;
}
static struct deuce_ssh_comp none_comp = {
.next = NULL,
.compress = compress,
.uncompress = uncompress,
.cleanup = cleanup,
.name = "none",
};
int
register_none_comp(void)
{
return deuce_ssh_transport_register_comp(&none_comp);
}
#ifndef NONE_COMP_H
#define NONE_COMP_H
int register_none_comp(void);
#endif
#include "ssh-trans.h"
static int
encrypt(uint8_t *buf, uint8_t *bufsz, deuce_ssh_session_t sess)
{
return 0;
}
static int
decrypt(uint8_t *buf, uint8_t *bufsz, deuce_ssh_session_t sess)
{
return 0;
}
static void
cleanup(deuce_ssh_session_t sess)
{
return;
}
static struct deuce_ssh_enc none_enc = {
.next = NULL,
.encrypt = encrypt,
.decrypt = decrypt,
.cleanup = cleanup,
.flags = 0,
.blocksize = 1,
.key_size = 0,
.name = "none",
};
int
register_none_enc(void)
{
return deuce_ssh_transport_register_enc(&none_enc);
}
#ifndef NONE_ENC_H
#define NONE_ENC_H
int register_none_enc(void);
#endif
#include "ssh-trans.h"
static int
generate(uint8_t *key, uint8_t *buf, size_t bufsz, uint8_t *outbuf, deuce_ssh_session_t sess)
{
return 0;
}
static void
cleanup(deuce_ssh_session_t sess)
{
return;
}
static struct deuce_ssh_mac none_mac = {
.next = NULL,
.generate = generate,
.cleanup = cleanup,
.digest_size = 0,
.key_size = 0,
.name = "none",
};
int
register_none_mac(void)
{
return deuce_ssh_transport_register_mac(&none_mac);
}
#ifndef NONE_MAC_H
#define NONE_MAC_H
int register_none_mac(void);
#endif
......@@ -73,7 +73,7 @@ typedef int (*deuce_ssh_enc_encrypt_t)(uint8_t *buf, uint8_t *bufsz, deuce_ssh_s
typedef int (*deuce_ssh_enc_decrypt_t)(uint8_t *buf, uint8_t *bufsz, deuce_ssh_session_t sess);
typedef void (*deuce_ssh_enc_cleanup_t)(deuce_ssh_session_t sess);
typedef int (*deuce_ssh_mac_generate_t)(uint8_t *key, uint8_t *buf, uint8_t *bufsz, uint8_t *outbuf, deuce_ssh_session_t sess);
typedef int (*deuce_ssh_mac_generate_t)(uint8_t *key, uint8_t *buf, size_t bufsz, uint8_t *outbuf, deuce_ssh_session_t sess);
typedef void (*deuce_ssh_mac_cleanup_t)(deuce_ssh_session_t sess);
typedef int (*deuce_ssh_comp_compress_t)(uint8_t *buf, uint8_t *bufsz, deuce_ssh_session_t sess);
......@@ -112,8 +112,8 @@ typedef struct deuce_ssh_mac {
struct deuce_ssh_mac *next;
deuce_ssh_mac_generate_t generate;
deuce_ssh_mac_cleanup_t cleanup;
uint16_t *digest_size;
uint16_t *key_size;
uint16_t digest_size;
uint16_t key_size;
char name[];
} *deuce_ssh_mac_t;
......@@ -122,9 +122,6 @@ typedef struct deuce_ssh_comp {
deuce_ssh_comp_compress_t compress;
deuce_ssh_comp_uncompress_t uncompress;
deuce_ssh_comp_cleanup_t cleanup;
uint32_t flags;
uint16_t blocksize;
uint16_t key_size;
char name[];
} *deuce_ssh_comp_t;
......@@ -166,5 +163,11 @@ typedef struct deuce_ssh_transport_state {
int deuce_ssh_transport_init(deuce_ssh_session_t sess);
void deuce_ssh_transport_cleanup(deuce_ssh_session_t sess);
int deuce_ssh_transport_register_kex(deuce_ssh_kex_t kex);
int deuce_ssh_transport_register_key_algo(deuce_ssh_key_algo_t key_algo);
int deuce_ssh_transport_register_enc(deuce_ssh_enc_t enc);
int deuce_ssh_transport_register_mac(deuce_ssh_mac_t mac);
int deuce_ssh_transport_register_comp(deuce_ssh_comp_t comp);
int deuce_ssh_transport_register_lang(deuce_ssh_language_t lang);
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment