RFC 1810 INFORMATIONAL SECURITY · CRYPTOGRAPHY · PERFORMANCE

Report on MD5 Performance

Measuring how fast MD5 can authenticate data in hardware and software, and what to do about it.

On rfc-editor.org ↗
PUBLISHED
June 1995
AUTHORS
J. Touch
STREAM
Legacy
BEST MEASURED SOFTWARE RATE
87 Mbps on a DEC Alpha at 190 MHz
HARDWARE RATE IN CMOS
256 Mbps
NETWORK RATES TO MATCH
100 Mbps TCP and 130 Mbps UDP over ATM
SOFTWARE COST PER WORD OF INPUT
20 instructions
PARALLEL SOFTWARE RATE
1.6 times the MIPS rate
PROPOSED CHAINING
16-way, with 4-way the minimum
DOI
10.17487/RFC1810
ERRATA
Reported errata

RFC text

Contents
Original text · RFC Editor View on rfc-editor.org ↗
Network Working Group                                           J. Touch
Request for Comments: 1810                                           ISI
Category: Informational                                        June 1995


                       Report on MD5 Performance

Status of this Memo

   This memo provides information for the Internet community.  This memo
   does not specify an Internet standard of any kind.  Distribution of
   this memo is unlimited.

Abstract

   MD5 is an authentication algorithm, which has been proposed as the
   default authentication option in IPv6.  When enabled, the MD5
   algorithm operates over the entire data packet, including header.
   This RFC addresses how fast MD5 can be implemented in software and
   hardware, and whether it supports currently available IP bandwidth.
   MD5 can be implemented in existing hardware technology at 256 Mbps,
   and in software at 87 Mbps.  These rates cannot support current IP
   rates, e.g., 100 Mbps TCP and 130 Mbps UDP over ATM.  If MD5 cannot
   support existing network bandwidth using existing technology, it will
   not scale as network speeds increase in the future.  This RFC is
   intended to alert the IP community about the performance limitations
   of MD5, and to suggest that alternatives be considered for use in
   high speed IP implementations.

Introduction

   MD5 is an authentication algorithm, which has been proposed as one
   authentication option in IPv6 [1].  RFC 1321 describes the MD5
   algorithm and gives a reference implementation [3].  When enabled,
   the MD5 algorithm operates over the entire data packet, including
   header (with dummy values for volatile fields).  This RFC addresses
   how fast MD5 can be implemented in software and hardware, and whether
   it supports currently available IP bandwidth.

   This RFC considers the general issue of checksumming and security at
   high speed in IPv6.  IPv6 has no header checksum (which IPv4 has
   [5]), but proposes an authentication digest over the entire body of
   the packet (including header where volatile fields are zeroed) [1].
   This RFC specifically addresses the performance of that
   authentication mechanism.

Measurements

   The performance of MD5 was measured.  The code was an optimized
   version of the MD5 reference implementation from the RFC [3], and is
   available for anonymous FTP [7].  The following are the results of
   the performance test "md5 -t", modified to prohibit on-chip caching
   of the data block:

        87 Mbps    DEC Alpha (190 Mhz)
        33 Mbps    HP 9000/720
        48 Mbps    IBM RS/6000 7006 (PPC 601 @80 Mhz)
        31 Mbps    Intel i486/66 NetBSD
        44 Mbps    Intel Pentium/90 NeXTStep
        52 Mbps    SGI/IP-20 IRIX 5.2
        37 Mbps    Sun SPARC-10/51, SPARC-20/50 SunOS 4.1.3
        57 Mbps    Sun SPARC-20/71 SunOS 4.1.3

   These rates do not keep up with currently available IP bandwidth,
   e.g., 100 Mbps TCP and 130 Mbps UDP over a Fore SBA-200 ATM host
   interface in a Sun SPARC-20/71.

   Values as high as 100 Mbps have been reported for the DEC Alpha (190
   Mhz).  These values reflect on-chip caching of the data.  It is not
   clear at this time whether in-memory, off-chip cache, or on-chip
   cache performance measures are more relevant to IP performance.

