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

Side by Side Diff: nss/lib/softoken/sftkhmac.c

Issue 1504923011: Update NSS to 3.21 RTM and NSPR to 4.11 RTM (Closed) Base URL: http://src.chromium.org/svn/trunk/deps/third_party/nss
Patch Set: Created 5 years 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* This Source Code Form is subject to the terms of the Mozilla Public 1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 4
5 #include "seccomon.h" 5 #include "seccomon.h"
6 #include "secerr.h" 6 #include "secerr.h"
7 #include "blapi.h" 7 #include "blapi.h"
8 #include "pkcs11i.h" 8 #include "pkcs11i.h"
9 #include "softoken.h" 9 #include "softoken.h"
10 #include "hmacct.h" 10 #include "hmacct.h"
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 memcpy(&ctx->header[j], params->pHeader, params->ulHeaderLen); 136 memcpy(&ctx->header[j], params->pHeader, params->ulHeaderLen);
137 137
138 return ctx; 138 return ctx;
139 139
140 loser: 140 loser:
141 PORT_Free(ctx); 141 PORT_Free(ctx);
142 return NULL; 142 return NULL;
143 } 143 }
144 144
145 void 145 void
146 sftk_HMACConstantTime_Update(void *pctx, void *data, unsigned int len) 146 sftk_HMACConstantTime_Update(void *pctx, const void *data, unsigned int len)
147 { 147 {
148 sftk_MACConstantTimeCtx *ctx = (sftk_MACConstantTimeCtx *) pctx; 148 sftk_MACConstantTimeCtx *ctx = (sftk_MACConstantTimeCtx *) pctx;
149 SECStatus rv = HMAC_ConstantTime( 149 PORT_CheckSuccess(HMAC_ConstantTime(
150 ctx->mac, NULL, sizeof(ctx->mac), 150 ctx->mac, NULL, sizeof(ctx->mac),
151 ctx->hash, 151 ctx->hash,
152 ctx->secret, ctx->secretLength, 152 ctx->secret, ctx->secretLength,
153 ctx->header, ctx->headerLength, 153 ctx->header, ctx->headerLength,
154 data, len, 154 data, len,
155 » ctx->totalLength); 155 » ctx->totalLength));
156 PORT_Assert(rv == SECSuccess);
157 } 156 }
158 157
159 void 158 void
160 sftk_SSLv3MACConstantTime_Update(void *pctx, void *data, unsigned int len) 159 sftk_SSLv3MACConstantTime_Update(void *pctx, const void *data, unsigned int len)
161 { 160 {
162 sftk_MACConstantTimeCtx *ctx = (sftk_MACConstantTimeCtx *) pctx; 161 sftk_MACConstantTimeCtx *ctx = (sftk_MACConstantTimeCtx *) pctx;
163 SECStatus rv = SSLv3_MAC_ConstantTime( 162 PORT_CheckSuccess(SSLv3_MAC_ConstantTime(
164 ctx->mac, NULL, sizeof(ctx->mac), 163 ctx->mac, NULL, sizeof(ctx->mac),
165 ctx->hash, 164 ctx->hash,
166 ctx->secret, ctx->secretLength, 165 ctx->secret, ctx->secretLength,
167 ctx->header, ctx->headerLength, 166 ctx->header, ctx->headerLength,
168 data, len, 167 data, len,
169 » ctx->totalLength); 168 » ctx->totalLength));
170 PORT_Assert(rv == SECSuccess);
171 } 169 }
172 170
173 void 171 void
174 sftk_MACConstantTime_EndHash(void *pctx, void *out, unsigned int *outLength, 172 sftk_MACConstantTime_EndHash(void *pctx, void *out, unsigned int *outLength,
175 unsigned int maxLength) 173 unsigned int maxLength)
176 { 174 {
177 const sftk_MACConstantTimeCtx *ctx = (sftk_MACConstantTimeCtx *) pctx; 175 const sftk_MACConstantTimeCtx *ctx = (sftk_MACConstantTimeCtx *) pctx;
178 unsigned int toCopy = ctx->hash->length; 176 unsigned int toCopy = ctx->hash->length;
179 if (toCopy > maxLength) { 177 if (toCopy > maxLength) {
180 toCopy = maxLength; 178 toCopy = maxLength;
181 } 179 }
182 memcpy(out, ctx->mac, toCopy); 180 memcpy(out, ctx->mac, toCopy);
183 if (outLength) { 181 if (outLength) {
184 *outLength = toCopy; 182 *outLength = toCopy;
185 } 183 }
186 } 184 }
187 185
188 void 186 void
189 sftk_MACConstantTime_DestroyContext(void *pctx, PRBool free) 187 sftk_MACConstantTime_DestroyContext(void *pctx, PRBool free)
190 { 188 {
191 PORT_Free(pctx); 189 PORT_Free(pctx);
192 } 190 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698