<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
<!ENTITY rfc2119 PUBLIC '' 
'http://www2.xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml'>
<!ENTITY rfc2104 PUBLIC '' 
'http://www2.xml.resource.org/public/rfc/bibxml/reference.RFC.2104.xml'>
<!ENTITY rfc4346 PUBLIC '' 
'http://www2.xml.resource.org/public/rfc/bibxml/reference.RFC.4346.xml'>
<!ENTITY rfc4493 PUBLIC '' 
'http://www2.xml.resource.org/public/rfc/bibxml/reference.RFC.4493.xml'>
<!ENTITY rfc3797 PUBLIC '' 
'http://www2.xml.resource.org/public/rfc/bibxml/reference.RFC.3797.xml'>

<!ENTITY rfc5078 PUBLIC '' 
'http://www2.xml.resource.org/public/rfc/bibxml/reference.RFC.5078.xml'>
<!ENTITY rfc5246 PUBLIC '' 
'http://www2.xml.resource.org/public/rfc/bibxml/reference.RFC.5246.xml'>
<!ENTITY rfc6859 PUBLIC '' 
'http://www2.xml.resource.org/public/rfc/bibxml/reference.RFC.6859.xml'>
]>

<rfc category="info" ipr="trust200902" 
     docName="draft-stjohns-tls-tls13-crypto-infra-00">

  <?xml-stylesheet type='text/xsl' href='rfc2629.xslt' ?>

  <?rfc toc="yes" ?>
  <?rfc symrefs="yes" ?>
  <?rfc sortrefs="yes"?>
  <?rfc iprnotified="no" ?>
  <?rfc strict="yes" ?>
  <?rfc compact="yes"?>
  <?rfc subcompact="no"?>

  <front>
    <title>TLS Crypto Constructs for Version 1.3</title>
    <author initials='M' surname="StJohns" fullname='Michael C StJohns'>
      <organization/>
      <address>
	<email>msj@nthpermutation.com</email>
      </address>
    </author>
    <date/>
    <abstract>
      <t>
	This document describes a set of replacements for the
	TLS cryptographic constructs for use with TLS1.3 and
	later.  The constructs used in versions of TLS 1.2 and prior
	have some issues with respect to secure implementation using
	generic security hardware.
      </t>
    </abstract>
  </front>
  <middle>
    <section title="Introduction" anchor="intro">
      <t>
	This document describes a set of replacements for the TLS1.2
	and earlier cryptographic constructs. Those constructs were
	based on the concept of a PRF or pseudo-random function.  The
	new constructs still use a single core function per
	connection, but describe the mappings between that core
	function and the actual TLS usages slightly differently.
      </t>
      <t>
	This text is meant to be contributed text or concepts for the
	next TLS specification version rather than a stand-alone
	standard.  As such it's submitted primarily for publication as
	an internet draft but may be published as an Informational RFC
	depending on the timing of the TLS1.3 work.  No attempt has
	been made to provide specific edits to the existing TLS1.2
	specifications. 
      </t>
      <section title="Rationale">
	<t>
	  Although never described as such in the original TLS
	  documents, there are three standard cryptographic constructs
	  used for different purposes in the TLS protocol negotiation:
	  <list>
	    <t>
	      A key derivation function or KDF.  This is used to derive
	      the master secret from the pre-master secret, and to
	      derive the session keys from the master secret.  In
	      TLS1.2 and before this was described as the key
	      expansion function.
	    </t>
	    <t>
	      A message authentication function or MAC.  This is the
	      keyed MAC function used to sign the "finished" messages
	      during protocol negotiation, and shouldn't be confused
	      with the MAC function (if any) used to protect the
	      record message traffic.  In TLS1.2 and prior, this used
	      the TLS PRF with a specific set of labels and with the
	      master key used as the key to produce the Finished
	      message verify_data tag.
	    </t>
	    <t>
	      A well-known pseudo-random data generator (PRDG).  This
	      is used to provided data for initialization vectors
	      (IV).  In TLS1.2 and before, this was done as part of
	      the derivation of the session keys and was based on the
	      master secret.
	    </t>
	  </list>
	</t>
	<t>
	  As defined in TLS1.2 (<xref target="RFC5246"/>) and before
	  (<xref target="RFC4346"/> and others),  these functions were
	  based on the TLS-PRF function.  Because of the way they were
	  defined, and given the specific uses of various TLS keys, it was
	  difficult or impossible to implement these functions securely
	  in general purpose hardware security modules.  It was
	  trivially easy to extract session key material.
	  <list style="symbols">
	    <t>
	      The TLS master secret was used both as a master key, and
	      as a key for the MAC function.  Since both functions
	      were defined in terms of the underlying PRF, and the MAC
	      function produced public data, while the KDF function
	      produced private data, it was trivially easy to use the
	      MAC function to reproduce the private key stream as
	      public data.
	    </t>
	    <t>
	      The key expansion of the master secret to traffic keys
	      included the production of IV material.  By cryptographic
	      convention, IV data is considered public data, so the key
	      derivation function was producing both public and private
	      data.  By varying the length of the requested private key
	      material, it was possible to leak the key stream data into
	      the produced IVs.
	    </t>
	  </list>
	</t>
      </section>
      <section title="Changes from TLS 1.2">
	<t>
	  This document makes a few changes in the way keys are used and
	  derived:
	  <list style="symbols">
	    <t>
	      A single key can't be used to produce both public and
	      private data.
	    </t>
	    <t>
	      A single key can't be used for multiple purposes. 
	      Each TLS key is typed, and can only be used
	      with specific cryptographic constructs appropriate for its
	      type.  To accomplish this, the master secret is no longer
	      used as a negotiation MAC key.  Instead, an additional key is
	      derived from the premaster secret specifically as a
	      negotiation MAC key.
	    </t>
	    <t>
	      The KDF (aka "key expansion") has
	      been modified to be sensitive of the length and types of
	      keys to be produced.  If any of these input values change, the
	      underlying key stream changes completely.  This in turn causes 
	      all of the individual keys extracted from that key
	      stream to also change.
	    </t>

	    <t>
	      Labels used for the KDF or for the pseudo-random data
	      function may be any stream of bytes, not just those
	      derived from ASCII strings.
	    </t>
	    <t>
	      IV's - if required by the cryptographic suite - are no
	      longer produced as part of a key derivation
	      step. Specifically, the 'master secret' expansion no
	      longer produces either the 'client write IV' or the
	      'server write IV'.  Instead, the IVs are produced using an
	      un-keyed well-known psuedo-random function using the
	      client and server random bytes as seed material.
	    </t> 
	  </list>
	</t>
      </section>
    </section>
    <section title="Key Hierachy">
      <section title="Key Types">
	<figure>
	  <preamble>
	  For the purposes of providing cryptographic separation of
	  key material, each of the keys used within TLS are given a
	  defined type.  These type values are used as input to the Key
	  Deriviation or expansion processing.
	  </preamble>
	  <artwork>
