Network Working Group                                        D. McDonald
INTERNET-DRAFT                                                       NRL
draft-mcdonald-readable-keys-00.txt                       20 August 1994

              A Convention for Human-Readable 128-bit Keys

Status of this Memo

   Internet Drafts are working documents of the Internet Engineering
   Task Force (IETF), its Areas, and its Working Groups.  Note that
   other groups may also distribute working documents as Internet

   Internet Drafts are draft documents valid for a maximum of six
   months.  This Internet Draft expires on February 20, 1995.  Internet
   Drafts may be updated, replaced, or obsoleted by other documents at
   any time. It is not appropriate to use Internet Drafts as reference
   material or to cite them other than as a "working draft" or "work in

   Please check the I-D abstract listing contained in each Internet
   Draft directory to learn the current status of this or any other
   Internet Draft.

   Distribution of this memo is unlimited.


   The Internet community has begun to address matters of security.
   Recent standards, including version 2 of SNMP [GM93], and version 6
   of IP [Atk94] have explicit requirements for an authentication
   mechanism.  Both require used of a keyed message-digest algorithm,
   MD5 [Riv92].  Both require a key size of 128-bits.  A 128-bit key,
   while sufficiently strong, is hard for most people to read, remember,
   and type in.

A Solution Already Exists

   The S/Key(tm) one-time password system [Hal94] uses MD4 (and now MD5,
   as well) to compute one-time passwords.  It takes the 128-bit result
   of MD4 and collapses it to a 64-bit result.  Despite the size
   reduction, 64-bit one-time passwords are still difficult for ordinary
   people to remember and enter.  The authors of S/Key devised a system
   to make the 64-bit one-time password easy for people to enter.

   Their idea was to transform the password into a string of small
   English words.  English words are significantly easier for people to

McDonald                                                        [Page 1]

INTERNET-DRAFT        Human-Readable 128-bit Keys         20 August 1994

   both remember and type.  The authors of S/Key started with a
   dictionary of 2048 English words, ranging in length from one to four
   characters.  The space covered by a 64-bit key (2^64) could be
   covered by six words from this dictionary (2^66) with room remaining
   for parity.  For example, an S/Key one-time password of hex value:

                            EB33 F77E E73D 4053

   would become the following six English words:

                       TIDE ITCH SLOW REIN RULE MOT

The Proposal

   The code (see Appendix A) which S/Key uses to convert 64-bit numbers
   to six English words contains two primitives which perform
   conversions either way.  The primitive btoe(char *engout,char *c)
   takes a 64-bit quantity referenced by c and places English words in
   the string referenced by engout.  The primitive etob(char *out,char
   *e) performs the opposite with an input string of English words
   referenced by e, and by placing the 64-bit result into the buffer
   referenced by out.

   The aforementioned primitives can be applied to both halves of a
   128-bit key, or both halves of a string of twelve English words.  Two
   new primitives (see Appendix B), key2eng(char *engout,char *key) and
   eng2key(char *keyout,char *eng) serve as wrappers which call the
   S/Key primitives twice, once for each half of the 128-bit key or
   string of twelve words.

   For example, the 128-bit key of:

                  CCAC 2AED 5910 56BE 4F90 FD44 1C53 4766

   would become


   Likewise, a user should be able to type in


   as a key, and the machine should make the translation to:

                  EFF8 1F9B FBC6 5350 920C DD74 16DE 8009

   If this proposal is to work, it is critical that the dictionary of
   English words does not change with different implementations.  A

McDonald                                                        [Page 2]

INTERNET-DRAFT        Human-Readable 128-bit Keys         20 August 1994

   freely redistributable reference implementation is given in
   Appendices A and B.