Analysis of the MD5 Algorithm

   The MD5 algorithm is a block-chained hashing algorithm.  The first
   block is hashed with an initial seed, resulting in a hash.  The hash
   is summed with the seed, and that result becomes the seed for the
   next block.  When the last block is computed, it's "next-seed' value
   becomes the hash for the entire stream. Thus, the seed for block
   depends on both the hash and the seed of its preceding block.  As a
   result, blocks cannot be hashed in parallel.

   Each 16-word (64-byte) block is hashed via 64 basic steps, using a
   4-word intermediate hash, and collapsing the intermediate hash at the
   end.  The 64 steps are 16 groups of 4 steps, one step per
   intermediate hash word.  This RFC uses the following notation (as
   from RFC-1321 [3]):

        A,B,C,D         intermediate hash words
        X[i]            input data block
        T[i]            sine table lookup
        << i            rotate i bits
        F               logical functions of 3 args

   The subscripts to X, I, and << are fixed for each step, and are
   omitted here.  There are four different logical functions, also
   omitted.  Each 4-step group looks like:

        A = B + ((A + F(B,C,D) + X[i] + T[i]) << i)
        D = A + ((D + F(A,B,C) + X[i] + T[i]) << i)
        C = D + ((C + F(D,A,B) + X[i] + T[i]) << i)
        B = C + ((B + F(C,D,A) + X[i] + T[i]) << i)

   Note that this has the general form shown below. Due to the
   complexity of the function 'f', these equations cannot be transformed
   into a less serial set.

        A = f(D); B = f(A); C = f(B); D = f(C)

   Each steps is composed of two table lookups, one rotation, a 3-
   component logical operation, and 4 additions.  The best
   parallelization possible leaves F(x,y,z) to the last step, waiting as
   long as possible for the result from the previous step.  The
   resulting tree is shown below.

     (t0) B* C  C  D      X   T
          |  |  |  |      |   |
          |  |  |  |      |   |
           \/    \/        \ /
      t1   op    op   A     +                               X   T
            \    /    \    /                                |   |
             \  /      \  /                                 |   |
              \/        \/                                   \ /
      t2      op        +             (t0) B* C  C  D   A     +
               \       /                   |  |  |  |    \    /
                 \   /                      \ |  | /      \  /
                  \ /                         \\//         \/
      t3           +                   t1      op          +
                   |                            \         /
                   |                              \     /
                   |                                \ /
      t4           <<      B*          t2            +       B*
                    \     /                           \     /
                     \   /                             <<  /
                      \ /                               \ /
      t5               +               t3                +
                       |                                 |
                       |                                 |
                       |                                 |
                       A**                               A**

            Binary operation tree             Optimized hardware tree

   This diagram assumes that each operation takes one unit time.  The
   tree shows the items that depend on the previous step as B*, and the
   item that the next step depends on as A**.  Sequences of the binary
   operation tree cannot be overlapped, but the optimized hardware tree
   can (by one time step).

   There are 4 steps processed per word of input, ignoring inter-block
   processing.  The speed of the overall algorithm depends on how fast
   we can process these 4 steps, vs.  the bandwidth of one word of input
   being processed.

   The binary tree takes 5 time units per step of the algorithm, and
   permits at best 3-way parallelism (at time t1).  In software, this
   means it takes 5 * 4 = 20 instructions per word input.  A computer
   capable of M MIPS can support a data bandwidth of M/20 * 32 Mbps,
   i.e., bits per second equal to 1.6x its MIPS rate.  Therefore, a 100
   MIPS machine can support a 160 Mbps stream.

        Parallel software rate in Mbps = 1.6 * MIPS rate

   This assumes that register reads and writes are overlapped with
   computation entirely.  Without any parallelism, there are 8
   operations per step, and 4 steps per word, so 32 operations per word,
   i.e., the data rate in Mbps would be identical to the MIPS rate:

        Serial software rate in Mbps = MIPS rate

   Predictions using SpecInt92 numbers as MIPS estimators can be
   compared with measured rates [2]:

     Spec-    Predicted      MD5
     Int92   Upper-Bound   Measured      Machine
   ------------------------------------------------------------
     122       122-195     87 Mbps    DEC Alpha (190 Mhz)
      48        48- 77     33 Mbps    HP 9000/720
      88        88-141     48 Mbps    IBM RS/6000 7006 (PPC 601 @80 Mhz)
      32        32- 51     31 Mbps    Intel i486/33 NetBSD
      90        90-144     44 Mbps    Intel Pentium/90 NeXTStep
      90        90-144     52 Mbps    SGI/IP-20 IRIX 5.2
      65        65-104     37 Mbps    Sun SPARC-10/51 SunOS 4.1.3
     126       126-202     57 Mbps    Sun SPARC-20/71 SunOS 4.1.3

   The hardware rate takes 3 time units per step, i.e.  3 * 4 = 12 time
   units per word of input.  Hardware capable of doing an operation
   (e.g., 32-bit addition) in N nanoseconds can support a data bandwidth
   of 32/12/N bps, i.e., 2/3N bps.

        Hardware rate in Mbps = 8/3N * 1,000

   For CMOS, an operation (32-bit addition, including register retrieval
   and storage) costs about 5.2 ns (2.6 ns per add, 2 ns for latching)
   [6].  There are 6 clocks through the most highly-parallelized
   implementation, resulting in 31.2 ns per 32-bit word, or 256 Mbps
   [6].  This will not keep pace with existing hardware, which is
   capable of link speeds in excess of 622 Mbps (ATM).

   By comparison, IPv4 uses the Internet Checksum [5].  This checksum
   can be performed in 32-bit-wide units in excess of 1 Gbps in an
   existing, low-cost PLD.  The checksum can also be parallelized by
   computing partial sums and reducing the result.