enum { masterKey (1), integrityKey(2), 
       encryptionKey(4), aeadKey (6) } KeyType;
	  </artwork>
	</figure>
	<t>

	  <list style="hanging">
	    <t hangText="masterKey: ">
	      A master key may only be used with the KDF cryptographic
	      construct.  It is only used as a source of key material
	      to produce subordinate keys. For TLS1.3, the only master
	      keys are the 'premaster' secret and the 'master' secret
	      derived from the premaster.
	    </t>
	    <t hangText="integrityKey: ">
	      An integrity key may only be used
	      with a Keyed Message Authentication construct. These include
	      the HMAC and CMAC constructs. 
	    </t>
	    <t hangText="encryptionKey: ">
	      An encryption key may only be
	      used with an encryption mode construct that isn't also
	      an AEAD construct.
	    </t>
	    <t hangText="aeadKey: ">
	      An AEAD (Authenticated Encryption with Associated Data)
	      key may only be used with an AEAD encyption construct.
	      These include CCM and GCM.  This type was added specifically to
	      cryptographically isolate keys used for encryption modes
	      from keys used for AEAD modes derived from or based on
	      plain encryption modes.  For example, AES-CCM mode uses
	      the exact same encryption/decryption logic as AES-CTR
	      but add a CMAC integrity check.  Without this isolation,
	      it is trivial to defeat the policy constraints on CCM
	      that prohibit release of decrypted data before the
	      integrity tag is verified.
	    </t>
	  </list> 
	  Note that a block cipher key (e.g. AES) can be typed as any
	  of Integrity (e.g. CMAC), Encryption or AEAD depending on its actual use.
	</t>
      </section>
      <section title="Keys Derived from the 'premaster' Secret">
	<t>
	  The following keys are derived from the premaster secret:
	  <list style="hanging">
	    <t hangText="master secret: ">
	      This is the key used to derive session keys for use with
	      a specific protocol suite. It is always typed as a masterKey.
	    </t>
	    <t hangText="negotiation mac key: ">
	      This is the key used with the negotiation MAC function
	      to produce the "verify_data" used with the Finished
	      message.  It is always typed as an integrityKey.
	    </t>
	  </list>
	</t>
	<t>
	  The master secret is always 48 bytes (384 bits) in length.  The
	  negotiation mac key is always 32 bytes (256 bits) in
	  length. [Discussion:  Alternately, the mac key is always the native
	  length of the selected PRF to avoid the impedence match
	  function?] 
	</t>
      </section>
      <section title="Keys Derived from the 'master' Secret">
	<t>
	  The following keys are derived from the master secret.
	  Depending on the needs of the selected cipher suite, some of
	  these keys may not need to derived.
	  <list style="symbols">
	    <t>
	      client write MAC key
	    </t>
	    <t>
	      server write MAC key
	    </t>
	    <t>
	      client write encryption key
	    </t>
	    <t>
	      server write encryption key
	    </t>
	  </list>
	</t>
	<t>
	  The lengths of these keys vary per cipher suite. The types of
	  the 'client write MAC key' and the 'server write MAC key' are
	  always Integrity Key (0x02).  The types of the 'client write
	  encryption key' and 'server write encryption key' are either
	  Encryption Key (0x04) or AEAD key (0x06).
	</t>
	<t>
	  If a key is not required for the cipher suite, it is omitted
	  from the derivation step.  There is no placeholder of a zero
	  length key.
	</t>
      </section>
    </section> 
    <section title="Cryptographic Constructs">
      <section title="Negotiated Pseudo-Random Function">
	<t>
	  The negotiated (SecurityParameters.prf_algorithm)
	  pseudo-random function or PRF is either an HMAC function or
	  CMAC function. If unspecified, HMAC-SHA256 shall be used.
	</t>
	<t>
	  The HMAC construct is based on an underlying non-invertable
	  hash or summary function and is formed as per <xref
	  target="RFC2104"/> or <xref target="FIPS198"/>.
	</t>
	<t>
	  The CMAC construct is based on an underlying block cipher
	  and is formed as per <xref target="RFC4493"/> or <xref
	  target="SP800-38B"/>.
	</t>
	<section title="CMAC Key Impedence Matching">
	  <t>
	    The generic CMAC construct as defined in <xref
	    target="SP800-38B"/> requires a specific key size based on
	    the underlying block cipher.  Unlike the HMAC
	    specification documents, neither of the CMAC specification
	    documents describe a way to take a key of any length and
	    adapt it for use it with CMAC.  TLS will use the mechanism
	    suggested in <xref target="SP800-56C"/> 
	    <eref
	    target="http://csrc.nist.gov/publications/nistpubs/800-56C/SP-800-56C.pdf">(Key
	    Derivation through Extraction-then-Expansion)</eref>,
	    for adapting keys
	    of any length to output a CMAC key. Using the approach in
	    section 5 of <xref target="SP800-56C"/>, and using an all
	    '0's salt, convert the input key to a key of the
	    appropriate size for the CMAC function. Process:
	    <list style="numbers">
	      <t>
		Set K to input key.
	      </t>
	      <t>
		If length(K) is equal to length of CMAC output, return K.
	      </t>
	      <t>
		Set K equal to CMAC ('0', K);
	      </t>
	      <t>
		Return K.
	      </t>
	    </list>
	  </t>
	</section>
      </section>
      <section title="Key Derivation Function (KDF)" anchor="kdf">
	<t>
	  The key derivation function (KDF) used for TLS1.3 and later
	  is the function described in section 5.1 of <xref target="SP800-108"/>
	  (<eref
	       target="http://csrc.nist.gov/publications/nistpubs/800-108/sp800-108.pdf">
	     Key Derivation Using Pseudorandom Functions</eref>),
	     - "KDF in Counter Mode".  This KDF construct is
	  able to produce any amount of key material by using an
	  incrementing counter, a master key, and some amount of input
	  public data (e.g. the label, client and server random, etc)
	  to produce multiple blocks of pseudo-random data which are
	  concatenated to produce the key data stream.
	</t>
	<figure>
	  <artwork>
