<?xml version="1.0" encoding="US-ASCII"?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
<!ENTITY RFC1321 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.1321.xml">
<!ENTITY RFC2119 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml">
<!ENTITY RFC2829 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2829.xml">
<!ENTITY RFC3112 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.3112.xml">
<!ENTITY RFC4510 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4510.xml">
<!ENTITY RFC4519 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4519.xml">
<!ENTITY RFC4270 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4270.xml">
<!ENTITY RFC4648 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4648.xml">
<!ENTITY RFC2307 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2307.xml">
<!ENTITY RFC5802 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.5802.xml">
<!ENTITY RFC5803 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.5803.xml">
<!ENTITY RFC6151 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6151.xml">
<!ENTITY RFC6648 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6648.xml">
<!ENTITY I-D.behera-ldap-password-policy SYSTEM "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.behera-ldap-password-policy.xml">
<!ENTITY I-D.hoffman-schneier-4270bis SYSTEM "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.draft-hoffman-schneier-4270bis-01.xml">
]>
<?xml-stylesheet type="text/xsl" href="rfc2629.xslt" ?> <!-- used by XSLT processors -->
<!-- OPTIONS, known as processing instructions (PIs) go here. -->
<!-- For a complete list and description of PIs,
     please see http://xml.resource.org/authoring/README.html. -->
<!-- Below are generally applicable PIs that most I-Ds might want to use. -->
<?rfc strict="yes" ?> <!-- give errors regarding ID-nits and DTD validation -->
<!-- control the table of contents (ToC): -->
<?rfc toc="yes"?> <!-- generate a ToC -->
<?rfc tocdepth="2"?> <!-- the number of levels of subsections in ToC. default: 3 -->
<!-- control references: -->
<?rfc symrefs="yes"?> <!-- use symbolic references tags, i.e, [RFC2119] instead of [1] -->
<?rfc sortrefs="yes" ?> <!-- sort the reference entries alphabetically -->
<!-- control vertical white space:
     (using these PIs as follows is recommended by the RFC Editor) -->
<?rfc compact="yes" ?> <!-- do not start each main section on a new page -->
<?rfc subcompact="no" ?> <!-- keep one blank line between list items -->
<!-- end of popular PIs -->

<rfc
  category="info"
  docName="draft-stroeder-hashed-userpassword-values-01"
  ipr="trust200902"
  updates="2307"
>

  <front>

    <title abbrev="LDAP Hashed userPassword Values">
      Lightweight&nbsp;Directory&nbsp;Access&nbsp;Protocol&nbsp;(LDAP):
      Hashed&nbsp;Attribute&nbsp;values&nbsp;for&nbsp;'userPassword'
    </title>

    <author fullname="Michael Stroeder" initials="M" surname="Stroeder">
      <organization>Independent consultant</organization>
      <address>
        <postal>
          <street>Klauprechtstr. 11</street>
          <city>Karlsruhe</city>
          <code>76137</code>
          <country>DE</country>
        </postal>
<!-- <phone/> -->
        <email>michael@stroeder.com</email>
        <uri>http://www.stroeder.com</uri>
      </address>
    </author>

    <date year="2013" />
