updates.
authorPekka Riikonen <priikone@silcnet.org>
Tue, 6 Nov 2001 19:58:09 +0000 (19:58 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Tue, 6 Nov 2001 19:58:09 +0000 (19:58 +0000)
CHANGES
apps/irssi/src/fe-common/silc/module-formats.c
apps/irssi/src/fe-common/silc/module-formats.h
apps/irssi/src/silc/core/client_ops.c
apps/irssi/src/silc/core/clientutil.c
lib/silccrypt/silchash.c
lib/silccrypt/silchash.h

diff --git a/CHANGES b/CHANGES
index 810b8b1e5554fe6d2f13987ef902686f612841a7..fe6c148167a237102afd52482f6bc882c27f6085 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,16 @@
+Tue Nov  6 21:31:54 EET 2001  Pekka Riikonen <priikone@silcnet.org>
+
+       * 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 <priikone@silcnet.org>
 
        * Fixed a security problem found in SKE.  The initiator's
index 36d8c356514eac48402eb6435a4a3e7eb3f94c91..d2c62f23e3f65cd18962bc6feece623f09181180 100644 (file)
@@ -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 },
index 361e1b7125d200dcba5a915ddf8a44496dfcb232..c1d94a34a9b3c0eedd43053348032dc89314f02c 100644 (file)
@@ -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,
index 59ecd37246bfcd0655885d7702456c23df1aa5c5..a3af5d415432661ea65adc3e11c25ecf7691b8c9 100644 (file)
@@ -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, 
index 6b19cc6f18e2a857e4592398e66562b886299a20..622fb762465da3ecc5ef2cba67152bb618b45e76 100644 (file)
@@ -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);
 
index 819a2fab377fdeadafa1d54fd7597f63d9df93db..4d0d27062d1f0485f4d5f81f5b0b677f2e2b2459 100644 (file)
@@ -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;
+}
index 1c2317e898f2b1d5d16bddb21a8715e27191ae11..8feb8e3402e4d7d0188ef3aabe27b0244b5d3252 100644 (file)
@@ -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