return num;
}
-/* Returns the username of the user. If the global variable LOGNAME
- does not exists we will get the name from the password file. */
-
-char *silc_get_username()
-{
- char *logname = NULL;
-
- logname = strdup(getenv("LOGNAME"));
- if (!logname) {
- logname = getlogin();
- if (!logname) {
- struct passwd *pw;
-
- pw = getpwuid(getuid());
- if (!pw) {
- fprintf(stderr, "silc_get_username: %s\n", strerror(errno));
- return NULL;
- }
-
- logname = strdup(pw->pw_name);
- }
- }
-
- return logname;
-}
-
-/* Returns the real name of ther user. */
-
-char *silc_get_real_name()
-{
- char *realname = NULL;
- struct passwd *pw;
-
- pw = getpwuid(getuid());
- if (!pw) {
- fprintf(stderr, "silc_get_username: %s\n", strerror(errno));
- return NULL;
- }
-
- if (strchr(pw->pw_gecos, ','))
- *strchr(pw->pw_gecos, ',') = 0;
-
- realname = strdup(pw->pw_gecos);
-
- return realname;
-}
-
/* Returns time til next minute changes. Used to update the clock when
needed. */
void silc_client_list_ciphers()
{
-
+ char *ciphers = silc_cipher_get_supported();
+ fprintf(stdout, "%s\n", ciphers);
+ silc_free(ciphers);
}
/* Lists supported (builtin) hash functions */
void silc_client_list_hash_funcs()
{
-
+ char *hash = silc_hash_get_supported();
+ fprintf(stdout, "%s\n", hash);
+ silc_free(hash);
}
/* Lists supported PKCS algorithms */
void silc_client_list_pkcs()
{
-
+ char *pkcs = silc_pkcs_get_supported();
+ fprintf(stdout, "%s\n", pkcs);
+ silc_free(pkcs);
}
/* Displays input prompt on command line and takes input data from user */
SilcPrivateKey prv_key;
SilcRng rng;
unsigned char *key;
- unsigned int key_len;
+ SilcUInt32 key_len;
char line[256];
char *pkfile = NULL, *prvfile = NULL;
}
if (!silc_pkcs_is_supported(pkcs_name)) {
- fprintf(stderr, "Unsupported PKCS `%s'", pkcs_name);
+ fprintf(stderr, "Unknown PKCS `%s'", pkcs_name);
return FALSE;
}
if (ret_prv_key)
*ret_prv_key = prv_key;
- printf("Public key has been save into `%s'.\n", pkfile);
+ printf("Public key has been saved into `%s'.\n", pkfile);
printf("Private key has been saved into `%s'.\n", prvfile);
printf("Press <Enter> to continue...\n");
getchar();
return TRUE;
}
+
+/* Dumps the public key on screen. Used from the command line option. */
+
+int silc_client_show_key(char *keyfile)
+{
+ SilcPublicKey public_key;
+ SilcPublicKeyIdentifier ident;
+ char *fingerprint;
+ unsigned char *pk;
+ SilcUInt32 pk_len;
+ SilcPKCS pkcs;
+ int key_len = 0;
+
+ if (silc_pkcs_load_public_key(keyfile, &public_key,
+ SILC_PKCS_FILE_PEM) == FALSE)
+ if (silc_pkcs_load_public_key(keyfile, &public_key,
+ SILC_PKCS_FILE_BIN) == FALSE) {
+ fprintf(stderr, "Could not load public key file `%s'\n", keyfile);
+ return FALSE;
+ }
+
+ ident = silc_pkcs_decode_identifier(public_key->identifier);
+
+ pk = silc_pkcs_public_key_encode(public_key, &pk_len);
+ fingerprint = silc_hash_fingerprint(NULL, pk, pk_len);
+
+ if (silc_pkcs_alloc(public_key->name, &pkcs)) {
+ key_len = silc_pkcs_public_key_set(pkcs, public_key);
+ silc_pkcs_free(pkcs);
+ }
+
+ printf("Public key file : %s\n", keyfile);
+ printf("Algorithm : %s\n", public_key->name);
+ if (key_len)
+ printf("Key length (bits) : %d\n", key_len);
+ if (ident->realname)
+ printf("Real name : %s\n", ident->realname);
+ if (ident->username)
+ printf("Username : %s\n", ident->username);
+ if (ident->host)
+ printf("Hostname : %s\n", ident->host);
+ if (ident->email)
+ printf("Email : %s\n", ident->email);
+ if (ident->org)
+ printf("Organization : %s\n", ident->org);
+ if (ident->country)
+ printf("Country : %s\n", ident->country);
+ printf("Fingerprint (SHA1) : %s\n", fingerprint);
+
+ fflush(stdout);
+
+ silc_free(fingerprint);
+ silc_free(pk);
+ silc_pkcs_public_key_free(public_key);
+ silc_pkcs_free_identifier(ident);
+
+ return TRUE;
+}