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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 return status; | 90 return status; |
91 | 91 |
92 if (1 != EVP_DigestVerifyInit(ctx.get(), NULL, digest, NULL, public_key)) | 92 if (1 != EVP_DigestVerifyInit(ctx.get(), NULL, digest, NULL, public_key)) |
93 return Status::OperationError(); | 93 return Status::OperationError(); |
94 | 94 |
95 if (1 != | 95 if (1 != |
96 EVP_DigestVerifyUpdate(ctx.get(), data.bytes(), data.byte_length())) { | 96 EVP_DigestVerifyUpdate(ctx.get(), data.bytes(), data.byte_length())) { |
97 return Status::OperationError(); | 97 return Status::OperationError(); |
98 } | 98 } |
99 | 99 |
100 // This function takes a non-const pointer to the signature, however does | 100 // Note that the return value can be: |
101 // not mutate it, so casting is safe. | |
102 // Also note that the return value can be: | |
103 // 1 --> Success | 101 // 1 --> Success |
104 // 0 --> Verification failed | 102 // 0 --> Verification failed |
105 // <0 --> Operation error | 103 // <0 --> Operation error |
106 int rv = EVP_DigestVerifyFinal(ctx.get(), | 104 int rv = EVP_DigestVerifyFinal(ctx.get(), |
107 const_cast<uint8_t*>(signature.bytes()), | 105 signature.bytes(), |
108 signature.byte_length()); | 106 signature.byte_length()); |
109 *signature_match = rv == 1; | 107 *signature_match = rv == 1; |
110 return rv >= 0 ? Status::Success() : Status::OperationError(); | 108 return rv >= 0 ? Status::Success() : Status::OperationError(); |
111 } | 109 } |
112 }; | 110 }; |
113 | 111 |
114 } // namespace | 112 } // namespace |
115 | 113 |
116 AlgorithmImplementation* CreatePlatformRsaSsaImplementation() { | 114 AlgorithmImplementation* CreatePlatformRsaSsaImplementation() { |
117 return new RsaSsaImplementation; | 115 return new RsaSsaImplementation; |
118 } | 116 } |
119 | 117 |
120 } // namespace webcrypto | 118 } // namespace webcrypto |
121 | 119 |
122 } // namespace content | 120 } // namespace content |
OLD | NEW |