home *** CD-ROM | disk | FTP | other *** search
/ Unix System Administration Handbook 1997 October / usah_oct97.iso / rfc / 1100s / rfc1115.txt < prev    next >
Text File  |  1989-08-23  |  18KB  |  451 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7. Network Working Group                                            J. Linn
  8. Request for Comments:  1115                                          DEC
  9.                                                   IAB Privacy Task Force
  10.                                                              August 1989
  11.  
  12.  
  13.            Privacy Enhancement for Internet Electronic Mail:
  14.              Part III -- Algorithms, Modes, and Identifiers
  15.  
  16. STATUS OF THIS MEMO
  17.  
  18.    This RFC suggests a draft standard elective protocol for the Internet
  19.    community, and requests discussion and suggestions for improvement.
  20.    This RFC provides definitions, references, and citations for
  21.    algorithms, usage modes, and associated identifiers used in RFC-1113
  22.    and RFC-1114 in support of privacy-enhanced electronic mail.
  23.    Distribution of this memo is unlimited.
  24.  
  25. ACKNOWLEDGMENT
  26.  
  27.    This RFC is the outgrowth of a series of IAB Privacy Task Force
  28.    meetings and of internal working papers distributed for those
  29.    meetings.  I would like to thank the following Privacy Task Force
  30.    members and meeting guests for their comments and contributions at
  31.    the meetings which led to the preparation of this RFC: David
  32.    Balenson, Curt Barker, Jim Bidzos, Matt Bishop, Morrie Gasser, Russ
  33.    Housley, Steve Kent (chairman), Dan Nessett, Mike Padlipsky, Rob
  34.    Shirey, and Steve Wilbur.
  35.  
  36. Table of Contents
  37.  
  38.    1.  Executive Summary                                             2
  39.    2.  Symmetric Encryption Algorithms and Modes                     2
  40.    2.1.  DES Modes                                                   2
  41.    2.1.1.  DES in ECB mode (DES-ECB)                                 2
  42.    2.1.2.  DES in EDE mode (DES-EDE)                                 2
  43.    2.1.3.  DES in CBC mode (DES-CBC)                                 3
  44.    3.  Asymmetric Encryption Algorithms and Modes                    3
  45.    3.1.  RSA                                                         3
  46.    4.  Integrity Check Algorithms                                    3
  47.    4.1.  Message Authentication Code (MAC)                           4
  48.    4.2.  RSA-MD2 Message Digest Algorithm                            4
  49.    4.2.1.  Discussion                                                4
  50.    4.2.2.  Reference Implementation                                  5
  51.    NOTES                                                             7
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58. Linn                                                            [Page 1]
  59.  
  60. RFC 1115                Mail Privacy: Algorithms             August 1989
  61.  
  62.  
  63. 1.  Executive Summary
  64.  
  65.    This RFC provides definitions, references, and citations for algorithms,
  66.    usage modes, and associated identifiers used in RFC-1113 and RFC-1114
  67.    in support of privacy-enhanced electronic mail in the Internet
  68.    community.  As some parts of this material are cited by both RFC-1113
  69.    and RFC-1114, and as it is anticipated that some of the definitions
  70.    herein may be changed, added, or replaced without affecting the citing
  71.    RFCs, algorithm-specific material has been placed into this separate
  72.    RFC.  The text is organized into three primary sections; dealing with
  73.    symmetric encryption algorithms, asymmetric encryption algorithms, and
  74.    integrity check algorithms.
  75.  
  76. 2.  Symmetric Encryption Algorithms and Modes
  77.  
  78.    This section identifies alternative symmetric encryption algorithms
  79.    and modes which may be used to encrypt DEKs, MICs, and message text,
  80.    and assigns them character string identifiers to be incorporated in
  81.    encapsulated header fields to indicate the choice of algorithm
  82.    employed.  (Note: all alternatives presently defined in this category
  83.    correspond to different usage modes of the DEA-1 (DES) algorithm,
  84.    rather than to other algorithms per se.)
  85.  
  86. 2.1.  DES Modes
  87.  
  88.    The Block Cipher Algorithm DEA-1, defined in ANSI X3.92-1981 [3] may
  89.    be used for message text, DEKs, and MICs.  The DEA-1 is equivalent to
  90.    the Data Encryption Standard (DES), as defined in FIPS PUB 46 [4].
  91.    The ECB and CBC modes of operation of DEA-1 are defined in ISO IS 8372
  92.    [5].
  93.  
  94. 2.1.1.  DES in ECB mode (DES-ECB)
  95.  
  96.    The string "DES-ECB" indicates use of the DES algorithm in Electronic
  97.    Codebook (ECB) mode.  This algorithm/mode combination is used for DEK
  98.    and MIC encryption.
  99.  
  100. 2.1.2.  DES in EDE mode (DES-EDE)
  101.  
  102.    The string "DES-EDE" indicates use of the DES algorithm in
  103.    Encrypt-Decrypt-Encrypt (EDE) mode as defined by ANSI X9.17 [2] for
  104.    key encryption and decryption with pairs of 64-bit keys.  This
  105.    algorithm/mode combination is used for DEK and MIC encryption.
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114. Linn                                                            [Page 2]
  115.  
  116. RFC 1115                Mail Privacy: Algorithms             August 1989
  117.  
  118.  
  119. 2.1.3.  DES in CBC mode (DES-CBC)
  120.  
  121.    The string "DES-CBC" indicates use of the DES algorithm in Cipher
  122.    Block Chaining (CBC) mode.  This algorithm/mode combination is used
  123.    for message text encryption only.  The CBC mode definition in IS 8372
  124.    is equivalent to that provided in FIPS PUB 81 [6] and in ANSI X3.106-
  125.    1983 [7].
  126.  
  127. 3.  Asymmetric Encryption Algorithms and Modes
  128.  
  129.    This section identifies alternative asymmetric encryption algorithms and
  130.    modes which may be used to encrypt DEKs and MICs, and assigns them
  131.    character string identifiers to be incorporated in encapsulated
  132.    header fields to indicate the choice of algorithm employed.  (Note:
  133.    only one alternative is presently defined in this category.)
  134.  
  135. 3.1.  RSA
  136.  
  137.    The string "RSA" indicates use of the RSA public-key encryption
  138.    algorithm, as described in [8].  This algorithm is used for DEK and
  139.    MIC encryption, in the following fashion: the product n of a
  140.    individual's selected primes p and q is used as the modulus for the
  141.    RSA encryption algorithm, comprising, for our purposes, the
  142.    individual's public key.  A recipient's public key is used in
  143.    conjunction with an associated public exponent (either 3 or 1+2**16)
  144.    as identified in the recipient's certificate.
  145.  
  146.    When a MIC must be padded for RSA encryption, the MIC will be
  147.    right-justified and padded on the left with zeroes.  This is also
  148.    appropriate for padding of DEKs on singly-addressed messages, and for
  149.    padding of DEKs on multi-addressed messages if and only if an exponent
  150.    of 3 is used for no more than one recipient.  On multi-addressed
  151.    messages in which an exponent of 3 is used for more than one recipient,
  152.    it is recommended that a separate 64-bit pseudorandom quantity be
  153.    generated for each recipient, in the same manner in which IVs are
  154.    generated.  (Reference [9] discusses the rationale for this
  155.    recommendation.)  At least one copy of the pseudorandom quantity should
  156.    be included in the input to RSA encryption, placed to the left of the
  157.    DEK.
  158.  
  159. 4.  Integrity Check Algorithms
  160.  
  161.    This section identifies the alternative algorithms which may be used
  162.    to compute Message Integrity Check (MIC) and Certificate Integrity
  163.    Check (CIC) values, and assigns the algorithms character string
  164.    identifiers for use in encapsulated header fields and within
  165.    certificates to indicate the choice of algorithm employed.
  166.  
  167.  
  168.  
  169.  
  170. Linn                                                            [Page 3]
  171.  
  172. RFC 1115                Mail Privacy: Algorithms             August 1989
  173.  
  174.  
  175.    MIC algorithms which utilize DEA-1 cryptography are computed using a key
  176.    which is a variant of the DEK used for message text encryption.  The
  177.    variant is formed by modulo-2 addition of the hexadecimal quantity
  178.    F0F0F0F0F0F0F0F0 to the encryption DEK.
  179.  
  180.    For compatibility with this specification, a privacy-enhanced mail
  181.    implementation must be able to process both MAC (Section 2.1) and
  182.    RSA-MD2 (Section 2.2) MICs on incoming messages.  It is a sender option
  183.    whether MAC or RSA-MD2 is employed on an outbound message addressed to
  184.    only one recipient.  However, use of MAC is strongly discouraged for
  185.    messages sent to more than a single recipient.  The reason for this
  186.    recommendation is that the use of MAC on multi-addressed mail fails to
  187.    prevent other intended recipients from tampering with a message in a
  188.    manner which preserves the message's appearance as an authentic message
  189.    from the sender.  In other words, use of MAC on multi-addressed mail
  190.    provides source authentication at the granularity of membership in the
  191.    message's authorized address list (plus the sender) rather than at a
  192.    finer (and more desirable) granularity authenticating the individual
  193.    sender.
  194.  
  195. 4.1.  Message Authentication Code (MAC)
  196.  
  197.    A message authentication code (MAC), denoted by the string "MAC", is
  198.    computed using the DEA-1 algorithm in the fashion defined in FIPS PUB
  199.    113 [1].  This algorithm is used only as a MIC algorithm, not as a CIC
  200.    algorithm.
  201.  
  202.    As noted above, use of the MAC is not recommended for multicast
  203.    messages, as it does not preserve authentication and integrity among
  204.    individual recipients, i.e., it is not cryptographically strong enough
  205.    for this purpose.  The message's canonically encoded text is padded at
  206.    the end, per FIPS PUB 113, with zero-valued octets as needed in order to
  207.    form an integral number of 8-octet encryption quanta.  These padding
  208.    octets are inserted implicitly and are not transmitted with a message.
  209.    The result of a MAC computation is a single 64-bit value.
  210.  
  211. 4.2.  RSA-MD2 Message Digest Algorithm
  212.  
  213. 4.2.1.  Discussion
  214.  
  215.    The RSA-MD2 Message Digest Algorithm, denoted by the string "RSA-MD2",
  216.    is computed using an algorithm defined in this section.  It has been
  217.    provided by Ron Rivest of RSA Data Security, Incorporated for use in
  218.    support of privacy-enhanced electronic mail, free of licensing
  219.    restrictions.  This algorithm should be used as a MIC algorithm
  220.    whenever a message is addressed to multiple recipients.  It is also
  221.    the only algorithm currently defined for use as CIC.  While its
  222.    continued use as the standard CIC algorithm is anticipated, RSA-MD2
  223.  
  224.  
  225.  
  226. Linn                                                            [Page 4]
  227.  
  228. RFC 1115                Mail Privacy: Algorithms             August 1989
  229.  
  230.  
  231.    may be supplanted by later recommendations for MIC algorithm
  232.    selections.
  233.  
  234.    The RSA-MD2 message digest algorithm accepts as input a message of any
  235.    length and produces as output a 16-byte quantity.  The attached
  236.    reference implementation serves to define the algorithm; implementors
  237.    may choose to develop optimizations suited to their operating
  238.    environments.
  239.  
  240. 4.2.2.  Reference Implementation
  241.  
  242. /* RSA-MD2 Message Digest algorithm in C  */
  243. /*  by Ronald L. Rivest 10/1/88  */
  244.  
  245. #include <stdio.h>
  246.  
  247. /**********************************************************************/
  248. /* Message digest routines:                                           */
  249. /* To form the message digest for a message M                         */
  250. /*    (1) Initialize a context buffer md using MDINIT                 */
  251. /*    (2) Call MDUPDATE on md and each character of M in turn         */
  252. /*    (3) Call MDFINAL on md                                          */
  253. /* The message digest is now in md->D[0...15]                         */
  254. /**********************************************************************/
  255. /* An MDCTX structure is a context buffer for a message digest        */
  256. /*  computation; it holds the current "state" of a message digest     */
  257. /*  computation                                                       */
  258. struct MDCTX
  259. {
  260.    unsigned char  D[48];   /* buffer for forming digest in */
  261.                            /* At the end, D[0...15] form the message */
  262.                            /*  digest */
  263.    unsigned char  C[16];   /* checksum register */
  264.    unsigned char  i;       /* number of bytes handled, modulo 16 */
  265.    unsigned char  L;       /* last checksum char saved */
  266. };
  267. /* The table S given below is a permutation of 0...255 constructed    */
  268. /*  from the digits of pi.  It is a ``random'' nonlinear byte         */
  269. /*  substitution operation.                                           */
  270. int S[256] = {
  271.         41, 46, 67,201,162,216,124,  1, 61, 54, 84,161,236,240,  6, 19,
  272.         98,167,  5,243,192,199,115,140,152,147, 43,217,188, 76,130,202,
  273.         30,155, 87, 60,253,212,224, 22,103, 66,111, 24,138, 23,229, 18,
  274.        190, 78,196,214,218,158,222, 73,160,251,245,142,187, 47,238,122,
  275.        169,104,121,145, 21,178,  7, 63,148,194, 16,137, 11, 34, 95, 33,
  276.        128,127, 93,154, 90,144, 50, 39, 53, 62,204,231,191,247,151,  3,
  277.        255, 25, 48,179, 72,165,181,209,215, 94,146, 42,172, 86,170,198,
  278.         79,184, 56,210,150,164,125,182,118,252,107,226,156,116,  4,241,
  279.  
  280.  
  281.  
  282. Linn                                                            [Page 5]
  283.  
  284. RFC 1115                Mail Privacy: Algorithms             August 1989
  285.  
  286.  
  287.         69,157,112, 89,100,113,135, 32,134, 91,207,101,230, 45,168,  2,
  288.         27, 96, 37,173,174,176,185,246, 28, 70, 97,105, 52, 64,126, 15,
  289.         85, 71,163, 35,221, 81,175, 58,195, 92,249,206,186,197,234, 38,
  290.         44, 83, 13,110,133, 40,132,  9,211,223,205,244, 65,129, 77, 82,
  291.        106,220, 55,200,108,193,171,250, 36,225,123,  8, 12,189,177, 74,
  292.        120,136,149,139,227, 99,232,109,233,203,213,254, 59,  0, 29, 57,
  293.        242,239,183, 14,102, 88,208,228,166,119,114,248,235,117, 75, 10,
  294.         49, 68, 80,180,143,237, 31, 26,219,153,141, 51,159, 17,131, 20,
  295. };
  296. /*The routine MDINIT initializes the message digest context buffer md.*/
  297. /* All fields are set to zero.                                        */
  298. void MDINIT(md)
  299.   struct MDCTX *md;
  300.   { int i;
  301.     for (i=0;i<16;i++) md->D[i] = md->C[i] = 0;
  302.     md->i = 0;
  303.     md->L = 0;
  304.   }
  305. /* The routine MDUPDATE updates the message digest context buffer to  */
  306. /*  account for the presence of the character c in the message whose  */
  307. /*  digest is being computed.  This routine will be called for each   */
  308. /*   message byte in turn.                                            */
  309. void MDUPDATE(md,c)
  310.   struct MDCTX *md;
  311.   unsigned char c;
  312.   { register unsigned char i,j,t,*p;
  313.     /**** Put i in a local register for efficiency ****/
  314.        i = md->i;
  315.     /**** Add new character to buffer ****/
  316.        md->D[16+i] = c;
  317.        md->D[32+i] = c ^ md->D[i];
  318.     /**** Update checksum register C and value L ****/
  319.        md->L = (md->C[i] ^= S[0xFF & (c ^ md->L)]);
  320.     /**** Increment md->i by one modulo 16 ****/
  321.        i = md->i = (i + 1) & 15;
  322.     /**** Transform D if i=0 ****/
  323.        if (i == 0)
  324.          { t = 0;
  325.            for (j=0;j<18;j++)
  326.              {/*The following is a more efficient version of the loop:*/
  327.                /*  for (i=0;i<48;i++) t = md->D[i] = md->D[i] ^ S[t]; */
  328.                p = md->D;
  329.                for (i=0;i<8;i++)
  330.                  { t = (*p++ ^= S[t]);
  331.                    t = (*p++ ^= S[t]);
  332.                    t = (*p++ ^= S[t]);
  333.                    t = (*p++ ^= S[t]);
  334.                    t = (*p++ ^= S[t]);
  335.  
  336.  
  337.  
  338. Linn                                                            [Page 6]
  339.  
  340. RFC 1115                Mail Privacy: Algorithms             August 1989
  341.  
  342.  
  343.                    t = (*p++ ^= S[t]);
  344.                  }
  345.                /* End of more efficient loop implementation */
  346.                t = t + j;
  347.              }
  348.          }
  349.   }
  350. /* The routine MDFINAL terminates the message digest computation and  */
  351. /* ends with the desired message digest being in md->D[0...15].       */
  352. void MDFINAL(md)
  353.   struct MDCTX *md;
  354.   { int i,padlen;
  355.     /* pad out to multiple of 16 */
  356.        padlen  = 16 - (md->i);
  357.        for (i=0;i<padlen;i++) MDUPDATE(md,(unsigned char)padlen);
  358.     /* extend with checksum */
  359.     /* Note that although md->C is modified by MDUPDATE, character    */
  360.     /* md->C[i] is modified after it has been passed to MDUPDATE, so  */
  361.     /* the net effect is the same as if md->C were not being modified.*/
  362.     for (i=0;i<16;i++) MDUPDATE(md,md->C[i]);
  363.   }
  364.  
  365. /**********************************************************************/
  366. /* End of message digest implementation                               */
  367. /**********************************************************************/
  368.  
  369. NOTES:
  370.  
  371.   [1]  Federal Information Processing Standards Publication 113,
  372.        Computer Data Authentication, May 1985.
  373.  
  374.   [2]  ANSI X9.17-1985, American National Standard, Financial
  375.        Institution Key Management (Wholesale), American Bankers
  376.        Association, April 4, 1985, Section 7.2.
  377.  
  378.   [3]  American National Standard Data Encryption Algorithm (ANSI
  379.        X3.92-1981), American National Standards Institute, Approved 30
  380.        December 1980.
  381.  
  382.   [4]  Federal Information Processing Standards Publication 46,  Data
  383.        Encryption Standard, 15 January 1977.
  384.  
  385.   [5]  Information Processing Systems: Data Encipherment: Modes of
  386.        Operation of a 64-bit Block Cipher.
  387.  
  388.   [6]  Federal Information Processing Standards Publication 81,
  389.        DES Modes of Operation, 2 December 1980.
  390.  
  391.  
  392.  
  393.  
  394. Linn                                                            [Page 7]
  395.  
  396. RFC 1115                Mail Privacy: Algorithms             August 1989
  397.  
  398.  
  399.   [7]  American National Standard for Information Systems - Data
  400.        Encryption  Algorithm - Modes of Operation (ANSI X3.106-1983),
  401.        American National Standards Institute - Approved 16 May 1983.
  402.  
  403.   [8]  CCITT, Recommendation X.509, "The Directory: Authentication
  404.        Framework", Annex C.
  405.  
  406.   [9]  Moore, J., "Protocol Failures in Cryptosystems",
  407.        Proceedings of the IEEE, Vol. 76, No. 5, Pg. 597, May 1988.
  408.  
  409. Author's Address
  410.  
  411.        John Linn
  412.        Secure Systems
  413.        Digital Equipment Corporation
  414.        85 Swanson Road, BXB1-2/D04
  415.        Boxborough, MA  01719-1326
  416.  
  417.        Phone: 508-264-5491
  418.  
  419.        EMail: Linn@ultra.enet.dec.com
  420.  
  421.  
  422.  
  423.  
  424.  
  425.  
  426.  
  427.  
  428.  
  429.  
  430.  
  431.  
  432.  
  433.  
  434.  
  435.  
  436.  
  437.  
  438.  
  439.  
  440.  
  441.  
  442.  
  443.  
  444.  
  445.  
  446.  
  447.  
  448.  
  449.  
  450. Linn                                                            [Page 8]
  451.