aboutsummaryrefslogtreecommitdiff
path: root/ssh/tomsg_clientlib.c
diff options
context:
space:
mode:
Diffstat (limited to 'ssh/tomsg_clientlib.c')
-rw-r--r--ssh/tomsg_clientlib.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/ssh/tomsg_clientlib.c b/ssh/tomsg_clientlib.c
index 9898b66..80a9bf3 100644
--- a/ssh/tomsg_clientlib.c
+++ b/ssh/tomsg_clientlib.c
@@ -34,13 +34,6 @@ struct tomsg_client {
static size_t min_size_t(size_t a, size_t b) { return a < b ? a : b; }
-static bool hostkey_checker(const unsigned char *hash, size_t length, void *userdata) {
- (void)userdata;
- static const char *preload = "SHA256:ppz/McaESpOQy0O3kbaIi1LPZ37/YtrdC+y9102Y0+I";
- const char *fingerprint = sshnc_print_hash(hash, length);
- return strcmp(fingerprint, preload) == 0;
-}
-
static bool hasspacelf(const char *string) {
for (size_t i = 0; string[i]; i++)
if (string[i] == ' ' || string[i] == '\n') return true;
@@ -139,6 +132,10 @@ static void splice_scanned_buffer_part(struct tomsg_client *client) {
client->buffer_newline_cursor = 0;
}
+const char* tomsg_print_hash(const unsigned char *hash, size_t length) {
+ return sshnc_print_hash(hash, length);
+}
+
const char* tomsg_strerror(enum tomsg_retval code) {
switch (code) {
case TOMSG_OK: return "Success";
@@ -190,13 +187,15 @@ static enum tomsg_retval version_negotiation(struct tomsg_client *client) {
}
enum tomsg_retval tomsg_connect(
- const char *hostname, int port, struct tomsg_client **clientp) {
+ const char *hostname, int port,
+ tomsg_hostkey_checker_t checker, void *userdata,
+ struct tomsg_client **clientp) {
// In case we throw an error along the way
*clientp = NULL;
struct sshnc_client *conn;
enum sshnc_retval ret = sshnc_connect(
- hostname, port, "tomsg", "tomsg", hostkey_checker, NULL, &conn);
+ hostname, port, "tomsg", "tomsg", checker, userdata, &conn);
if (ret == SSHNC_ERR_CONNECT) return TOMSG_ERR_CONNECT;
if (ret != SSHNC_OK) return TOMSG_ERR_TRANSPORT;