Security Considerations

   This document recommends a method of representing 128-bit keys using
   strings of English words.  Since the strings of English words are
   easy to remember, people may potentially construct easy-to-guess
   strings of English words.  With easy-to-guess strings comes the
   possibility of a sentential equivalent of a dictionary attack.  In
   order to maximize the strength of any authentication mechanism that
   uses 128-bit keys, the keys must be sufficiently obscure.  In
   particular, people should avoid the temptation to devise sentences.


   [Atk94]  Atkinson, Randall, "IPv6 Authentication Header", Internet-
   Draft, August 1994.

   [GM93]  Galvin, J. and McCloghrie, K., "Security Protocols for
   version 2 of the Simple Network Management Protocol (SNMPv2)",
   RFC1446, Internet Architecture Board, April 1993.

   [Hal94]  Haller, Neil M., "The S/Key(tm) One-Time Password System",
   Proceedings of the Symposium on Network & Distributed Systems
   Security, Internet Society, San Diego, February 1994.

   [Riv92]  Rivest, R., "The MD5 Message-Digest Algorithm", RFC1321,
   Internet Architecture Board, April 1992.

Author's Address

   Daniel L. McDonald
   United States Naval Research Laboratory
   Code 5544
   4555 Overlook Ave. SW
   Washington, DC 20375

   Phone:  (202) 404-7122


McDonald                                                        [Page 3]

INTERNET-DRAFT        Human-Readable 128-bit Keys         20 August 1994

Appendix A - Source for S/Key 8-bytes to/from Words Routines (put.c)

