Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(244)

Side by Side Diff: content/child/webcrypto/openssl/aes_cbc_openssl.cc

Issue 948543002: Convert crypto::ScopedOpenSSL to type aliases. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "base/stl_util.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 if (!output_max_len.IsValid()) 58 if (!output_max_len.IsValid())
59 return Status::ErrorDataTooLarge(); 59 return Status::ErrorDataTooLarge();
60 60
61 const unsigned remainder = output_max_len.ValueOrDie() % AES_BLOCK_SIZE; 61 const unsigned remainder = output_max_len.ValueOrDie() % AES_BLOCK_SIZE;
62 if (remainder != 0) 62 if (remainder != 0)
63 output_max_len += AES_BLOCK_SIZE - remainder; 63 output_max_len += AES_BLOCK_SIZE - remainder;
64 if (!output_max_len.IsValid()) 64 if (!output_max_len.IsValid())
65 return Status::ErrorDataTooLarge(); 65 return Status::ErrorDataTooLarge();
66 66
67 // Note: PKCS padding is enabled by default 67 // Note: PKCS padding is enabled by default
68 crypto::ScopedOpenSSL<EVP_CIPHER_CTX, EVP_CIPHER_CTX_free>::Type context( 68 crypto::ScopedOpenSSL<EVP_CIPHER_CTX, EVP_CIPHER_CTX_free> context(
69 EVP_CIPHER_CTX_new()); 69 EVP_CIPHER_CTX_new());
70 70
71 if (!context.get()) 71 if (!context.get())
72 return Status::OperationError(); 72 return Status::OperationError();
73 73
74 const EVP_CIPHER* const cipher = GetAESCipherByKeyLength(raw_key.size()); 74 const EVP_CIPHER* const cipher = GetAESCipherByKeyLength(raw_key.size());
75 DCHECK(cipher); 75 DCHECK(cipher);
76 76
77 if (!EVP_CipherInit_ex(context.get(), cipher, NULL, &raw_key[0], 77 if (!EVP_CipherInit_ex(context.get(), cipher, NULL, &raw_key[0],
78 params->iv().data(), cipher_operation)) { 78 params->iv().data(), cipher_operation)) {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 124
125 } // namespace 125 } // namespace
126 126
127 AlgorithmImplementation* CreatePlatformAesCbcImplementation() { 127 AlgorithmImplementation* CreatePlatformAesCbcImplementation() {
128 return new AesCbcImplementation; 128 return new AesCbcImplementation;
129 } 129 }
130 130
131 } // namespace webcrypto 131 } // namespace webcrypto
132 132
133 } // namespace content 133 } // namespace content
OLDNEW
« no previous file with comments | « chrome/common/net/x509_certificate_model_openssl.cc ('k') | content/child/webcrypto/openssl/aes_ctr_openssl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698