One Proposed Solution

   There are several ways to increase the performance of the IPv6
   authentication mechanism.  One is to increase the hardware
   performance of MD5 by slightly modifying the algorithm, the other is
   to propose a replacement algorithm.  This RFC discusses briefly the
   modification of MD5 for high-speed hardware implementation.
   Alternate algorithms, capable of 3.5x the speed of MD5, have been
   discussed elsewhere [6].

   MD5 uses block chaining to ensure sensitivity to block order.  Block
   chaining also prevents arbitrary parallelism, which can be as much a
   benefit to the spoofer as to the user.  MD5 can be slightly altered
   to accommodate a higher bandwidth data rate.  There should be a
   predetermined finite number of blocks processed from independent
   seeds, such that the I-th block is part of the "I mod K"-th chain.
   The resulting K digests themselves form a message, which can be MD5-
   encoded using a single-block algorithm. This idea was proposed
   independently by the author and by Burt Kaliski of RSA.

   The goal is to support finite parallelism to provide adequate
   bandwidth at current processing rates, without providing arbitrary
   power for spoofing.  It would require further analysis to ensure that
   it provides an adequate level of security.

   For current technology and network bandwidth, a minimum of 4-way
   parallel chaining would suffice, and 16-way chaining would be
   preferable.  This would support network bandwidth of 1 Gbps with 4-
   way chaining, in CMOS hardware.  The chaining parallelism should be a
   multiple of 4-way, to generate a complete block of digests (4 words
   per digest, 16 words per block).  This modification is believed to
   achieve the goals of MD5, without the penalties of implementation of
   the current MD5 algorithm.

Security Considerations

   This entire document addresses a mechanism for providing security in
   IPv6.  MD5 is the proposed default optional authentication mechanism
   for IPv6 traffic.  This RFC specifically addresses the concern that
   security mechanisms such as MD5 that cannot support high bandwidth
   with available hardware will compromise their deployment, and
   ultimately, the security of the systems they are intended to
   maintain.

   The IPv6 requirements document emphasizes that IPv6 implementations
   should not compromise performance, compared to IPv4.  This is
   presumably despite IPv6's increased functionality.  "Required
   optional" components of IPv6 should be held to this same standard.
   MD5 compromises performance, and so its use as a required default
   option in IPv6 should be reconsidered.

   The use of MD5 as the default to the required authentication option
   may compromise security in high-bandwidth systems, because enabling
   the option causes performance degradation, defeating its inclusion as
   an IPv6 option.  As a result, the authentication option may be
   disabled entirely.

   It is important to the use of authentication in high-performance
   systems that an alternative mechanism be available in IPv6 from the
   outset.  This may require the specification of multiple "required"
   authentication algorithms - one that's slower but believed strong,
   and one that's faster but may inspire somewhat less confidence.

