| 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 "base/numerics/safe_math.h" | 5 #include "base/numerics/safe_math.h" |
| 6 #include "base/stl_util.h" | |
| 7 #include "components/webcrypto/algorithms/rsa_sign.h" | 6 #include "components/webcrypto/algorithms/rsa_sign.h" |
| 8 #include "components/webcrypto/algorithms/util.h" | 7 #include "components/webcrypto/algorithms/util.h" |
| 9 #include "components/webcrypto/blink_key_handle.h" | 8 #include "components/webcrypto/blink_key_handle.h" |
| 10 #include "components/webcrypto/crypto_data.h" | 9 #include "components/webcrypto/crypto_data.h" |
| 11 #include "components/webcrypto/status.h" | 10 #include "components/webcrypto/status.h" |
| 12 #include "crypto/openssl_util.h" | 11 #include "crypto/openssl_util.h" |
| 13 #include "crypto/scoped_openssl_types.h" | 12 #include "crypto/scoped_openssl_types.h" |
| 14 #include "third_party/WebKit/public/platform/WebCryptoKeyAlgorithm.h" | 13 #include "third_party/WebKit/public/platform/WebCryptoKeyAlgorithm.h" |
| 15 | 14 |
| 16 namespace webcrypto { | 15 namespace webcrypto { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 status = ApplyRsaPssOptions(key, digest, pss_salt_length_bytes, pctx); | 94 status = ApplyRsaPssOptions(key, digest, pss_salt_length_bytes, pctx); |
| 96 if (status.IsError()) | 95 if (status.IsError()) |
| 97 return status; | 96 return status; |
| 98 | 97 |
| 99 if (!EVP_DigestSignUpdate(ctx.get(), data.bytes(), data.byte_length()) || | 98 if (!EVP_DigestSignUpdate(ctx.get(), data.bytes(), data.byte_length()) || |
| 100 !EVP_DigestSignFinal(ctx.get(), NULL, &sig_len)) { | 99 !EVP_DigestSignFinal(ctx.get(), NULL, &sig_len)) { |
| 101 return Status::OperationError(); | 100 return Status::OperationError(); |
| 102 } | 101 } |
| 103 | 102 |
| 104 buffer->resize(sig_len); | 103 buffer->resize(sig_len); |
| 105 if (!EVP_DigestSignFinal(ctx.get(), vector_as_array(buffer), &sig_len)) | 104 if (!EVP_DigestSignFinal(ctx.get(), buffer->data(), &sig_len)) |
| 106 return Status::OperationError(); | 105 return Status::OperationError(); |
| 107 | 106 |
| 108 buffer->resize(sig_len); | 107 buffer->resize(sig_len); |
| 109 return Status::Success(); | 108 return Status::Success(); |
| 110 } | 109 } |
| 111 | 110 |
| 112 Status RsaVerify(const blink::WebCryptoKey& key, | 111 Status RsaVerify(const blink::WebCryptoKey& key, |
| 113 unsigned int pss_salt_length_bytes, | 112 unsigned int pss_salt_length_bytes, |
| 114 const CryptoData& signature, | 113 const CryptoData& signature, |
| 115 const CryptoData& data, | 114 const CryptoData& data, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 137 | 136 |
| 138 if (!EVP_DigestVerifyUpdate(ctx.get(), data.bytes(), data.byte_length())) | 137 if (!EVP_DigestVerifyUpdate(ctx.get(), data.bytes(), data.byte_length())) |
| 139 return Status::OperationError(); | 138 return Status::OperationError(); |
| 140 | 139 |
| 141 *signature_match = 1 == EVP_DigestVerifyFinal(ctx.get(), signature.bytes(), | 140 *signature_match = 1 == EVP_DigestVerifyFinal(ctx.get(), signature.bytes(), |
| 142 signature.byte_length()); | 141 signature.byte_length()); |
| 143 return Status::Success(); | 142 return Status::Success(); |
| 144 } | 143 } |
| 145 | 144 |
| 146 } // namespace webcrypto | 145 } // namespace webcrypto |
| OLD | NEW |