Subject: [TLS] About the key block generation for different ciphers.

From: nilesh <[email-masked]>
Date: Tue, 04 Oct 2011 17:08:37 +0530

Hi,

In case of SSL/TLS we generate the master_secret and then the key_block.
The size of the key block depends upon the cipher suit that is negotiated.

Do we have any reference where I can understand the fields in key_block?

E.g. I could identify that
For AES_256_CBC_SHA we need - 2 * 32 bytes of keys and 2 * 20 bytes of MAC.
For 3DES_EDE_CBC_SHA we need - 2 * 24bytes of keys, 2 * 20bytes of MAC 
and 2 * 8bytes of IV.

So based on the above information I can generate 104bytes of key_block 
for these ciphers and extract the required keys.
So for AES_256_CBC_SHA-
key_block[0..19] - MAC for client, key_block[20..39] - MAC for server.
key_block[40..71] - client write key and key_block[72..104] - server 
write key.

Could someone please advice any reference on how to get the key_block 
details for a give cipher suit?

-- 
Thanks,
Nilesh

---

From: Marsh Ray <[email-masked]>
Date: Tue, 04 Oct 2011 10:07:25 -0500

http://tools.ietf.org/html/rfc2246 TLS 1.0:
> 6.3. Key calculation
...
> Then the key_block is
>    partitioned as follows:
>
>        client_write_MAC_secret[SecurityParameters.hash_size]
>        server_write_MAC_secret[SecurityParameters.hash_size]
>        client_write_key[SecurityParameters.key_material_length]
>        server_write_key[SecurityParameters.key_material_length]
>        client_write_IV[SecurityParameters.IV_size]
>        server_write_IV[SecurityParameters.IV_size]
>
>    The client_write_IV and server_write_IV are only generated for non-
>    export block ciphers. For exportable block ciphers, the
>    initialization vectors are generated later, as described below. Any
>    extra key_block material is discarded.

- Marsh

---

From: nilesh <[email-masked]>
Date: Wed, 05 Oct 2011 11:45:24 +0530

>> extra key_block material is discarded.

Thanks. I had gone through that, but couldn't really get reference to 
the cipher suites with the key length.
Attached is the file what I was exactly looking for.

Thanks to Joshua Davies for the compilation.

-- 
Thanks,
Nilesh

---

From: Marsh Ray <[email-masked]>
Date: Wed, 05 Oct 2011 09:03:03 -0500

> [Cipher suit, digest size, key length, IV size]
> TLS_RSA_WITH_AES_256_CBC_SHA, 16, 32, 5 * sizeof(int)

No way that could be right.

But you have a software problem at this point, which is not so relevant 
for the TLS WG. (Ping me off-list if you need a hint :-)

- Marsh