Conclusions

   MD5 cannot be implemented in existing technology at rates in excess
   of 256 Mbps in hardware, or 86 Mbps in software.  MD5 is a proposed
   authentication option in IPv6, a protocol that should support
   existing networking technology, which is capable of 130 Mbps UDP.

   As a result, MD5 cannot be used to support IP authentication in
   existing networks at existing rates.  Although MD5 will support
   higher bandwidth in the future due to technological advances, these
   will be offset by similar advances in networking.  If MD5 cannot
   support existing network bandwidth using existing technology, it will
   not be able to scale as network speeds increase in the future.  This
   RFC proposes that MD5 be modified to support a 16-way block chaining,
   in order to allow existing technology (CMOS hardware) to support
   existing networking rates (1 Gbps).  It further proposes that
   alternatives to MD5 be considered for use in high-speed networks.

Acknowledgements

   The author would like to thank Steve Kent at BBN, Burt Kaliski,
   Victor Chang, and Steve Burnett at RSA, Ran Atkinson at the NRL, and
   the HPCC Division at ISI for reviewing the contents of this document.
   Burt independently suggested the block-parallel modification proposed
   here.

References

   [1] Atkinson, R., "IPv6 Authentication Header", Work in Progress,
       Naval Research Lab, February 1995.

   [2] DiMarco, J., "Spec Benchmark table, V.  4.12",
       <ftp://ftp.cfd.toronto.edu/pub/spectable>.

   [3] Rivest, R., "The MD5 Message-Digest Algorithm", RFC1321, MIT LCS
       & RSA Data Security, Inc., April 1992.

   [4] Partridge, C., and F. Kastenholz, "Technical Criteria for
       Choosing IP The Next Generation (IPng)", RFC 1726, BBN Systems
       and Technologies, FTP Software, December 1994.

   [5] Postel, J., "Internet Protocol - DARPA Internet Program Protocol
       Specification," STD 5, RFC 791, USC/Information Sciences
       Institute, September 1981.

   [6] Touch, J., "Performance Analysis fo MD5," to appear in ACM
       Sigcomm '95, Boston.

   [7] Touch, J., Optimized MD5 software, <ftp://ftp.isi.edu/pub/hpcc-
       papers/touch/md5-opt.tar>.

Author's Address

   Joe Touch
   Information Sciences Institute
   University of Southern California
   4676 Admiralty Way
   Marina del Rey, CA 90292-6695
   USA

   Phone: +1 310-822-1511 x151
   Fax:   +1 310-823-6714
   URL:   ftp://ftp.isi.edu/pub/hpcc-papers/touch
   EMail: touch@isi.edu

ISO Plain Language

On this page
PROBLEMMD5 had been proposed as a default authentication mechanism for IPv6, but it had to be shown that it could keep up with the IP bandwidth available at the time.
MECHANISMThe RFC measures MD5 on eight platforms in software and works out what the algorithm's structure allows in hardware, finding that its block chaining limits how much of the work can run at the same time.
THE VERDICTThe best software rate measured was 87 Mbps and hardware tops out at 256 Mbps, below the 100 Mbps TCP and 130 Mbps UDP over ATM rates of the day. The RFC proposes a 16-way parallel chaining of MD5 and asks that alternatives be considered.

§1Why the Speed Matters

MD5 is an authentication algorithm that has been proposed as one authentication option in IPv6. RFC 1321 describes the MD5 algorithm and gives a reference implementation. When enabled, the MD5 algorithm operates over the entire data packet, including the header, with dummy values for the volatile fields.

The RFC addresses how fast MD5 can be implemented in software and hardware, and whether it supports the currently available IP bandwidth. It frames the question as the general issue of checksumming and security at high speed in IPv6. IPv6 has no header checksum, which IPv4 has, but proposes an authentication digest over the entire body of the packet, including the header where volatile fields are zeroed. The performance of that mechanism is what the report examines.