KDF (key, label, context, bitsToGenerate) ::=
    KDF-SP800-108-51 (key, label, context, bitsToGenerate);
	  </artwork>
	</figure>
	<t>
	  The KDF construct allows the derivation of any amount of
	  random data.  It is generally used to generate additional key
	  material.  When used with the 'KeyExpansionContext' Context
	  construct, it has the property that any change in the
	  number, type or length of the keys to be derived completely
	  changes the output key stream.
	</t>
	<t>
	  See <xref target="premasterex"/>, <xref target="premasterex"
	  format="title"/> and <xref target="masterex"/>, <xref
	  target="masterex" format="title"/> for the specific orders
	  in which keys are derived for each usage.  By convention,
	  master keys are derived first, then MAC keys, and then
	  encryption or AEAD keys.  Within the type of keys, client
	  write keys are derived before server write keys.
	</t> 
	<t>
	  The general calling form for this KDF is:
	  <list>
	    <t>
	      K sub O := KDF (K sub I, Label, Context, L)
	    </t>
	   
	  </list>
	</t>
	<t>
	   Where 'K sub O' is the output key stream.  The remainder of the
	   fields are described below in <xref target="keystreamSegProd"/>.
	</t>
	<t>
	  If 'K sub I' is private data (e.g. typed as a masterSecret),
	  then the output 'K sub O' is also private data.  Otherwise,
	  if 'K sub I' is public data (e.g. for use below at <xref
	  target="prdg"/> in the PRDG), then the output 'K sub O' is
	  also public data.
	</t>
	<t>
	  If the construct is being used to produce key material
	  (e.g. with the KeyExpansionContext and a secret key), the
	  output keys are formed by producing multiple blocks of key
	  stream, concatenating them, and then splitting up the key
	  stream in to key data of the appropriate lengths for each
	  derived key.  Otherwise, K sub O may be broken up as
	  desired for the usage.
	</t>
	<t>
	  Although this construct permits the production of fractional
	  byte (e.g. 12 bit) keys, there are no current TLS keys
	  defined with fractional byte lengths.
	</t>
	<section title="Producing One Segment of the Key Stream"
		 anchor="keystreamSegProd">
	  <t>
	    Each pseudo-random key stream block 'K(i)' is produced using the function:
	    <list>
	      <t>
		K(i) := PRF (K sub I, i || Label || 0x00 || Context || L)
	      </t>
	    </list>
	  </t>
	  <t>
	    The values for each input variable (described in step 4.a of section 5.1 of <xref
	    target="SP800-108"/>) are mapped as follows:

		<list style="hanging">
		  <t hangText="PRF: ">
		    The negotiated TLS1.3 PRF function, generally either
		    an HMAC or CMAC function.
		  </t>
		  <t hangText="K sub I: ">
		    The input master key for this key derivation. For TLS
		    this is generally either the 'master secret' or
		    'premaster secret'.
		  </t>
		  <t hangText="i: ">
		    The iteration count represented as a uint32. This
		    is initialized to '1' for the first block of key
		    material and incremented for each subsequent
		    block.
		  </t>
		  <t hangText="Label: ">
		    A string of bytes used to describe the specific use
		    of the output of this derivation.  For TLS this is
		    usually the ASCII encoding of either "premaster" or
		    "master secret", but could be anything if this
		    construct is used for key exporters.
		  </t>
		  <t hangText="Context: ">
		    A string of bytes used to differentiate this call to
		    the KDF from all other calls. 
		  </t>
		  <t hangText="L: ">
		    The uint32 length in bits of the key stream being
		    produced during this derivation.  For TLS, this is
		    always the sum of the sizes of the keys being
		    produced from this derivation.  E.g. for the
		    "premaster" derivation, this is the sum of 48*8 or
		    384 bits (the
		    length of the TLS master secret) and 32*8 or 256 bits (the
		    length of the negotiation mac key) or 80*8 of 640 bits.
		  </t>
		</list>
	      </t>
	  <t>
	    <figure>
	      <preamble>
		The specific Context construct used depends on what
		the KDF function is being used for.  The
		GenericContext may be used for key exporters and other
		to-be-defined usages.  The KeyExpansionContext is used
		for the expansion of keys typed as masterKey,
		including the pre-master secret and the expansion of
		the master secret.  The RandomBitContext is used for
		the generation of public unpredictable data such as
		IV's.
	      </preamble>
	      <artwork>
