| 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 "content/child/webcrypto/crypto_data.h" | 6 #include "content/child/webcrypto/crypto_data.h" |
| 7 #include "content/child/webcrypto/openssl/key_openssl.h" | 7 #include "content/child/webcrypto/openssl/key_openssl.h" |
| 8 #include "content/child/webcrypto/openssl/rsa_key_openssl.h" | 8 #include "content/child/webcrypto/openssl/rsa_key_openssl.h" |
| 9 #include "content/child/webcrypto/openssl/rsa_sign_openssl.h" | 9 #include "content/child/webcrypto/openssl/rsa_sign_openssl.h" |
| 10 #include "content/child/webcrypto/openssl/util_openssl.h" | 10 #include "content/child/webcrypto/openssl/util_openssl.h" |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 return Status::OperationError(); | 133 return Status::OperationError(); |
| 134 | 134 |
| 135 // Set PSS-specific options (if applicable). | 135 // Set PSS-specific options (if applicable). |
| 136 status = ApplyRsaPssOptions(key, digest, pss_salt_length_bytes, pctx); | 136 status = ApplyRsaPssOptions(key, digest, pss_salt_length_bytes, pctx); |
| 137 if (status.IsError()) | 137 if (status.IsError()) |
| 138 return status; | 138 return status; |
| 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 // Note that the return value can be: | 143 *signature_match = 1 == EVP_DigestVerifyFinal(ctx.get(), signature.bytes(), |
| 144 // 1 --> Success | 144 signature.byte_length()); |
| 145 // 0 --> Verification failed | 145 return Status::Success(); |
| 146 // <0 --> Operation error | |
| 147 int rv = EVP_DigestVerifyFinal( | |
| 148 ctx.get(), signature.bytes(), signature.byte_length()); | |
| 149 *signature_match = rv == 1; | |
| 150 return rv >= 0 ? Status::Success() : Status::OperationError(); | |
| 151 } | 146 } |
| 152 | 147 |
| 153 } // namespace webcrypto | 148 } // namespace webcrypto |
| 154 | 149 |
| 155 } // namespace content | 150 } // namespace content |
| OLD | NEW |