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

Side by Side Diff: content/renderer/webcrypto/webcrypto_impl_nss.cc

Issue 25906002: [webcrypto] Add JWK import for HMAC and AES-CBC key. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixes for eroman Created 7 years, 1 month 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/webcrypto/webcrypto_impl.h" 5 #include "content/renderer/webcrypto/webcrypto_impl.h"
6 6
7 #include <cryptohi.h> 7 #include <cryptohi.h>
8 #include <pk11pub.h> 8 #include <pk11pub.h>
9 #include <sechash.h> 9 #include <sechash.h>
10 10
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "content/renderer/webcrypto/webcrypto_util.h"
14 #include "crypto/nss_util.h" 15 #include "crypto/nss_util.h"
15 #include "crypto/scoped_nss_types.h" 16 #include "crypto/scoped_nss_types.h"
16 #include "crypto/secure_util.h" 17 #include "crypto/secure_util.h"
17 #include "third_party/WebKit/public/platform/WebArrayBuffer.h" 18 #include "third_party/WebKit/public/platform/WebArrayBuffer.h"
18 #include "third_party/WebKit/public/platform/WebCryptoAlgorithm.h" 19 #include "third_party/WebKit/public/platform/WebCryptoAlgorithm.h"
19 #include "third_party/WebKit/public/platform/WebCryptoAlgorithmParams.h" 20 #include "third_party/WebKit/public/platform/WebCryptoAlgorithmParams.h"
20 21
21 namespace content { 22 namespace content {
22 23
23 namespace { 24 namespace {
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 } 141 }
141 142
142 unsigned int final_output_chunk_len; 143 unsigned int final_output_chunk_len;
143 if (SECSuccess != PK11_DigestFinal(context.get(), 144 if (SECSuccess != PK11_DigestFinal(context.get(),
144 buffer_data + output_len, 145 buffer_data + output_len,
145 &final_output_chunk_len, 146 &final_output_chunk_len,
146 output_max_len - output_len)) { 147 output_max_len - output_len)) {
147 return false; 148 return false;
148 } 149 }
149 150
150 WebCryptoImpl::ShrinkBuffer(buffer, final_output_chunk_len + output_len); 151 ShrinkBuffer(buffer, final_output_chunk_len + output_len);
151 return true; 152 return true;
152 } 153 }
153 154
154 CK_MECHANISM_TYPE HmacAlgorithmToGenMechanism( 155 CK_MECHANISM_TYPE HmacAlgorithmToGenMechanism(
155 const WebKit::WebCryptoAlgorithm& algorithm) { 156 const WebKit::WebCryptoAlgorithm& algorithm) {
156 DCHECK_EQ(algorithm.id(), WebKit::WebCryptoAlgorithmIdHmac); 157 DCHECK_EQ(algorithm.id(), WebKit::WebCryptoAlgorithmIdHmac);
157 const WebKit::WebCryptoHmacKeyParams* params = algorithm.hmacKeyParams(); 158 const WebKit::WebCryptoHmacKeyParams* params = algorithm.hmacKeyParams();
158 DCHECK(params); 159 DCHECK(params);
159 switch (params->hash().id()) { 160 switch (params->hash().id()) {
160 case WebKit::WebCryptoAlgorithmIdSha1: 161 case WebKit::WebCryptoAlgorithmIdSha1:
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 break; 507 break;
507 } 508 }
508 default: 509 default:
509 return false; 510 return false;
510 } 511 }
511 512
512 return true; 513 return true;
513 } 514 }
514 515
515 } // namespace content 516 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698