enum { generic, expansion, randomBits } ContextTag;

struct {
    opaque contextBytes;
} GenericContext; 

struct { 
    uint8    clientRandom[32];      /* ClientHello.random */
    uint8    serverRandom[32];      /* ServerHello.random */
    uint32   keyCount;              /* Num keys to derive */
    KeyType  keyTypes[keycount];  
    uint16   keyLengths[keycount];  /* Key lengths in bits */
} KeyExpansionContext;

struct {
    uint8    clientRandom[32];
    uint8    serverRandom[32];
} RandomBitContext;

struct {
    select (ContextTag) { /* implicit selection */
        case generic:
          GenericContext;
        case expansion:
          KeyExpansionContext;
        case randomBits:
          RandomBitContext;
    };
} Context;
	      </artwork>
	      <postamble>
		The clientRandom and serverRandom are the bytes
		provided by the ClientHello.random and
		ServerHello.random fields respectively.  KeyCount is the
		number of keys being derived with this call to the
		KDF. KeyTypes contains the types of keys being
		derived, and KeyLengths the matching lengths for those
		keys in bits.
	      </postamble>
	    </figure>
	  </t>
	</section>
	<section title="Producing the Key Stream" anchor="keystreamProd">
	  <figure>
	    <preamble>
	      The output stream,  K sub O, is produced by concatenating
	      all of the K(i) outputs and then truncating to length
	      L.  There are CEIL(L/prfBlockSize) K(i) output blocks
	      where 'prfBlockSize' is the output size of the PRF in bits:
	    </preamble>
	    <artwork>
