| OLD | NEW |
| 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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 } | 164 } |
| 164 | 165 |
| 165 unsigned int final_output_chunk_len; | 166 unsigned int final_output_chunk_len; |
| 166 if (SECSuccess != PK11_DigestFinal(context.get(), | 167 if (SECSuccess != PK11_DigestFinal(context.get(), |
| 167 buffer_data + output_len, | 168 buffer_data + output_len, |
| 168 &final_output_chunk_len, | 169 &final_output_chunk_len, |
| 169 output_max_len - output_len)) { | 170 output_max_len - output_len)) { |
| 170 return false; | 171 return false; |
| 171 } | 172 } |
| 172 | 173 |
| 173 WebCryptoImpl::ShrinkBuffer(buffer, final_output_chunk_len + output_len); | 174 ShrinkBuffer(buffer, final_output_chunk_len + output_len); |
| 174 return true; | 175 return true; |
| 175 } | 176 } |
| 176 | 177 |
| 177 CK_MECHANISM_TYPE HmacAlgorithmToGenMechanism( | 178 CK_MECHANISM_TYPE HmacAlgorithmToGenMechanism( |
| 178 const WebKit::WebCryptoAlgorithm& algorithm) { | 179 const WebKit::WebCryptoAlgorithm& algorithm) { |
| 179 DCHECK_EQ(algorithm.id(), WebKit::WebCryptoAlgorithmIdHmac); | 180 DCHECK_EQ(algorithm.id(), WebKit::WebCryptoAlgorithmIdHmac); |
| 180 const WebKit::WebCryptoHmacKeyParams* params = algorithm.hmacKeyParams(); | 181 const WebKit::WebCryptoHmacKeyParams* params = algorithm.hmacKeyParams(); |
| 181 DCHECK(params); | 182 DCHECK(params); |
| 182 switch (params->hash().id()) { | 183 switch (params->hash().id()) { |
| 183 case WebKit::WebCryptoAlgorithmIdSha1: | 184 case WebKit::WebCryptoAlgorithmIdSha1: |
| (...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 642 break; | 643 break; |
| 643 } | 644 } |
| 644 default: | 645 default: |
| 645 return false; | 646 return false; |
| 646 } | 647 } |
| 647 | 648 |
| 648 return true; | 649 return true; |
| 649 } | 650 } |
| 650 | 651 |
| 651 } // namespace content | 652 } // namespace content |
| OLD | NEW |