Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1413)

Unified Diff: net/third_party/nss/ssl/sslinfo.c

Issue 9663043: Add a boolean |had_context| argument to the TLS ExportKeyingMaterial (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Make suggested changes, add patch file Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/third_party/nss/ssl/sslinfo.c
===================================================================
--- net/third_party/nss/ssl/sslinfo.c (revision 126517)
+++ net/third_party/nss/ssl/sslinfo.c (working copy)
@@ -317,18 +317,12 @@
return PR_FALSE;
}
-/* Export keying material according to RFC 5705.
-** fd must correspond to a TLS 1.0 or higher socket, out must
-** be already allocated.
-*/
SECStatus
SSL_ExportKeyingMaterial(PRFileDesc *fd,
- const char *label,
- unsigned int labelLen,
- const unsigned char *context,
- unsigned int contextLen,
- unsigned char *out,
- unsigned int outLen)
+ const char *label, unsigned int labelLen,
+ PRBool hasContext,
+ const unsigned char *context, unsigned int contextLen,
+ unsigned char *out, unsigned int outLen)
{
sslSocket *ss;
unsigned char *val = NULL;
@@ -347,18 +341,21 @@
return SECFailure;
}
+ /* construct PRF arguments */
valLen = SSL3_RANDOM_LENGTH * 2;
- if (contextLen > 0)
+ if (hasContext) {
valLen += 2 /* uint16 length */ + contextLen;
+ }
val = PORT_Alloc(valLen);
- if (val == NULL)
+ if (!val) {
return SECFailure;
+ }
i = 0;
PORT_Memcpy(val + i, &ss->ssl3.hs.client_random.rand, SSL3_RANDOM_LENGTH);
i += SSL3_RANDOM_LENGTH;
PORT_Memcpy(val + i, &ss->ssl3.hs.server_random.rand, SSL3_RANDOM_LENGTH);
i += SSL3_RANDOM_LENGTH;
- if (contextLen > 0) {
+ if (hasContext) {
val[i++] = contextLen >> 8;
val[i++] = contextLen;
PORT_Memcpy(val + i, context, contextLen);
@@ -366,6 +363,9 @@
}
PORT_Assert(i == valLen);
+ /* Allow TLS keying material to be exported sooner, when the master
+ * secret is available and we have sent ChangeCipherSpec.
+ */
ssl_GetSpecReadLock(ss);
if (!ss->ssl3.cwSpec->master_secret && !ss->ssl3.cwSpec->msItem.len) {
PORT_SetError(SSL_ERROR_HANDSHAKE_NOT_COMPLETED);

Powered by Google App Engine
This is Rietveld 408576698