K sub O := 
    KDF (K sub I, Label, Context, L)
        := PRF (K sub I, 1 || Label || 0x00 || Context || L)
           PRF (K sub I, 2 || Label || 0x00 || Context || L) + 
           PRF (K sub I, 3 || Label || 0x00 || Context || L) + ...
              [0..CEIL(L/8)]
	    </artwork>

	  </figure>
      </section> 

      <section title="Key Stream to Keys Conversion">
	<figure>
	  <preamble>
	    If the desired output is keys, then K sub O is then broken
	    up into the component keys.  The following example assumes
	    key that have bit lengths that are all multiples of 8.
	  </preamble>
	  <artwork>
pos := 0
Key[0] := K sub O[pos..pos+keyLength[0]/8-1]
pos := pos + keyLength[0]
Key[1] := K sub O[pos..pos+keyLength[1]/8-1]
pos := pos + KeyLength[1]
Key[2] := K sub O[pos..pos+keyLength[2]/8-1]
pos := pos + KeyLength[2]
...
	  </artwork>
	</figure>
      </section>
    </section>
    <section title="Keyed Message Authentication Functions">
      <t>
	The keyed message authentication function (MAC) is the negotiated
	CMAC or HMAC PRF function used as is. 
      </t>
      <figure>
	<artwork>