<!-- <area/> -->
    <workgroup>Network Working Group</workgroup>
    <keyword>ldap</keyword>
    <keyword>userPassword</keyword>
    <keyword>hashed password</keyword>

    <abstract>
      <t>
        This document describes the widely used syntax for storing 
        hashed passwords in LDAP attribute 'userPassword'.
        Furthermore it points out some of the deficiencies of 
        the approach.
        Its purpose is solely to document current practice, it does not 
        define a new standard.
      </t>
    </abstract>

  </front>

  <middle>

    <section anchor="introduction" title="Introduction">
      <t>
        This document does not define a new standard.  Its purpose is 
        solely to correctly document what is widely implemented in LDAP 
        servers and clients to avoid interop issues in case implementors 
        have to support old legacy systems using this scheme.
      </t>
      <t>
        Strictly speaking the 'userPassword' attribute type, intended to
        be used to support the LDAP <xref target="RFC4510"/> "simple"
        bind operation, was meant to only store clear text passwords
        <xref target="RFC4519"/>.
      </t>
      <t>
        Although <xref target="RFC3112"/> defined a more versatile
        password attribute 'authPassword' for storing hashed passwords this
        was not widely implemented in server and client implementations.
        Instead current LDAP deployments still rely on the password
        hashing scheme for attribute 'userPassword' introduced in
        <xref target="RFC2307"/> especially since this attribute type is
        directly used in various object classes.
      </t>
      <t>
        The specification in <xref target="RFC2307"/> is missing some 
        formal aspects potentially leading to interop issues. 
        Furthermore new hash algorithms are used today by various 
        implementors which were not mentioned in <xref target="RFC2307"/>.
      </t>
      <t>
        Therefore this document also updates <xref target="RFC2307"/> by
        fully specifying how to store hashed password values in
        attribute 'userPassword' optionally using the SHA-2 hash
        algorithms <xref target="FIPS-180-4"/>.  For this it focuses on
        documenting already implemented server and client implementations.
        The password hashing scheme {crypt} was left out from the syntax 
        definition because there are many platform-specific variants of 
        possible values.
      </t>
      <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"/>.
      </t>
      <t>
        This document is being discussed on the ldapext@ietf.org mailing list.
      </t>
    </section>

    <section anchor="syntax_userPassword" title="Syntax for attribute 'userPassword'">

      <t>
        userPassword values MUST be represented by following syntax:
      </t>
      <figure><artwork><![CDATA[
    userpasswordvalue  = cleartext-password / prefix b64-hashandsalt

    prefix       = "{" scheme "}"
    scheme = %x30-39 / %x41-5A / %x61-7a / %x2D-2F / %x5F
         ;0-9, A-Z, a-z, "-", ".", "/", or "_"

    b64-hashandsalt = <base64 of hashandsalt>

    hashandsalt = password-hash salt

    password-hash = <digest of cleartext-password salt>

    cleartext-password = %x00-FF

    salt = %x00-FF
      ]]></artwork></figure>
      <t>
        Field salt SHALL be treated as a randomely chosen sequence of bytes.
        The length of the salt SHOULD be at least 64 bits but other salt
        length MAY be recommended for specific hash algorithms.
        Implementations MUST be prepared of handling field salt of
        arbitrary length. salt MUST be empty for non-salted hashing
        schemes.
      </t>
      <t>
        The field hashandsalt is generated by concatening the field
        password-hash and the salt. The field password-hash is
        generated by calculating the digest over the concatenation of
        password followed by salt.
      </t>
      <t>
        b64-hashandsalt is generated by encoding hashandsalt according
        to the base64 algorithm as specified in <xref target="RFC4648"/>.
      </t>
      <t>
        The field scheme MUST be treated case-insensitive by all server
        and client implementations.  Applications SHALL handle prefix
        "x-" in scheme just like any other scheme value without this
        prefix <xref target="RFC6648"/>.  Other specifications MAY
        update this document by defining other values for scheme.
      </t>
      <texttable anchor="hash_schemes" title="Currently used hash schemes">
          <ttcol align='center'>prefix</ttcol>
          <ttcol align='center'>Description</ttcol>
          <ttcol align='center'>Algorithm reference</ttcol>
          <c>{MD5}</c><c>MD-5 without salt</c><c><xref target="RFC1321"/></c>
          <c>{SMD5}</c><c>salted MD-5</c><c><xref target="RFC1321"/></c>
          <c>{SHA}</c><c>SHA-1 without salt</c><c><xref target="FIPS-180-4"/></c>
          <c>{SSHA}</c><c>salted SHA-1</c><c><xref target="FIPS-180-4"/></c>
          <c>{SHA256}</c><c>SHA-256 without salt</c><c><xref target="FIPS-180-4"/></c>
          <c>{SSHA256}</c><c>salted SHA-256</c><c><xref target="FIPS-180-4"/></c>
          <c>{SHA384}</c><c>SHA-384 without salt</c><c><xref target="FIPS-180-4"/></c>
          <c>{SSHA384}</c><c>salted SHA-384</c><c><xref target="FIPS-180-4"/></c>
          <c>{SHA512}</c><c>SHA-512 without salt</c><c><xref target="FIPS-180-4"/></c>
          <c>{SSHA512}</c><c>salted SHA-512</c><c><xref target="FIPS-180-4"/></c>
          <!--postamble></postamble-->
      </texttable>

    </section>

    <section anchor="implementation_issues" title="Implementation Issues">
      <t>
        All implementations SHOULD prepare textual strings used as
        field password like described for clear-text storage in section 2.41
        in <xref target= "RFC4519"/> before deriving a hash value from
        them.  It is up to the implementation to determine what a
        textual password is.
      </t>
      <t>
        Hashed 'userPassword' values are only suitable for directly
        comparing it to a clear-text password.  They SHOULD NOT be used
        in challenge-response authentication schemes.
      </t>
      <t>
        It is clear from the syntax specification that distinguishing
        clear-text passwords and hashed passwords is somewhat ambigous
        which is a well-known deficiency of this approach.  Therefore
        implementing <xref target="RFC3112"/> is RECOMMENDED if a better
        solution is strictly required.
      </t>
      <t>
        Implementations SHALL first check whether a value stored in
        attribute 'userPassword' adheres to the syntax specified above.
        Syntax checking SHALL be implemented by checking hash and
        optional salt following the algorithm-specific rules.  Any value
        which do not adhere to this syntax MAY be treated as clear-text
        password by the DSA when processing a LDAP simple bind request
        or LDAP compare request.
      </t>
      <t>
        Servers MAY provide local configuration items to limit the set
        of hash schemes to be processed and for completely disabling
        use of clear-text passwords in attribute 'userPassword'.
      </t>
    </section>

    <section anchor="Acknowledgements" title="Acknowledgements">
      <t>
        The syntax definition for 'userPassword' values in this document
        is based on and supersedes the specification in section 5.3 of
        <xref target="RFC2307"/> by L. Howard.
      </t>
      <t>
        Some basics of the formal specification and security considerations
        are based on text in <xref target="RFC3112"/> by K. Zeilenga.
      </t>
    </section>

    <section anchor="IANA" title="IANA Considerations">
      <t>
        There are no identifiers defined herein to be reserved by IANA.
      </t>
    </section>

    <section anchor="Security" title="Security Considerations">
      <t>
        This document describes how authentication information may be
        stored in a directory.  Authentication information MUST be
        adequately protected as unintended disclosure will allow
        attackers to gain immediate access to the directory as described
        by <xref target="RFC2829"/>.
      </t>
      <t>
        Hashed values in attribute 'userPassword' SHOULD be protected as if 
        they were clear text passwords because they are subject to 
        dictionary or other attacks and flaws may be discovered in the hashing 
        algorithm or with a particular implementation of the algorithm.
      </t>
      <t>
        Especially it is RECOMMENDED to avoid using hashing schemes
        based on MD-5 because of known weaknesses of this digest algorithm
        <xref target="RFC6151"/>.
      </t>
      <t>
        Applications SHOULD NOT use the non-salted password hash schemes
        and SHOULD use a sufficiently long salt value.
      </t>
      <t>
        When values are transferred, privacy protections, such as IPSEC
        or TLS, SHOULD be in place.
      </t>
      <t>
        Clients SHOULD use stronger authentication mechanisms like
        defined in <xref target="RFC5802"/>.
      </t>
      <t>
        Servers SHOULD use stronger credential storage mechanisms like
        defined in <xref target="RFC5803"/>.
      </t>
      <t>
        Some password schemes may require CPU intensive operations.  Servers
        SHOULD take appropriate measures to protect against Denial of Service
        attacks.
      </t>
      <t>
        Using 'userPassword' attribute type description as defined in 
        <xref target="RFC4519"/> does not restrict an authentication 
        identity to a single password.  An attacker who gains write 
        access to this attribute may store additional values without 
        disabling the user's true password(s).
        If a server supports defining additional local constraints to 
        limit the count of attribute values it is RECOMMENDED to define 
        such a constraint for 'userPassword' values to be limited to one 
        without having to change the standard schema.
      </t>
      <t>
        Use of policy aware clients and servers is RECOMMENDED (see 
        example in <xref target="I-D.behera-ldap-password-policy"/>).
      </t>
      <t>
        The level of protection offered against various attacks differ from
        scheme to scheme.  It is RECOMMENDED that servers support scheme
        selection as a configuration item.  This allows for a scheme to be
        easily disabled if a significant security flaw is discovered.
      </t>

    </section>

  </middle>

  <back>

    <references title="Normative References">

      <reference
        anchor="FIPS-180-4"
        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 (NIST)
            </organization>
          </author>
          <date year="2012" month="March"></date>
        </front>
        <seriesInfo name="FIPS PUB" value="180-4"></seriesInfo>
      </reference>

      &RFC1321;
      &RFC2119;
      &RFC4510;
      &RFC4519;
      &RFC4648;

    </references>

    <references title="Informative References">

      &RFC2829;
      &RFC2307;
      &RFC3112;
      &RFC5802;
      &RFC5803;
      &RFC6151;
      &RFC6648;
      &I-D.behera-ldap-password-policy;
      &RFC4270;
      &I-D.hoffman-schneier-4270bis;

   </references>

  </back>

</rfc>
