| 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/aes.h> | 5 #include <openssl/aes.h> |
| 6 #include <openssl/evp.h> | 6 #include <openssl/evp.h> |
| 7 | 7 |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/numerics/safe_math.h" | 9 #include "base/numerics/safe_math.h" |
| 10 #include "base/stl_util.h" |
| 10 #include "content/child/webcrypto/crypto_data.h" | 11 #include "content/child/webcrypto/crypto_data.h" |
| 11 #include "content/child/webcrypto/openssl/aes_key_openssl.h" | 12 #include "content/child/webcrypto/openssl/aes_key_openssl.h" |
| 12 #include "content/child/webcrypto/openssl/key_openssl.h" | 13 #include "content/child/webcrypto/openssl/key_openssl.h" |
| 13 #include "content/child/webcrypto/status.h" | 14 #include "content/child/webcrypto/status.h" |
| 14 #include "content/child/webcrypto/webcrypto_util.h" | 15 #include "content/child/webcrypto/webcrypto_util.h" |
| 15 #include "crypto/scoped_openssl_types.h" | 16 #include "crypto/scoped_openssl_types.h" |
| 16 #include "third_party/WebKit/public/platform/WebCryptoAlgorithmParams.h" | 17 #include "third_party/WebKit/public/platform/WebCryptoAlgorithmParams.h" |
| 17 | 18 |
| 18 namespace content { | 19 namespace content { |
| 19 | 20 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 cipher, | 77 cipher, |
| 77 NULL, | 78 NULL, |
| 78 &raw_key[0], | 79 &raw_key[0], |
| 79 params->iv().data(), | 80 params->iv().data(), |
| 80 cipher_operation)) { | 81 cipher_operation)) { |
| 81 return Status::OperationError(); | 82 return Status::OperationError(); |
| 82 } | 83 } |
| 83 | 84 |
| 84 buffer->resize(output_max_len.ValueOrDie()); | 85 buffer->resize(output_max_len.ValueOrDie()); |
| 85 | 86 |
| 86 unsigned char* const buffer_data = Uint8VectorStart(buffer); | 87 unsigned char* const buffer_data = vector_as_array(buffer); |
| 87 | 88 |
| 88 int output_len = 0; | 89 int output_len = 0; |
| 89 if (!EVP_CipherUpdate(context.get(), | 90 if (!EVP_CipherUpdate(context.get(), |
| 90 buffer_data, | 91 buffer_data, |
| 91 &output_len, | 92 &output_len, |
| 92 data.bytes(), | 93 data.bytes(), |
| 93 data.byte_length())) | 94 data.byte_length())) |
| 94 return Status::OperationError(); | 95 return Status::OperationError(); |
| 95 int final_output_chunk_len = 0; | 96 int final_output_chunk_len = 0; |
| 96 if (!EVP_CipherFinal_ex( | 97 if (!EVP_CipherFinal_ex( |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 | 129 |
| 129 } // namespace | 130 } // namespace |
| 130 | 131 |
| 131 AlgorithmImplementation* CreatePlatformAesCbcImplementation() { | 132 AlgorithmImplementation* CreatePlatformAesCbcImplementation() { |
| 132 return new AesCbcImplementation; | 133 return new AesCbcImplementation; |
| 133 } | 134 } |
| 134 | 135 |
| 135 } // namespace webcrypto | 136 } // namespace webcrypto |
| 136 | 137 |
| 137 } // namespace content | 138 } // namespace content |
| OLD | NEW |