If a security check on incoming packets takes longer than the packets arrive, the router cannot keep up with the data. This report asks whether MD5 would cause that.

§2Measured Performance

The code measured was an optimized version of the MD5 reference implementation from RFC 1321, and the results come from the performance test md5 -t, modified to prohibit on-chip caching of the data block. The measured rates were 87 Mbps on a DEC Alpha at 190 MHz, 33 Mbps on an HP 9000/720, 48 Mbps on an IBM RS/6000 7006 with a PPC 601 at 80 MHz, 31 Mbps on an Intel i486/66 running NetBSD, 44 Mbps on an Intel Pentium/90 running NeXTStep, 52 Mbps on an SGI IP-20 running IRIX 5.2, 37 Mbps on a Sun SPARC-10/51 and SPARC-20/50 running SunOS 4.1.3, and 57 Mbps on a Sun SPARC-20/71 running SunOS 4.1.3.

The report says these rates do not keep up with the currently available IP bandwidth, for example 100 Mbps TCP and 130 Mbps UDP over a Fore SBA-200 ATM host interface in a Sun SPARC-20/71. It also notes that values as high as 100 Mbps have been reported for the DEC Alpha, but that those reflect on-chip caching of the data, and that it is not clear whether in-memory off-chip cache or on-chip cache performance measures are more relevant to IP performance.

Testing shows MD5 running between 31 and 87 million bits per second on the fastest computers of the time, while the networks around them were already carrying 100 to 130 million bits per second.

MEASURED MD5 SOFTWARE RATES AND THE NETWORK RATES TO MATCH
MachineMD5 rate
DEC Alpha (190 MHz)87 Mbps
Sun SPARC-20/7157 Mbps
SGI IP-2052 Mbps
IBM RS/600048 Mbps
Intel Pentium/9044 Mbps
Sun SPARC-1037 Mbps
HP 9000/72033 Mbps
Intel i486/6631 Mbps
TCP on the network100 Mbps
UDP over ATM on the network130 Mbps

§3Why MD5 Cannot Go Faster

WHAT EACH APPROACH TO CHECKING A PACKET COSTS
ApproachRate
MD5 in software, no parallelism1 Mbps for each MIPS
MD5 in software, with parallelism1.6 Mbps for each MIPS
MD5 in CMOS hardware256 Mbps
IPv4 header checksum in a low-cost PLDMore than 1 Gbps

The MD5 algorithm is a block-chained hashing algorithm. The first block is hashed with an initial seed, and the resulting hash is summed with the seed to become the seed for the next block. When the last block is computed, its next-seed value becomes the hash for the whole stream. The seed for a block therefore depends on both the hash and the seed of the block before it, and as a result blocks cannot be hashed in parallel.

Each 16-word, that is 64-byte, block is hashed in 64 basic steps using a 4-word intermediate hash, which is collapsed at the end, and the 64 steps are 16 groups of 4 steps, one step per intermediate hash word. Each step is composed of two table lookups, one rotation, a 3-component logical operation and 4 additions. The best parallelisation possible leaves the logical function to the last step, and the resulting tree shows that sequences of the binary operation tree cannot be overlapped while the optimised hardware tree can, by one time step. The binary tree takes 5 time units per step of the algorithm and permits at best 3-way parallelism, which in software means 20 instructions per word of input.

From this the report derives two software rates. A computer capable of M MIPS can support a data bandwidth of M/20 * 32 Mbps, that is 1.6 times its MIPS rate, so a 100 MIPS machine can support a 160 Mbps stream, provided register reads and writes overlap entirely with computation. Without any parallelism there are 8 operations per step and 4 steps per word, so 32 operations per word and the data rate equals the MIPS rate. Measured results on eight machines are compared against predictions made from SpecInt92 numbers as MIPS estimators.

