From 8beb77db2bede9e31d4343b4c8a27e5b9a2fa6b1 Mon Sep 17 00:00:00 2001 From: Pekka Riikonen Date: Tue, 6 Nov 2001 19:58:09 +0000 Subject: [PATCH] updates. --- CHANGES | 13 ++++ .../irssi/src/fe-common/silc/module-formats.c | 3 +- .../irssi/src/fe-common/silc/module-formats.h | 1 + apps/irssi/src/silc/core/client_ops.c | 11 +++- apps/irssi/src/silc/core/clientutil.c | 4 +- lib/silccrypt/silchash.c | 65 +++++++++++++++++++ lib/silccrypt/silchash.h | 2 + 7 files changed, 96 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index 810b8b1e..fe6c1481 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,16 @@ +Tue Nov 6 21:31:54 EET 2001 Pekka Riikonen + + * Added silc_hash_babbleprint to create a Bubble Babble + Encoded fingerprint. The encoding is developed by Antti + Huima (draft-huima-babble-01.txt), and it creates human + readable strings out of binary data. Affected file + lib/silccrypt/silchash.[ch]. + + * Print the babble print now in addition of fingerprint as well + in Irssi SILC client. Affected files are + irssi/src/fe-common/silc/module-formats.[ch], + irssi/src/fe-common/silc/core/client_ops.c. + Sun Nov 4 23:37:28 EET 2001 Pekka Riikonen * Fixed a security problem found in SKE. The initiator's diff --git a/apps/irssi/src/fe-common/silc/module-formats.c b/apps/irssi/src/fe-common/silc/module-formats.c index 36d8c356..d2c62f23 100644 --- a/apps/irssi/src/fe-common/silc/module-formats.c +++ b/apps/irssi/src/fe-common/silc/module-formats.c @@ -79,7 +79,8 @@ FORMAT_REC fecommon_silc_formats[] = { { "key_agreement_failure", "Key agreement failed with {nick $0}", 1, { 0 } }, { "key_agreement_timeout", "Timeout during key agreement. The key agreement was not performed with {nick $0}", 1, { 0 } }, { "pubkey_received", "Received {hilight $0} public key", 1, { 0 } }, - { "pubkey_fingerprint", "Fingerprint for the {hilight $0} key is %: $1", 2, { 0, 0 } }, + { "pubkey_fingerprint", "Fingerprint and babbleprint for the {hilight $0} key are %: $1", 2, { 0, 0 } }, + { "pubkey_babbleprint", " $0", 1, { 0 } }, { "pubkey_unsupported", "We don't support {hilight $0} public key type {hilight $1}", 2, { 0, 0 } }, { "pubkey_discard", "Will not accept the {hilight $0} key", 1, { 0 } }, { "pubkey_accept", "Would you like to accept the key (y/n)? ", 0 }, diff --git a/apps/irssi/src/fe-common/silc/module-formats.h b/apps/irssi/src/fe-common/silc/module-formats.h index 361e1b71..c1d94a34 100644 --- a/apps/irssi/src/fe-common/silc/module-formats.h +++ b/apps/irssi/src/fe-common/silc/module-formats.h @@ -75,6 +75,7 @@ enum { SILCTXT_KEY_AGREEMENT_TIMEOUT, SILCTXT_PUBKEY_RECEIVED, SILCTXT_PUBKEY_FINGERPRINT, + SILCTXT_PUBKEY_BABBLEPRINT, SILCTXT_PUBKEY_UNSUPPORTED, SILCTXT_PUBKEY_DISCARD, SILCTXT_PUBKEY_ACCEPT, diff --git a/apps/irssi/src/silc/core/client_ops.c b/apps/irssi/src/silc/core/client_ops.c index 59ecd372..a3af5d41 100644 --- a/apps/irssi/src/silc/core/client_ops.c +++ b/apps/irssi/src/silc/core/client_ops.c @@ -863,7 +863,7 @@ silc_verify_public_key_internal(SilcClient client, SilcClientConnection conn, SilcVerifyPublicKey completion, void *context) { int i; - char file[256], filename[256], *fingerprint, *format; + char file[256], filename[256], *fingerprint, *babbleprint, *format; struct passwd *pw; struct stat st; char *entity = ((conn_type == SILC_SOCKET_TYPE_SERVER || @@ -911,6 +911,7 @@ silc_verify_public_key_internal(SilcClient client, SilcClientConnection conn, /* Take fingerprint of the public key */ fingerprint = silc_hash_fingerprint(NULL, pk, pk_len); + babbleprint = silc_hash_babbleprint(NULL, pk, pk_len); verify = silc_calloc(1, sizeof(*verify)); verify->client = client; @@ -932,6 +933,8 @@ silc_verify_public_key_internal(SilcClient client, SilcClientConnection conn, SILCTXT_PUBKEY_RECEIVED, entity); printformat_module("fe-common/silc", NULL, NULL, MSGLEVEL_CRAP, SILCTXT_PUBKEY_FINGERPRINT, entity, fingerprint); + printformat_module("fe-common/silc", NULL, NULL, MSGLEVEL_CRAP, + SILCTXT_PUBKEY_BABBLEPRINT, babbleprint); format = format_get_text("fe-common/silc", NULL, NULL, NULL, SILCTXT_PUBKEY_ACCEPT); keyboard_entry_redirect((SIGNAL_FUNC)verify_public_key_completion, @@ -954,6 +957,8 @@ silc_verify_public_key_internal(SilcClient client, SilcClientConnection conn, SILCTXT_PUBKEY_RECEIVED, entity); printformat_module("fe-common/silc", NULL, NULL, MSGLEVEL_CRAP, SILCTXT_PUBKEY_FINGERPRINT, entity, fingerprint); + printformat_module("fe-common/silc", NULL, NULL, MSGLEVEL_CRAP, + SILCTXT_PUBKEY_BABBLEPRINT, babbleprint); printformat_module("fe-common/silc", NULL, NULL, MSGLEVEL_CRAP, SILCTXT_PUBKEY_COULD_NOT_LOAD, entity); format = format_get_text("fe-common/silc", NULL, NULL, NULL, @@ -972,6 +977,8 @@ silc_verify_public_key_internal(SilcClient client, SilcClientConnection conn, SILCTXT_PUBKEY_RECEIVED, entity); printformat_module("fe-common/silc", NULL, NULL, MSGLEVEL_CRAP, SILCTXT_PUBKEY_FINGERPRINT, entity, fingerprint); + printformat_module("fe-common/silc", NULL, NULL, MSGLEVEL_CRAP, + SILCTXT_PUBKEY_BABBLEPRINT, babbleprint); printformat_module("fe-common/silc", NULL, NULL, MSGLEVEL_CRAP, SILCTXT_PUBKEY_MALFORMED, entity); format = format_get_text("fe-common/silc", NULL, NULL, NULL, @@ -989,6 +996,8 @@ silc_verify_public_key_internal(SilcClient client, SilcClientConnection conn, SILCTXT_PUBKEY_RECEIVED, entity); printformat_module("fe-common/silc", NULL, NULL, MSGLEVEL_CRAP, SILCTXT_PUBKEY_FINGERPRINT, entity, fingerprint); + printformat_module("fe-common/silc", NULL, NULL, MSGLEVEL_CRAP, + SILCTXT_PUBKEY_BABBLEPRINT, babbleprint); printformat_module("fe-common/silc", NULL, NULL, MSGLEVEL_CRAP, SILCTXT_PUBKEY_NO_MATCH, entity); printformat_module("fe-common/silc", NULL, NULL, MSGLEVEL_CRAP, diff --git a/apps/irssi/src/silc/core/clientutil.c b/apps/irssi/src/silc/core/clientutil.c index 6b19cc6f..622fb762 100644 --- a/apps/irssi/src/silc/core/clientutil.c +++ b/apps/irssi/src/silc/core/clientutil.c @@ -550,7 +550,7 @@ int silc_client_show_key(char *keyfile) { SilcPublicKey public_key; SilcPublicKeyIdentifier ident; - char *fingerprint; + char *fingerprint, *babbleprint; unsigned char *pk; uint32 pk_len; SilcPKCS pkcs; @@ -568,6 +568,7 @@ int silc_client_show_key(char *keyfile) pk = silc_pkcs_public_key_encode(public_key, &pk_len); fingerprint = silc_hash_fingerprint(NULL, pk, pk_len); + babbleprint = silc_hash_babbleprint(NULL, pk, pk_len); if (silc_pkcs_alloc(public_key->name, &pkcs)) { key_len = silc_pkcs_public_key_set(pkcs, public_key); @@ -591,6 +592,7 @@ int silc_client_show_key(char *keyfile) if (ident->country) printf("Country : %s\n", ident->country); printf("Fingerprint (SHA1) : %s\n", fingerprint); + printf("Babbleprint (SHA1) : %s\n", babbleprint); fflush(stdout); diff --git a/lib/silccrypt/silchash.c b/lib/silccrypt/silchash.c index 819a2fab..4d0d2706 100644 --- a/lib/silccrypt/silchash.c +++ b/lib/silccrypt/silchash.c @@ -238,3 +238,68 @@ char *silc_hash_fingerprint(SilcHash hash, const unsigned char *data, return strdup(fingerprint); } + +static const char vo[]= "aeiouy"; +static const char co[]= "bcdfghklmnprstvzx"; + +/* Creates a babbleprint (Bubble Babble Encoding, developed by Antti + Huima (draft-huima-babble-01.txt)), by first computing real fingerprint + using `hash' or if NULL, then using SHA1, and then encoding the + fingerprint to the babbleprint. */ + +char *silc_hash_babbleprint(SilcHash hash, const unsigned char *data, + uint32 data_len) +{ + char *babbleprint; + unsigned char hval[32]; + unsigned int a, b, c, d, e, check; + int i, k, out_len; + + if (!hash) + silc_hash_alloc("sha1", &hash); + + /* Take fingerprint */ + silc_hash_make(hash, data, data_len, hval); + + /* Encode babbleprint */ + out_len = (((hash->hash->hash_len + 1) / 2) + 1) * 6; + babbleprint = silc_calloc(out_len, sizeof(*babbleprint)); + babbleprint[0] = co[16]; + + check = 1; + for (i = 0, k = 1; i < hash->hash->hash_len - 1; i += 2, k += 6) { + a = (((hval[i] >> 6) & 3) + check) % 6; + b = (hval[i] >> 2) & 15; + c = ((hval[i] & 3) + (check / 6)) % 6; + d = (hval[i + 1] >> 4) & 15; + e = hval[i + 1] & 15; + + check = ((check * 5) + (hval[i] * 7) + hval[i + 1]) % 36; + + babbleprint[k + 0] = vo[a]; + babbleprint[k + 1] = co[b]; + babbleprint[k + 2] = vo[c]; + babbleprint[k + 3] = co[d]; + babbleprint[k + 4] = '-'; + babbleprint[k + 5] = co[e]; + } + + if ((hash->hash->hash_len % 2) != 0) { + a = (((hval[i] >> 6) & 3) + check) % 6; + b = (hval[i] >> 2) & 15; + c = ((hval[i] & 3) + (check / 6)) % 6; + babbleprint[k + 0] = vo[a]; + babbleprint[k + 1] = co[b]; + babbleprint[k + 2] = vo[c]; + } else { + a = check % 6; + b = 16; + c = check / 6; + babbleprint[k + 0] = vo[a]; + babbleprint[k + 1] = co[b]; + babbleprint[k + 2] = vo[c]; + } + babbleprint[k + 3] = co[16]; + + return babbleprint; +} diff --git a/lib/silccrypt/silchash.h b/lib/silccrypt/silchash.h index 1c2317e8..8feb8e34 100644 --- a/lib/silccrypt/silchash.h +++ b/lib/silccrypt/silchash.h @@ -96,5 +96,7 @@ void silc_hash_make(SilcHash hash, const unsigned char *data, uint32 len, unsigned char *return_hash); char *silc_hash_fingerprint(SilcHash hash, const unsigned char *data, uint32 data_len); +char *silc_hash_babbleprint(SilcHash hash, const unsigned char *data, + uint32 data_len); #endif -- 2.24.0