| 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 "content/child/webcrypto/crypto_data.h" | 5 #include "content/child/webcrypto/crypto_data.h" |
| 6 #include "content/child/webcrypto/openssl/key_openssl.h" | 6 #include "content/child/webcrypto/openssl/key_openssl.h" |
| 7 #include "content/child/webcrypto/openssl/rsa_key_openssl.h" | 7 #include "content/child/webcrypto/openssl/rsa_key_openssl.h" |
| 8 #include "content/child/webcrypto/openssl/util_openssl.h" | 8 #include "content/child/webcrypto/openssl/util_openssl.h" |
| 9 #include "content/child/webcrypto/status.h" | 9 #include "content/child/webcrypto/status.h" |
| 10 #include "crypto/openssl_util.h" | 10 #include "crypto/openssl_util.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 | 98 |
| 99 crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE); | 99 crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE); |
| 100 crypto::ScopedEVP_MD_CTX ctx(EVP_MD_CTX_create()); | 100 crypto::ScopedEVP_MD_CTX ctx(EVP_MD_CTX_create()); |
| 101 | 101 |
| 102 EVP_PKEY* public_key = NULL; | 102 EVP_PKEY* public_key = NULL; |
| 103 const EVP_MD* digest = NULL; | 103 const EVP_MD* digest = NULL; |
| 104 Status status = GetPKeyAndDigest(key, &public_key, &digest); | 104 Status status = GetPKeyAndDigest(key, &public_key, &digest); |
| 105 if (status.IsError()) | 105 if (status.IsError()) |
| 106 return status; | 106 return status; |
| 107 | 107 |
| 108 if (1 != EVP_DigestVerifyInit(ctx.get(), NULL, digest, NULL, public_key)) | 108 if (!EVP_DigestVerifyInit(ctx.get(), NULL, digest, NULL, public_key)) |
| 109 return Status::OperationError(); | 109 return Status::OperationError(); |
| 110 | 110 |
| 111 if (1 != | 111 if (!EVP_DigestVerifyUpdate(ctx.get(), data.bytes(), data.byte_length())) { |
| 112 EVP_DigestVerifyUpdate(ctx.get(), data.bytes(), data.byte_length())) { | |
| 113 return Status::OperationError(); | 112 return Status::OperationError(); |
| 114 } | 113 } |
| 115 | 114 |
| 116 // Note that the return value can be: | 115 // Note that the return value can be: |
| 117 // 1 --> Success | 116 // 1 --> Success |
| 118 // 0 --> Verification failed | 117 // 0 --> Verification failed |
| 119 // <0 --> Operation error | 118 // <0 --> Operation error |
| 120 int rv = EVP_DigestVerifyFinal(ctx.get(), | 119 int rv = EVP_DigestVerifyFinal( |
| 121 signature.bytes(), | 120 ctx.get(), signature.bytes(), signature.byte_length()); |
| 122 signature.byte_length()); | |
| 123 *signature_match = rv == 1; | 121 *signature_match = rv == 1; |
| 124 return rv >= 0 ? Status::Success() : Status::OperationError(); | 122 return rv >= 0 ? Status::Success() : Status::OperationError(); |
| 125 } | 123 } |
| 126 }; | 124 }; |
| 127 | 125 |
| 128 } // namespace | 126 } // namespace |
| 129 | 127 |
| 130 AlgorithmImplementation* CreatePlatformRsaSsaImplementation() { | 128 AlgorithmImplementation* CreatePlatformRsaSsaImplementation() { |
| 131 return new RsaSsaImplementation; | 129 return new RsaSsaImplementation; |
| 132 } | 130 } |
| 133 | 131 |
| 134 } // namespace webcrypto | 132 } // namespace webcrypto |
| 135 | 133 |
| 136 } // namespace content | 134 } // namespace content |
| OLD | NEW |