X-Git-Url: http://git.silcnet.org/gitweb/?p=silc.git;a=blobdiff_plain;f=lib%2Fsilcapputil%2Fsilcapputil.c;h=833f40e29b4d230eeb1d1b24120b43d2fb746b13;hp=67df01eb161720ed6f9075659c8d4f8c43b1acd1;hb=52e57c880aba9c5e89f59d962eb9af75670b76e0;hpb=ae1482a76c29db9fdcd6ed6cf63d312a37a5cb01 diff --git a/lib/silcapputil/silcapputil.c b/lib/silcapputil/silcapputil.c index 67df01eb..833f40e2 100644 --- a/lib/silcapputil/silcapputil.c +++ b/lib/silcapputil/silcapputil.c @@ -146,6 +146,12 @@ New pair of keys will be created. Please, answer to following questions.\n\ silc_free(def); } + if (!strstr(identifier, "UN=") || !strstr(identifier, "HN=")) { + fprintf(stderr, "Invalid public key identifier. You must specify both " + "UN and HN\n"); + return FALSE; + } + rng = silc_rng_alloc(); silc_rng_init(rng); silc_rng_global_init(rng); @@ -202,12 +208,14 @@ New pair of keys will be created. Please, answer to following questions.\n\ return FALSE; /* Save public key into file */ - silc_pkcs_save_public_key(pkfile, public_key, SILC_PKCS_FILE_BASE64); + if (!silc_pkcs_save_public_key(pkfile, public_key, SILC_PKCS_FILE_BASE64)) + return FALSE; /* Save private key into file */ - silc_pkcs_save_private_key(prvfile, private_key, - (const unsigned char *)pass, strlen(pass), - SILC_PKCS_FILE_BIN, rng); + if (!silc_pkcs_save_private_key(prvfile, private_key, + (const unsigned char *)pass, strlen(pass), + SILC_PKCS_FILE_BIN, rng)) + return FALSE; if (return_public_key) *return_public_key = public_key; @@ -265,6 +273,8 @@ SilcBool silc_load_key_pair(const char *pub_filename, if (!silc_pkcs_load_private_key(prv_filename, (const unsigned char *)pass, strlen(pass), return_private_key)) { + silc_pkcs_public_key_free(*return_public_key); + *return_public_key = NULL; memset(pass, 0, strlen(pass)); silc_free(pass); return FALSE;