| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <openssl/digest.h> | |
| 6 #include <openssl/evp.h> | |
| 7 #include <openssl/rsa.h> | |
| 8 #include <stddef.h> | 5 #include <stddef.h> |
| 9 | 6 |
| 10 #include "base/numerics/safe_math.h" | 7 #include "base/numerics/safe_math.h" |
| 11 #include "components/webcrypto/algorithms/rsa_sign.h" | 8 #include "components/webcrypto/algorithms/rsa_sign.h" |
| 12 #include "components/webcrypto/algorithms/util.h" | 9 #include "components/webcrypto/algorithms/util.h" |
| 13 #include "components/webcrypto/blink_key_handle.h" | 10 #include "components/webcrypto/blink_key_handle.h" |
| 14 #include "components/webcrypto/crypto_data.h" | 11 #include "components/webcrypto/crypto_data.h" |
| 15 #include "components/webcrypto/status.h" | 12 #include "components/webcrypto/status.h" |
| 16 #include "crypto/openssl_util.h" | 13 #include "crypto/openssl_util.h" |
| 17 #include "third_party/WebKit/public/platform/WebCryptoKeyAlgorithm.h" | 14 #include "third_party/WebKit/public/platform/WebCryptoKeyAlgorithm.h" |
| 15 #include "third_party/boringssl/src/include/openssl/digest.h" |
| 16 #include "third_party/boringssl/src/include/openssl/evp.h" |
| 17 #include "third_party/boringssl/src/include/openssl/rsa.h" |
| 18 | 18 |
| 19 namespace webcrypto { | 19 namespace webcrypto { |
| 20 | 20 |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 // Extracts the OpenSSL key and digest from a WebCrypto key. The returned | 23 // Extracts the OpenSSL key and digest from a WebCrypto key. The returned |
| 24 // pointers will remain valid as long as |key| is alive. | 24 // pointers will remain valid as long as |key| is alive. |
| 25 Status GetPKeyAndDigest(const blink::WebCryptoKey& key, | 25 Status GetPKeyAndDigest(const blink::WebCryptoKey& key, |
| 26 EVP_PKEY** pkey, | 26 EVP_PKEY** pkey, |
| 27 const EVP_MD** digest) { | 27 const EVP_MD** digest) { |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 | 139 |
| 140 if (!EVP_DigestVerifyUpdate(ctx.get(), data.bytes(), data.byte_length())) | 140 if (!EVP_DigestVerifyUpdate(ctx.get(), data.bytes(), data.byte_length())) |
| 141 return Status::OperationError(); | 141 return Status::OperationError(); |
| 142 | 142 |
| 143 *signature_match = 1 == EVP_DigestVerifyFinal(ctx.get(), signature.bytes(), | 143 *signature_match = 1 == EVP_DigestVerifyFinal(ctx.get(), signature.bytes(), |
| 144 signature.byte_length()); | 144 signature.byte_length()); |
| 145 return Status::Success(); | 145 return Status::Success(); |
| 146 } | 146 } |
| 147 | 147 |
| 148 } // namespace webcrypto | 148 } // namespace webcrypto |
| OLD | NEW |