MAC (key, data) ::= PRF (key, data);
	</artwork>
      </figure>
      <t>
	See <xref
	target="finishedex"/>,
	<xref target="finishedex" format="title"/>
	for the how this function is used to produce the Finished
	message verify_data.
      </t>
    </section>
    <section title="Pseudo-random Data Generator Function (PRDG)" anchor="prdg">
      <t>
	The pseudo-random data generator function uses the  KDF
	construct described at <xref target="kdf"/> above, but uses a
	zero key.
      </t>
      <figure>
	<artwork>
PRDG (label, context, bytesNeeded) ::=  
    KDF ( '0', label, context, bytesNeeded*8)
	</artwork>
      </figure>
      <t>
	where:
	<list style="hanging">
	  <t hangText="'0': ">
	    '0' is a key consisting of a bit stream of '0's equal in
	    length to the natural key length of the underlying PRF
	    function.  E.g. 128 bits if the underlying PRF
	    function is AES-CMAC-128.
	  </t>
	  <t hangText="label: ">
	    A byte stream which identifies the general use of the
	    bits output from this call to the DBRG.  For example,
	    this is "clientAndServerIV" expressed as ASCII bytes
	    when used to derive a stream of bytes used for IVs.
	  </t>
	  <t hangText="context: ">
	    A byte stream used diversify this generation of bytes
	    from all others. If not otherwise specified, this is the
	    RandomBitContext structure defined above in <xref target="keystreamSegProd"/>.
	  </t>
	  <t hangText="bytesNeeded: ">
	    The number of bytes needed as output from this call to
	    the DBRG.
	  </t>
	</list>
	
      </t>
      <t>
	See <xref target="ivex"/>, <xref target="ivex" format="title"/> 
	for how to use this function to produce IV
	material if required.
      </t>
    </section>
  </section>
  <section title="TLS 1.3 Usages">
    <t>
      This section describes the proposed TLS 1.3 changes to key derivation,
      IV production and Finished message signatures.
    </t>
    <section title="Premaster Secret Expansion" anchor="premasterex">
      <figure>
	<preamble>
	    The expansion of the pre-master secret always results in
	    two keys: the master secret and the negotiation MAC key.
	    The master secret has been defined since the first version
	    of TLS (and its predecessor SSL).  The derivation of the
	    negoiation MAC key is new with this version.
	</preamble>
	<artwork>
KeyType keytypes[2] = { masterKey, integrityKey };
uint16 keylengths[2] = { 384, 256 };
KeyExpansionContext context = 
                  { ClientHello.random,
                    ServerHellow.random,
                    2, keytypes, keylengths };    

key_block = KDF (pre_master_secret, "master secret v2", 
                 context, 640);

master_secret = key_block[0..47];

negotiation_mac_key = key_block[48..79];
	</artwork>
      </figure>

    </section>
    <section title="Master Secret Expansion" anchor="masterex">
      <t>
	There are three cases for master key expansion: integrity
	only, integrity plus encryption, and finally AEAD.  Integrity
	only modes need 2 MAC keys, integrity plus encryption modes
	need 2 MAC keys plus two encryption keys for a total of 4
	keys, and finally AEAD modes need 2 encryption keys.
      </t>
      <figure>
	<preamble>
	  Only the AEAD case is expanded below. N.B., if a key is not
	  needed for a suite - such as integrity keys for AEAD, those
	  keys are neither derived nor requested.  While the general
	  use case of this function is to generate session keys for
	  TLS, it may be used by key exporters to generate any number
	  of keys of any type simply by changing the request parameters.
	</preamble>
	<artwork>
/* Parameters for AEAD key derivation */
KeyType aeadTypes[2] = { aeadKey, aeadKey };

uint16 aeadLengths[2] =
    { SecurityParameters.enc_key_length * 8,
      SecurityParameters.enc_key_length * 8 };

uint32 aeadL = 2 * 
      SecurityParameters.enc_key_length * 8;

KeyExpansionContext aeadContext = 
                  { ClientHello.random,
                    ServerHellow.random,
                    2, aeadTypes, aeadLengths }; 

/* Substitute the approriate context and L from above eg */
key_block = KDF (master_secret, "key expansion v2", 
                aeadContext, aeadL);

/* And then break it down into keys */
client_write_key = 
     key_block[0..SecurityParameters.enc_key_length-1];