The hardware rate takes 3 time units per step, that is 12 time units per word of input. Hardware that can do an operation such as a 32-bit addition in N nanoseconds supports a data bandwidth of 32/12/N bits per second. For CMOS, an operation including register retrieval and storage costs about 5.2 ns, and with 6 clocks through the most highly parallelised implementation that gives 31.2 ns per 32-bit word, or 256 Mbps. The report notes that this will not keep pace with existing hardware, which is capable of link speeds in excess of 622 Mbps for ATM. By comparison, IPv4 uses the Internet checksum, which can be performed in 32-bit-wide units in excess of 1 Gbps in an existing low-cost PLD, and can also be parallelised by computing partial sums and reducing the result.

MD5 works step by step in a chain where each step must wait for the previous one to finish, so the blocks of a packet cannot be hashed at the same time. That is the reason it cannot be sped up much.

WHAT THE ALGORITHM ALLOWS
  • Block chainingEach block depends on the block before it, so blocks cannot be hashed in parallel.
  • 64 steps per blockEach 64-byte block is hashed in 64 basic steps, in 16 groups of 4.
  • 5 time units per stepThe binary operation tree gives 20 instructions per word of input in software.
  • 3-way parallelismThat is the most the binary operation tree allows at any one time.
  • 3 time units per step in hardwareThat is 12 time units per word of input, which gives 256 Mbps in CMOS.

§4The Proposed Modification

The report considers two ways to raise the performance of the IPv6 authentication mechanism: increasing the hardware performance of MD5 by slightly modifying the algorithm, or proposing a replacement algorithm. It discusses the modification briefly, and notes that alternate algorithms capable of 3.5 times the speed of MD5 have been discussed elsewhere.

MD5 uses block chaining to ensure sensitivity to block order, and block chaining also prevents arbitrary parallelism, which can be as much a benefit to a spoofer as to the user. MD5 can be slightly altered so that a predetermined finite number of blocks are processed from independent seeds, such that the I-th block is part of the I mod K-th chain. The resulting K digests themselves form a message, which can be MD5-encoded using a single-block algorithm. The report says this idea was proposed independently by the author and by Burt Kaliski of RSA.

The goal is to support finite parallelism, to provide adequate bandwidth at current processing rates, without providing arbitrary power for spoofing. The report says it would require further analysis to ensure an adequate level of security. For current technology and network bandwidth, a minimum of 4-way parallel chaining would suffice and 16-way chaining would be preferable, which would support network bandwidth of 1 Gbps with 4-way chaining in CMOS hardware. The chaining parallelism should be a multiple of 4-way, to generate a complete block of digests, since there are 4 words per digest and 16 words per block.

Split the data into a fixed number of chains and hash them side by side instead of one after another. Sixteen chains would let existing hardware handle a gigabit per second.

§5Security Considerations

The whole document addresses a mechanism for providing security in IPv6, and MD5 is the proposed default optional authentication mechanism for IPv6 traffic. The report says its concern is that security mechanisms such as MD5 that cannot support high bandwidth with available hardware will compromise their deployment, and ultimately the security of the systems they are meant to maintain.

The IPv6 requirements document emphasises that IPv6 implementations should not compromise performance compared to IPv4, presumably despite IPv6's increased functionality, and that required optional components of IPv6 should be held to the same standard. The report says MD5 compromises performance, and so its use as a required default option in IPv6 should be reconsidered. Using MD5 as the default for the required authentication option may compromise security in high-bandwidth systems, because enabling the option causes performance degradation, which defeats its inclusion as an IPv6 option, and as a result the authentication option may be disabled entirely.

It concludes that it is important for the use of authentication in high-performance systems that an alternative mechanism be available in IPv6 from the outset. This may require the specification of multiple required authentication algorithms, one slower but believed strong, and one faster but inspiring somewhat less confidence. The conclusions repeat the numbers: MD5 cannot be implemented in existing technology at rates in excess of 256 Mbps in hardware, or 86 Mbps in software, so it cannot be used to support IP authentication in existing networks at existing rates, and although MD5 will support higher bandwidth in the future through technological advances, those will be offset by similar advances in networking.

The report's conclusion is that making a slow security check part of every packet may make people turn it off altogether, which is worse than having nothing. It asks for a faster alternative to be available from the start.

§6References