/* This code originally appeared in the source for S/Key, available in the
 * directory
 * It has been modified only to remove explicit S/Key references.

#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <ctype.h>

#ifdef __STDC__
#define __ARGS(x) x
#define __ARGS(x) ()

static unsigned long extract __ARGS((char *s,int start,int length));
static void standard __ARGS((char *word));
static void insert __ARGS((char *s, int x, int start, int length));
static int wsrch __ARGS((char *w,int low,int high));

/* Dictionary for integer-word translations */
char Wp[2048][4] = {
"A", "ABE", "ACE", "ACT", "AD", "ADA", "ADD", "AGO", "AID", "AIM", "AIR",
"ALL", "ALP", "AM", "AMY", "AN", "ANA", "AND", "ANN", "ANT", "ANY", "APE",
"APS", "APT", "ARC", "ARE", "ARK", "ARM", "ART", "AS", "ASH", "ASK", "AT",
"ATE", "AUG", "AUK", "AVE", "AWE", "AWK", "AWL", "AWN", "AX", "AYE", "BAD",
"BAG", "BAH", "BAM", "BAN", "BAR", "BAT", "BAY", "BE", "BED", "BEE", "BEG",
"BEN", "BET", "BEY", "BIB", "BID", "BIG", "BIN", "BIT", "BOB", "BOG", "BON",
"BOO", "BOP", "BOW", "BOY", "BUB", "BUD", "BUG", "BUM", "BUN", "BUS", "BUT",
"BUY", "BY", "BYE", "CAB", "CAL", "CAM", "CAN", "CAP", "CAR", "CAT", "CAW",
"COD", "COG", "COL", "CON", "COO", "COP", "COT", "COW", "COY", "CRY", "CUB",
"CUE", "CUP", "CUR", "CUT", "DAB", "DAD", "DAM", "DAN", "DAR", "DAY", "DEE",
"DEL", "DEN", "DES", "DEW", "DID", "DIE", "DIG", "DIN", "DIP", "DO", "DOE",
"DOG", "DON", "DOT", "DOW", "DRY", "DUB", "DUD", "DUE", "DUG", "DUN", "EAR",
"EAT", "ED", "EEL", "EGG", "EGO", "ELI", "ELK", "ELM", "ELY", "EM", "END",
"EST", "ETC", "EVA", "EVE", "EWE", "EYE", "FAD", "FAN", "FAR", "FAT", "FAY",
"FED", "FEE", "FEW", "FIB", "FIG", "FIN", "FIR", "FIT", "FLO", "FLY", "FOE",
"FOG", "FOR", "FRY", "FUM", "FUN", "FUR", "GAB", "GAD", "GAG", "GAL", "GAM",
"GAP", "GAS", "GAY", "GEE", "GEL", "GEM", "GET", "GIG", "GIL", "GIN", "GO",
"GOT", "GUM", "GUN", "GUS", "GUT", "GUY", "GYM", "GYP", "HA", "HAD", "HAL",
"HAM", "HAN", "HAP", "HAS", "HAT", "HAW", "HAY", "HE", "HEM", "HEN", "HER",
"HEW", "HEY", "HI", "HID", "HIM", "HIP", "HIS", "HIT", "HO", "HOB", "HOC",
"HOE", "HOG", "HOP", "HOT", "HOW", "HUB", "HUE", "HUG", "HUH", "HUM", "HUT",

McDonald                                                        [Page 4]

INTERNET-DRAFT        Human-Readable 128-bit Keys         20 August 1994

"I", "ICY", "IDA", "IF", "IKE", "ILL", "INK", "INN", "IO", "ION", "IQ", "IRA",
"IRE", "IRK", "IS", "IT", "ITS", "IVY", "JAB", "JAG", "JAM", "JAN", "JAR",
"JAW", "JAY", "JET", "JIG", "JIM", "JO", "JOB", "JOE", "JOG", "JOT", "JOY",
"JUG", "JUT", "KAY", "KEG", "KEN", "KEY", "KID", "KIM", "KIN", "KIT", "LA",
"LAB", "LAC", "LAD", "LAG", "LAM", "LAP", "LAW", "LAY", "LEA", "LED", "LEE",
"LEG", "LEN", "LEO", "LET", "LEW", "LID", "LIE", "LIN", "LIP", "LIT", "LO",
"LOB", "LOG", "LOP", "LOS", "LOT", "LOU", "LOW", "LOY", "LUG", "LYE", "MA",
"MAC", "MAD", "MAE", "MAN", "MAO", "MAP", "MAT", "MAW", "MAY", "ME", "MEG",
"MEL", "MEN", "MET", "MEW", "MID", "MIN", "MIT", "MOB", "MOD", "MOE", "MOO",
"MOP", "MOS", "MOT", "MOW", "MUD", "MUG", "MUM", "MY", "NAB", "NAG", "NAN",
"NAP", "NAT", "NAY", "NE", "NED", "NEE", "NET", "NEW", "NIB", "NIL", "NIP",
"NIT", "NO", "NOB", "NOD", "NON", "NOR", "NOT", "NOV", "NOW", "NU", "NUN",
"NUT", "O", "OAF", "OAK", "OAR", "OAT", "ODD", "ODE", "OF", "OFF", "OFT",
"OH", "OIL", "OK", "OLD", "ON", "ONE", "OR", "ORB", "ORE", "ORR", "OS", "OTT",
"OUR", "OUT", "OVA", "OW", "OWE", "OWL", "OWN", "OX", "PA", "PAD", "PAL",
"PAM", "PAN", "PAP", "PAR", "PAT", "PAW", "PAY", "PEA", "PEG", "PEN", "PEP",
"PER", "PET", "PEW", "PHI", "PI", "PIE", "PIN", "PIT", "PLY", "PO", "POD",
"POE", "POP", "POT", "POW", "PRO", "PRY", "PUB", "PUG", "PUN", "PUP", "PUT",
"QUO", "RAG", "RAM", "RAN", "RAP", "RAT", "RAW", "RAY", "REB", "RED", "REP",
"RET", "RIB", "RID", "RIG", "RIM", "RIO", "RIP", "ROB", "ROD", "ROE", "RON",
"ROT", "ROW", "ROY", "RUB", "RUE", "RUG", "RUM", "RUN", "RYE", "SAC", "SAD",
"SAG", "SAL", "SAM", "SAN", "SAP", "SAT", "SAW", "SAY", "SEA", "SEC", "SEE",
"SEN", "SET", "SEW", "SHE", "SHY", "SIN", "SIP", "SIR", "SIS", "SIT", "SKI",
"SKY", "SLY", "SO", "SOB", "SOD", "SON", "SOP", "SOW", "SOY", "SPA", "SPY",
"SUB", "SUD", "SUE", "SUM", "SUN", "SUP", "TAB", "TAD", "TAG", "TAN", "TAP",
"TAR", "TEA", "TED", "TEE", "TEN", "THE", "THY", "TIC", "TIE", "TIM", "TIN",
"TIP", "TO", "TOE", "TOG", "TOM", "TON", "TOO", "TOP", "TOW", "TOY", "TRY",
"TUB", "TUG", "TUM", "TUN", "TWO", "UN", "UP", "US", "USE", "VAN", "VAT",
"VET", "VIE", "WAD", "WAG", "WAR", "WAS", "WAY", "WE", "WEB", "WED", "WEE",
"WET", "WHO", "WHY", "WIN", "WIT", "WOK", "WON", "WOO", "WOW", "WRY", "WU",
"YAM", "YAP", "YAW", "YE", "YEA", "YES", "YET", "YOU", "ABED", "ABEL", "ABET",

McDonald                                                        [Page 5]

INTERNET-DRAFT        Human-Readable 128-bit Keys         20 August 1994


McDonald                                                        [Page 6]

INTERNET-DRAFT        Human-Readable 128-bit Keys         20 August 1994


McDonald                                                        [Page 7]

INTERNET-DRAFT        Human-Readable 128-bit Keys         20 August 1994


McDonald                                                        [Page 8]

INTERNET-DRAFT        Human-Readable 128-bit Keys         20 August 1994


/* Encode 8 bytes in 'c' as a string of English words.
 * Returns a pointer to a static buffer
char *
char *c, *engout;
        char cp[9];     /* add in room for the parity 2 bits*/
        int p,i ;

        engout[0] = '\0';
        memcpy(cp, c,8);
        /* compute parity */
        for(p = 0,i = 0; i < 64;i += 2)
                p += extract(cp,i,2);

        cp[8] = (char)p << 6;
        strncat(engout,&Wp[extract(cp, 0,11)][0],4);
        strcat(engout," ");
        strcat(engout," ");
        strcat(engout," ");
        strcat(engout," ");
        strcat(engout," ");
#ifdef  notdef
        printf("engout is %s\n\r",engout);

/* convert English to binary
 * returns 1 OK - all good words and parity is OK
 *         0 word not in data base
 *        -1 badly formed in put ie > 4 char word
 *        -2 words OK but parity is wrong
etob(out, e)
char *out;

McDonald                                                        [Page 9]

INTERNET-DRAFT        Human-Readable 128-bit Keys         20 August 1994

char *e;
        char *word;
        int i, p, v,l, low,high;
        char b[9];
        char input[36];

        if(e == NULL)
                return -1;

        memset(b, 0, sizeof(b));
        memset(out, 0, 8);
                if((word = strtok(i == 0 ? input : NULL," ")) == NULL)
                        return -1;
                l = strlen(word);
                if(l > 4 || l < 1){
                        return -1;
                } else if(l < 4){
                        low = 0;
                        high = 570;
                } else {
                        low = 571;
                        high = 2047;
                if( (v = wsrch(word,low,high)) < 0 )
                        return 0;

        /* now check the parity of what we got */
        for(p = 0, i = 0; i < 64; i +=2)
                p += extract(b, i, 2);

        if( (p & 3) != extract(b, 64,2) )
                return -2;


        return 1;
/* Display 8 bytes as a series of 16-bit hex digits */
char *
char *out;
char *s;

McDonald                                                       [Page 10]

INTERNET-DRAFT        Human-Readable 128-bit Keys         20 August 1994

        sprintf(out,"%02X%02X %02X%02X %02X%02X %02X%02X",
                s[0] & 0xff,s[1] & 0xff,s[2] & 0xff,
                s[3] & 0xff,s[4] & 0xff,s[5] & 0xff,
                s[6] & 0xff,s[7] & 0xff);
        return out;
#ifdef  notdef
/* Encode 8 bytes in 'cp' as stream of ascii letters.
 * Provided as a possible alternative to btoe()
char *
char *cp;
        int i;
        static char out[31];

        /* code out put by characters 6 bits each added to 0x21 (!)*/
        for(i=0;i <= 10;i++){
                /* last one is only 4 bits not 6*/
                out[i] = '!'+ extract(cp,6*i,i >= 10 ? 4:6);
        out[i] = '\0';

/* Internal subroutines for word encoding/decoding */

/* Dictionary binary search */
static int
char *w;
int low, high;
        int i,j;

                i = (low + high)/2;
                if((j = strncmp(w,Wp[i],4)) == 0)
                        return i;       /* Found it */
                if(high == low+1){
                        /* Avoid effects of integer truncation in /2 */
                        if(strncmp(w,Wp[high],4) == 0)
                                return high;
                                return -1;

McDonald                                                       [Page 11]

INTERNET-DRAFT        Human-Readable 128-bit Keys         20 August 1994

                if(low >= high)
                        return -1;      /* I don't *think* this can happen...*/
                if(j < 0)
                        high = i;       /* Search lower half */
                        low = i;        /* Search upper half */
static void
insert(s, x, start, length)
char *s;
int x;
int  start, length;
        unsigned char cl;
        unsigned char cc;
        unsigned char cr;
        unsigned long y;
        int shift;

        assert(length <= 11);
        assert(start >= 0);
        assert(length >= 0);
        assert(start +length <= 66);

        shift = ((8  -(( start + length) % 8))%8);
        y = (long) x << shift;
        cl = (y >> 16) & 0xff;
        cc = (y >> 8) & 0xff;
        cr = y & 0xff;
        if(shift + length > 16){
                s[start /8] |= cl;
                s[start/8 +1] |= cc;
                s[start/8 +2] |= cr;
        } else if(shift +length > 8){
                s[start/8] |= cc;
                s[start/8 + 1] |= cr;
        } else {
                s[start/8] |= cr;

static void
register char *word;

McDonald                                                       [Page 12]

INTERNET-DRAFT        Human-Readable 128-bit Keys         20 August 1994

                        *word = toupper(*word);
                if(*word == '1')
                        *word = 'L';
                if(*word == '0')
                        *word = 'O';
                if(*word == '5')
                        *word = 'S';

/* Extract 'length' bits from the char array 's' starting with bit 'start' */
static unsigned long
extract(s, start, length)
char *s;
int start, length;
        unsigned char cl;
        unsigned char cc;
        unsigned char cr;
        unsigned long x;

        assert(length <= 11);
        assert(start >= 0);
        assert(length >= 0);
        assert(start +length <= 66);

        cl = s[start/8];
        cc = s[start/8 +1];
        cr = s[start/8 +2];
        x = ((long)(cl<<8 | cc) <<8  | cr) ;
        x = x >> (24 - (length + (start %8)));
        x =( x & (0xffff >> (16-length) )   );

McDonald                                                       [Page 13]

INTERNET-DRAFT        Human-Readable 128-bit Keys         20 August 1994

Appendix B - Source for 128-bit key to/from English words (convert.c)

/* convert.c  --  Wrapper to S/Key binary-to-English routines.
                  Daniel L. McDonald  --  U. S. Naval Research Laboratory. */

#include <string.h>

/* eng2key() assumes words must be separated by spaces only.

   eng2key() returns

   1 if succeeded
   0 if word not in dictionary
   -1 if badly formed string
   -2 if words are okay but parity is wrong.
   (see etob() in S/Key)

int eng2key(keyout,eng)
char *keyout,*eng;
  int rc=0,state=1;
  char *eng2;

  /* Find pointer to word 7. */

  for (eng2 = eng; rc<7 && (*(++eng2) != '\0'); )
    if (*eng2 != ' ')
        rc += state;
        state = 0;
    else state=1;

  if ( (rc = etob(keyout,eng)) != 1)
    return rc;

  rc = etob(keyout+8,eng2);

  return rc;

/* key2eng() assumes string referenced by engout has at least 60 characters
   (4*12 + 11 spaces + '\0') of space.

   key2eng() returns pointer to engout.


McDonald                                                       [Page 14]

INTERNET-DRAFT        Human-Readable 128-bit Keys         20 August 1994

char *key2eng(engout,key)
char *engout,*key;
  strcat(engout," ");

McDonald                                                       [Page 15]