diff options
Diffstat (limited to 'src/ssl_routines.c')
-rw-r--r-- | src/ssl_routines.c | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/src/ssl_routines.c b/src/ssl_routines.c index 30a0714..ae20fe2 100644 --- a/src/ssl_routines.c +++ b/src/ssl_routines.c @@ -19,11 +19,21 @@ */ #include <config.h> - -#include "ssl_routines.h" #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <assert.h> + +#include "ssl_routines.h" + +/* + * Function name: check_public_key + * Description: Checks if the public key is trusted. + * Arguments: filename - the name of the file with stored keys + * hostname - the name of the host + * keyhash - the hash of the key + * Returns: The result of the check. + */ int check_public_key(char* filename, char* hostname, char* keyhash) @@ -32,6 +42,10 @@ check_public_key(char* filename, char* hostname, char* keyhash) char buff[256]; int lspaceind, i; + assert(filename != NULL); + assert(hostname != NULL); + assert(keyhash != NULL); + memset(buff, 0, 256); storefile = fopen(filename, "r"); @@ -68,10 +82,23 @@ check_public_key(char* filename, char* hostname, char* keyhash) return SSL_PUBLIC_KEY_NOT_KNOWN; } +/* + * Function name: add_public_key + * Description: Adds the key to the store file. + * Arguments: filename - the name of the file with stored keys + * hostname - the name of the host + * keyhash - the hash of the key + */ + void add_public_key(char* filename, char* hostname, char* keyhash) { FILE* storefile; + + assert(filename != NULL); + assert(hostname != NULL); + assert(keyhash != NULL); + storefile = fopen(filename, "a"); if (storefile == NULL) { return; |