server_write_key =
     key_block[SecurityParameters.enc_key_length..
             2*SecurityParameters.enc_key_length-1];

	</artwork>
      </figure>
    </section>
    <section title="Finished Message" anchor="finishedex">
      <t>
	The following replaces the definition of "verify_data" in
	section 7.4.9 of <xref target="RFC5246"/>.
      </t>
      <figure>
	<artwork>
verify_data
    MAC (negotiation_mac_key, finished_label + handshake_messages)
        [0..verify_data_length-1];
	</artwork>
      </figure>
      <t>
	Prior versions of TLS used a hash of the handshake messages as
	input to the TLS PRF.  It's unclear there was any added
	security benefit to that approach after the PRF was changed to
	remove MD5.  For this version, the handshake messages are
	input without hashing to the CMAC or HMAC function
	represented by the PRF.
      </t>
    </section>
    <section title="IV Generation" anchor="ivex">
      <figure>
	<preamble>
	  If necessary for the cryptosuite, the IV data is produced as follows:
	</preamble>
	<artwork>
RandomBitContext context = 
   { ClientHello.random,
     ServerHello.random };

iv_data = PRDG ("clientAndServerIV", context,
                2* SecurityParameters.fixed_iv_length * 8);
	</artwork>
      </figure>
      <figure>
	<preamble>
	  Then, iv_data is partitioned as follows:
	</preamble>
	<artwork>
client_write_IV[SecurityParameters.fixed_iv_length];
server_write_IV[SecurityParameters.fixed_iv_length];
	</artwork>
      </figure>
    </section>
  </section>

  </middle>
  <back>

    <references title="Normative References">
      <reference anchor="SP800-108" target="http://csrc.nist.gov/publications/nistpubs/800-108/sp800-108.pdf">
	<front>
	  <title>
	    Recommendation for Key Derivation Using Pseudorandom
	    Functions
	  </title>
	  <author>
	    <organization>National Institute of Standards and
	    Technology</organization>
	  </author>
	  <date month="October" year="2009"/>
	</front>
	<seriesInfo name="NIST Special Publication" value="800-108"/>
	<format type='PDF' target='http://csrc.nist.gov/publications/nistpubs/800-108/sp800-108.pdf'/>
      </reference>
      <reference anchor="SP800-38B">
	<front>

	  <title>
	    Recommendation for Block Cipher Modes of Operation: The
	    CMAC Mode for Authentication
	  </title>
	  <author>
	    <organization>National Institute of Standards and
	    Technology</organization>
	  </author>
	  <date month="May" year="2005"/>
	</front>
	<seriesInfo name="NIST Special Publication" value="800-38B"/>
      </reference>
      <reference anchor="SP800-56C">
	<front>
	  <title>
	    Recommendation for Key Derivation through Extraction-then-Expansion
	  </title>
	  <author>
	    <organization>National Institute of Standards and
	    Technology</organization>
	  </author>
	  <date month="May" year="2005"/>
	</front>
	<seriesInfo name="NIST Special Publication" value="800-56C"/>
      </reference>
      <reference anchor="FIPS198">
	<front>
	  <title>
	    The Keyed-Hash Message Authentication Code (HMAC)
	  </title>
	  <author>
	    <organization>National Institute of Standards and
	    Technology</organization>
	  </author>
	  <date month="July" year="2008"/>
	</front>
	<seriesInfo name="Federal Information Processing Standards
			  Publication"
		    value="198-1"/>
      </reference>
      <!--      <reference anchor="SP800-90A">
	   <front>
	   <title>
	   Recommendations for Random Number Generation using
	   Deterministic Random Bit Generators
	   </title>
	   <author>
	   <organization>
	   National Institute of Standards and
	   Technology
	   </organization>
	   </author>
	   <date month="January" year="2009"/>
	   </front>
	   <seriesInfo name="NIST Special Publication" value="800-90A"/>
	   </reference> -->
      &rfc2104;
      &rfc4346;
      &rfc4493;
      &rfc5246; 
    </references>
    <section title="Test Vectors">
      <t>
	To be provided.
      </t>
    </section>
  </back>
</rfc>
