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

Unified Diff: nss/lib/softoken/tlsprf.c

Issue 23510003: Implement the TLS 1.2 mechanisms for PKCS #11. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/nss/
Patch Set: Allow CKM_TLS12_MAC to use the TLS 1.0 and 1.1 PRF Created 7 years, 3 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
« no previous file with comments | « nss/lib/softoken/pkcs11i.h ('k') | nss/lib/util/pkcs11t.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: nss/lib/softoken/tlsprf.c
===================================================================
--- nss/lib/softoken/tlsprf.c (revision 209026)
+++ nss/lib/softoken/tlsprf.c (working copy)
@@ -6,6 +6,7 @@
#include "pkcs11i.h"
#include "blapi.h"
+#include "secerr.h"
#define SFTK_OFFSETOF(str, memb) ((PRPtrdiff)(&(((str *)0)->memb)))
@@ -23,6 +24,7 @@
SECStatus cxRv; /* records failure of void functions. */
PRBool cxIsFIPS; /* true if conforming to FIPS 198. */
HASH_HashType cxHashAlg; /* hash algorithm to use for TLS 1.2+ */
+ unsigned int cxOutLen; /* bytes of output if nonzero */
unsigned char cxBuf[512]; /* actual size may be larger than 512. */
} TLSPRFContext;
@@ -87,7 +89,14 @@
seedItem.len = cx->cxDataLen;
sigItem.data = sig;
- sigItem.len = maxLen;
+ if (cx->cxOutLen == 0) {
+ sigItem.len = maxLen;
+ } else if (cx->cxOutLen <= maxLen) {
+ sigItem.len = cx->cxOutLen;
+ } else {
+ PORT_SetError(SEC_ERROR_OUTPUT_LEN);
+ return SECFailure;
+ }
if (cx->cxHashAlg != HASH_AlgNULL) {
rv = TLS_P_hash(cx->cxHashAlg, &secretItem, NULL, &seedItem, &sigItem,
@@ -142,7 +151,8 @@
sftk_TLSPRFInit(SFTKSessionContext *context,
SFTKObject * key,
CK_KEY_TYPE key_type,
- HASH_HashType hash_alg)
+ HASH_HashType hash_alg,
+ unsigned int out_len)
{
SFTKAttribute * keyVal;
TLSPRFContext * prf_cx;
@@ -169,6 +179,7 @@
prf_cx->cxIsFIPS = (key->slot->slotID == FIPS_SLOT_ID);
prf_cx->cxBufPtr = prf_cx->cxBuf;
prf_cx->cxHashAlg = hash_alg;
+ prf_cx->cxOutLen = out_len;
if (keySize)
PORT_Memcpy(prf_cx->cxBufPtr, keyVal->attrib.pValue, keySize);
« no previous file with comments | « nss/lib/softoken/pkcs11i.h ('k') | nss/lib/util/pkcs11t.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698