<?xml version="1.0" encoding="US-ASCII"?>

<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [

<!ENTITY RFC2119 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml">
<!ENTITY RFC2629 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2629.xml">
<!ENTITY RFC8018 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.8018.xml">
<!ENTITY RFC3454 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.3454.xml">
<!ENTITY RFC3552 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.3552.xml">
<!ENTITY RFC5931 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.5931.xml">
<!ENTITY RFC7613 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.7613.xml">
<!ENTITY RFC7616 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.7616.xml">
<!ENTITY RFC7664 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.7664.xml">
<!ENTITY RFC7914 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.7914.xml">

]>
<?xml-stylesheet type='text/xsl' href='rfc2629.xslt' ?>
<?rfc strict="yes" ?>
<?rfc toc="yes"?>
<?rfc tocdepth="4"?>
<?rfc symrefs="yes"?>
<?rfc sortrefs="yes" ?>
<?rfc compact="yes" ?>
<?rfc subcompact="no" ?>

<rfc submissionType="IETF" category="info" consensus="yes" number="8146" ipr="trust200902" updates="5931">


  <!-- ***** FRONT MATTER ***** -->

  <front>


    <title abbrev="NaCled EAP-pwd">Adding Support for Salted Password Databases to EAP-pwd</title>



    <author fullname="Dan Harkins" initials="D.H." surname="Harkins">
      <organization>HP Enterprise</organization>
      <address>
	<postal>
	  <street>3333 Scott boulevard</street>
	  <city>Santa Clara</city>
	  <region>CA</region>
	  <code>95054</code>
	  <country>United States of America</country>
	</postal>
	<email>dharkins@arubanetworks.com</email>
      </address>
    </author>

    <date month="April" year="2017" />



    <!-- Meta-data Declarations -->

    <area>Security</area>

    <workgroup>Internet Engineering Task Force</workgroup>

    <keyword>"Password-Authenticated Key Exchange" PAKE "Dictionary Attack" Authentication EAP</keyword>



    <abstract>
      <t>
	EAP-pwd is an Extensible Authentication Protocol (EAP) method that utilizes a shared password
	for authentication using a technique that is resistant to dictionary attacks.
	It includes support for raw keys and double hashing of a password in the style of Microsoft Challenge Handshake Authentication Protoco version 2 (MSCHAPv2),
	but it does not include support for salted passwords. There are many existing
	databases of salted passwords, and it is desirable to allow their use with EAP-pwd.
      </t>
    </abstract>
  </front>

  <middle>
    <section title="Introduction">
      <section title="Background">
	<t>
	  Databases of stored passwords present an attractive target for attack -- get
	  access to the database, learn the passwords. To confound such attacks, a
	  random "salt" was hashed with the password and the resulting digest 
	  stored, along with the salt, instead of the raw password. This has the
	  effect of randomizing the password; even if two, distinct users have chosen
	  the same password, the stored, and salted, password will be different.
	  It also requires an adversary who has compromised the security of the
	  stored database to launch a dictionary attack per entry to recover
	  passwords.
	</t>
	<t>
	  Dictionary attacks, especially using custom hardware, represent real-world
	  attacks and merely salting a password is insufficient to protect a password
	  database. To address these attacks, a sequential memory hard function, such
	  as described in <xref target="RFC7914"/>, is used.
	</t>
	<t>
	  While salting a password database is not sufficient to deal with many
	  real-world attacks, the historic popularity of password salting means
	  there are a large number of such databases deployed, and EAP-pwd needs to
	  be able to support them. In addition, EAP-pwd needs to be able to support
	  databases using more modern sequential memory hard functions for protection.
	</t>
	<t>
	  EAP-pwd imposes an additional security requirement on a database of
	  salted passwords that otherwise would not exist, see 
	  <xref target="security"/>.
	</t>
      </section>
      <section title="Keyword Definition">
	<t>
	  The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
	  "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
	  document are to be interpreted as described in <xref target="RFC2119"></xref>.
	</t>
      </section>
    </section>
    <section title="Salted Passwords in EAP-pwd">
      <section title="Password Preprocessing">
	<t>
	  EAP-pwd is based on the "dragonfly" Password-Authenticated Key Exchange
	  (PAKE) -- see <xref target="RFC7664"/>. This is a balanced PAKE and
	  requires that each party to the protocol obtain an identical
	  representation of a processed password (see <xref target="security"/>).
	  Therefore, salting of a password is treated as an additional password
	  preprocessing technique of EAP-pwd. The salt and digest to use are
	  conveyed to the peer by the server, and the password is processed
	  prior to fixing the password element (see Section 2.8.3 of
	  <xref target="RFC5931"/>).
	</t>
	<t>
	  This memo defines eight (8) new password preprocessing techniques
	  for EAP-pwd:

	  <list hangIndent="4" style="symbols">
	    <t>0x03: a random salt with SHA-1</t>
	    <t>0x04: a random salt with SHA-256</t>
	    <t>0x05: a random salt with SHA-512</t>
	    <t>0x06: UNIX crypt()</t>
	    <t>0x07: scrypt</t>
	    <t>0x08: PBKDF2 with SHA-256</t>
	    <t>0x09: PBKDF2 with SHA-512</t>
	    <t>0x0A: SASLprep then a random salt with SHA-1</t>
	    <t>0x0B: SASLprep then a random salt with SHA-256</t>
	    <t>0x0C: SASLprep then a random salt with SHA-512</t>
	    <t>0x0D: SASLprep then UNIX crypt()</t>
	    <t>0x0E: OpaqueString then scrypt</t> 
	    <t>0x0F: OpaqueString then PBKDF2 with SHA-256</t> 
	    <t>0x10: OpaqueString then PBKDF2 with SHA-512</t> 
	  </list>
	  When passing salt, the size of the salt SHOULD be at least as
	  long as the message digest of the hash algorithm used. There is
	  no guarantee that deployed salted databases have followed this
	  rule, and in the interest of interoperability, an EAP peer
	  SHOULD NOT abort an EAP-pwd exchange if the length of the salt
	  conveyed during the exchange is less than the message digest of
	  the indicated hash algorithm. 
	</t>
	<t>
	  UNIX crypt() (<xref target="CRY"/>), scrypt (<xref target="RFC7914"/>), and
	  PBKDF2 (<xref target="RFC8018"/>) impose additional formatting requirements
	  on the passed salt. See below.
	</t>
	<t>
	  Plain salting techniques using <xref target="SHS"/> are included for support of existing
	  databases. scrypt and PBKDF2 techniques are RECOMMENDED for
	  new password database deployments. 
	</t>
	<t>
	  SASLprep has been deprecated, but databases treated with SASLprep
	  exist; it is necessary to provide code points for them. When using
	  SASLprep, a password SHALL be considered a "stored string" per
	  <xref target="RFC3454"/>; therefore, unassigned code points are
	  prohibited. The output of SASLprep SHALL be the binary representation
	  of the processed UTF-8 character string. Prohibited output and
	  unassigned code points encountered in SASLprep preprocessing SHALL
	  cause a failure of preprocessing, and the output SHALL NOT be
	  used with EAP-pwd.
	</t>
	<t>
	  When performing one of the preprocessing techniques (0x0E-0x10), the password SHALL be a UTF-8 string
	  and SHALL be preprocessed by applying the Preparation and Enforcement
	  steps of the OpaqueString profile in <xref target="RFC7613"/> to the
	  password. The output of OpaqueString, also a UTF-8 string, becomes the
	  EAP-pwd password and SHALL be hashed with the indicated algorithm.
	</t>
	<t>
	  There is a large number of deployed password databases that use
	  salting and hashing in the style of <xref target="RFC7616"/>, but these deployments
	  require a nonce contribution by the client (as well as the server), and
	  EAP-pwd does not have the capability to provide that information.
	</t>
      </section>
      <section title="The Salting of a Password">

	<t>
	  For both parties to derive the same salted password, there needs
	  to be a canonical method of salting a password. When using
	  EAP-pwd, a password SHALL be salted by hashing the password
	  followed by the salt using the designated hash function:
	  <list hangIndent="4" style="empty">
	    <t>salted-password = Hash(password | salt)</t>
	  </list>
	  The server stores the salted-password, and the salt, in its
	  database and the client derives the salted password
	  on the fly.
	</t>
      </section>
      <section title="Using UNIX crypt">
	<t>
	  Different algorithms are supported with the UNIX crypt() function.
	  The particular algorithm used is indicated by prepending an
	  encoding of "setting" to the passed salt. The specific
	  algorithm used is opaque to EAP-pwd as the entire salt, including
	  the encoded "setting", is passed as an opaque
	  string for interpretation by crypt(). The salted password
	  used for EAP-pwd SHALL be the output of crypt():
	  <list hangIndent="4" style="empty">
	    <t>salted-password = crypt(password, salt)</t>
	  </list>
	  The server stores the salted-password, and the encoded
	  algorithm plus salt, in its database and the client derives
	  the salted-password on-the-fly.
	</t>
	<t>
	  If the server indicates a crypt() algorithm that is unsupported
	  by the client, the exchange fails and the client MUST terminate
	  the connection. 
	</t>
      </section>
      <section title="Using scrypt">
	<t>
	  The scrypt function takes several parameters:
	  <list hangIndent="4" style="symbols">
	    <t>N, the cost parameter</t>
	    <t>r, the block size</t>
	    <t>p, the parallelization parameter</t>
	    <t>dkLen, the length of the output</t>
	  </list>
	</t>
	<t>
	  These parameters are encoded into the "salt" field of the modified EAP-pwd
	  message. Parameters r and dkLen SHALL be 16-bit integers in network order.
	  The other parameters SHALL each be 32-bit integers in network order. The "salt"
	  field that gets transmitted in EAP-pwd SHALL therefore be:
	  <list hangIndent="4" style="empty">
	    <t>N || r || p || dkLen || salt</t>
	  </list>
	  where || represents concatenation.
	</t>
	<t>
	  The value of N represents the exponent taken to the power of two in order to
	  determine the CPU/Memory cost of scrypt -- i.e., the value is 2^N.
	  Per <xref target="RFC7914"/>, the resulting CPU/Memory cost value SHALL be less
	  than 2^(128 * r / 8), and the value p SHALL be less than or equal to
	  ((2^32 - 1) * 32) / (128 * r).
	</t>
	<t>
	  Note: EAP-pwd uses the salted password directly as the authentication credential
	  and will hash it with a counter in order to obtain a secret element in a
	  finite field. Therefore, it makes little sense to use dkLen greater than the
	  length of the digest produced by the underlying hash function, but the capability is provided to do so
	  anyway.
	</t>
      </section>
      <section title="Using PBKDF2">
	<t>
	  The PBKDF2 function requires two parameters:
	  <list hangIndent="4" style="symbols">
	    <t>c, the iteration count</t>
	    <t>dkLen, the length of the output</t>
	  </list>
	</t>
	<t>
	  These parameters are encoded into the "salt" field of the modified EAP-pwd
	  message. The parameters SHALL be 16-bit integers in network order. The "salt"
	  field that gets transmitted in EAP-pwd SHALL therefore be:
	  <list hangIndent="4" style="empty">
	    <t>c || dkLen || salt</t>
	  </list>
	  where || represents concatenation.
	</t>
	<t>
	  Note: EAP-pwd uses the salted password directly as the authentication credential
	  and will hash it with a counter in order to obtain a secret element in a
	  finite field. Therefore, it makes little sense to use a dkLen greater than the
	  length of the digest produced by the underlying hash function, but the capability is provided to do so
	  anyway.
	</t>
      </section>
      <section title="Protocol Modifications">
	<t>
	  Like all EAP methods, EAP-pwd is server initiated, and the initial
	  identity supplied by the client is not useful for authentication
	  purposes. Because of this, the server is required to indicate its
	  intentions, including the password preprocessing it wishes to use,
	  before it knows the true identity of the client. This prevents the
	  server from supporting multiple salt digests simultaneously in a single
	  password database. To support multiple salt digests simultaneously,
	  it is necessary to maintain multiple password databases and use
	  the routable portion of the client identity to select one when
	  initiating EAP-pwd.
	</t>
	<t>
	  The server uses the EAP-pwd-ID/Request to indicate the password
	  preprocessing technique. The client indicates its acceptance of
	  the password preprocessing technique and identifies itself
	  in the EAP-pwd-ID/Response. If the client does not accept any of
	  the offered preprocessing techniques, it SHALL terminate the
	  exchange. Upon receipt of the EAP-pwd-ID/Response,
	  the server knows the identity of the client and can look up 
	  the client's salted password and the salt from the database.
	  The server adds the length of the salt and the salt itself
	  to the EAP-pwd-Commit/Request message (see <xref target="payload"/>).
	</t>
	<t>
	  The server can fix the password element (Section 2.8.3 of
	  <xref target="RFC5931"/>) as soon as the salted password
	  has been looked up in the database. The client, though, is
	  required to wait until receipt of the server's 
	  EAP-pwd-Commit/Request before it begins fixing the
	  password element.
	</t>
      </section>
      <section anchor= "payload" title="Payload Modifications">
	<t>
	  When a salted password preprocessing technique is agreed upon
	  during the EAP-pwd-ID exchange, the EAP-pwd-Commit payload is
	  modified to include the salt and salt length (see
	  <xref target="commit-req"/>). The server passes the salt
	  and salt length in the EAP-pwd-Commit/Request; the
	  client's EAP-pwd-Commit/Response is unchanged, and it MUST
	  NOT echo the salt length and salt in its EAP-pwd-Commit/Response.
	</t>
	<t>
	  <figure align="center" anchor="commit-req" 
		  title="Salted EAP-pwd-Commit/Request">
	    <artwork align="center"><![CDATA[
    0                   1                   2                   3
    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |   Salt-len    |                                               |
   +-+-+-+-+-+-+-+-+                                               ~
   ~                            Salt             +-+-+-+-+-+-+-+-+-+
   |                                             |                 |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                 ~
   |                                                               |
   ~                           Element                             ~
   |                                                               |
   ~                               +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                               |                               |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                               ~
   |                                                               |
   ~                            Scalar             +-+-+-+-+-+-+-+-+
   |                                               |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
	    ]]></artwork>
	  </figure>
	</t>
	<t>
	  The "salt-len" SHALL be non-zero, and it indicates the length,
	  in octets, of the salt that follows.
	  The "Salt" SHALL be a binary string.
	  The "Element" and "Scalar" are encoded according to Section 3.3
	  of <xref target="RFC5931"/>.
	</t>
	<t>
	  Note: when a non-salted password preprocessing method is
	  used, for example, any of the methods from 
	  <xref target="RFC5931"/>, the EAP-pwd-Commit payload MUST
	  NOT be modified to include the salt and salt length.
	</t>
      </section>
    </section>

    <section anchor="iana" title="IANA Considerations">
      <t>
	IANA has allocated fourteen (14) values from the 
	"password preprocessing method registry" established
	by <xref target="RFC5931"/>.
      </t>
    </section>

    <section anchor="security" title="Security Considerations">
      <t>
	EAP-pwd requires each side to produce an identical representation
	of the (processed) password before the password element can
	be fixed. This symmetry undercuts one of the benefits to salting
	a password database because the salted password from a
	compromised database can be used directly to impersonate the
	EAP-pwd client -- since the plaintext password need not be recovered,
	no dictionary attack is needed. While the immediate effect of such
	a compromise would be compromise of the server, the per-user salt
	would still prevent the adversary from recovering the password,
	barring a successful dictionary attack, to use for other
	purposes. 
      </t>
      <t>
	Salted password databases used with EAP-pwd
	MUST be afforded the same level of protection as databases of
	plaintext passwords.
      </t>
      <t>
	Hashing a password with a salt increases the work factor for an
	attacker to obtain the cleartext password, but dedicated hardware
	makes this increased work factor increasingly negligible in
	real-world scenarios. Cleartext password databases SHOULD be
	protected with a scheme that uses a sequential memory hard
	function such as <xref target="RFC7914"/>.
      </t>
      <t>
	EAP-pwd sends the salt in the clear. If EAP-pwd is
	not tunneled in another, encrypting, EAP method, an adversary
	that can observe traffic from server to authenticator or
	from authenticator to client would learn the salt used for a
	particular user. While knowledge of a salt by an adversary may
	be of a somewhat dubious nature (pre-image resistance of the
	hash function used will protect the client's password and, as
	noted above, the database of salted passwords must still be
	protected from disclosure), it does represent potential
	additional meta-data in the hands of a untrusted third party. 
      </t>
    </section>
  </middle>

  <!--  *****BACK MATTER ***** -->

  <back>
    <references title="Normative References">
 
      &RFC2119;
      &RFC8018;
      &RFC3454;
      &RFC5931;
      &RFC7613;
      &RFC7914;

      <reference anchor="SHS"
                 target="http://csrc.nist.gov/publications/fips/fips180-4/fips-180-4.pdf">
        <front>
          <title>Secure Hash Standard (SHS)</title>
          <author>
            <organization>National Institute of Standards and Technology</organization>
          </author>

          <date month="August" year="2015"/>
        </front>
       <seriesInfo name="FIPS PUB" value="180-4"/>
       <seriesInfo name="DOI" value="10.6028/NIST.FIPS.180-4"/>
      </reference>

      <reference anchor="CRY"
		 target="http://man7.org/linux/man-pages/man3/crypt.3.html">
	<front>
	  <title>CRYPT(3)</title>
	  <author>
            <organization>Linux Programmer's Manual</organization>
           </author>
	  <date month="August" year="2015"/>
	</front>
      </reference>

    </references>
    <references title="Informative References">
      &RFC7616;
      &RFC7664;
    </references>
    <section anchor="ack" title="Acknowledgements" numbered="no">
      <t>
	Thanks to Stefan Winter and the eduroam project for its continued
	interest in using EAP-pwd. Thanks to Simon Josefsson for his
	advice on support for scrypt and PBKDF2.
      </t>
    </section>
  </back>
</rfc>
