Switch remaining scoped_openssl_types uses to BoringSSL scopers.
BUG=654143 Review-Url: https://codereview.chromium.org/2408063002 Cr-Commit-Position: refs/heads/master@{#424523}
This commit is contained in:
android_webview/native
chrome
browser
extensions
api
certificate_provider
ui
common
extensions
api
networking_private
crypto
@@ -19,7 +19,6 @@
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
#include "content/public/browser/render_view_host.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "crypto/scoped_openssl_types.h"
|
||||
#include "grit/components_strings.h"
|
||||
#include "jni/AwContentsClientBridge_jni.h"
|
||||
#include "net/cert/x509_certificate.h"
|
||||
|
@@ -33,7 +33,6 @@
|
||||
#include "content/public/test/test_navigation_observer.h"
|
||||
#include "content/public/test/test_utils.h"
|
||||
#include "crypto/rsa_private_key.h"
|
||||
#include "crypto/scoped_openssl_types.h"
|
||||
#include "extensions/common/extension.h"
|
||||
#include "extensions/test/result_catcher.h"
|
||||
#include "net/test/spawned_test_server/spawned_test_server.h"
|
||||
@@ -82,7 +81,7 @@ void StoreDigest(std::vector<uint8_t>* digest,
|
||||
bool RsaSign(const std::vector<uint8_t>& digest,
|
||||
crypto::RSAPrivateKey* key,
|
||||
std::vector<uint8_t>* signature) {
|
||||
crypto::ScopedRSA rsa_key(EVP_PKEY_get1_RSA(key->key()));
|
||||
RSA* rsa_key = EVP_PKEY_get0_RSA(key->key());
|
||||
if (!rsa_key)
|
||||
return false;
|
||||
|
||||
@@ -94,9 +93,9 @@ bool RsaSign(const std::vector<uint8_t>& digest,
|
||||
return false;
|
||||
}
|
||||
size_t len = 0;
|
||||
signature->resize(RSA_size(rsa_key.get()));
|
||||
signature->resize(RSA_size(rsa_key));
|
||||
const int rv =
|
||||
RSA_sign_raw(rsa_key.get(), &len, signature->data(), signature->size(),
|
||||
RSA_sign_raw(rsa_key, &len, signature->data(), signature->size(),
|
||||
prefixed_digest, prefixed_digest_len, RSA_PKCS1_PADDING);
|
||||
if (is_alloced)
|
||||
free(prefixed_digest);
|
||||
|
@@ -18,7 +18,6 @@
|
||||
#include "chrome/browser/ui/android/view_android_helper.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "content/public/browser/client_certificate_delegate.h"
|
||||
#include "crypto/scoped_openssl_types.h"
|
||||
#include "jni/SSLClientCertificateRequest_jni.h"
|
||||
#include "net/base/host_port_pair.h"
|
||||
#include "net/cert/cert_database.h"
|
||||
|
@@ -17,7 +17,6 @@
|
||||
#include "components/cast_certificate/cast_cert_validator.h"
|
||||
#include "crypto/openssl_util.h"
|
||||
#include "crypto/rsa_private_key.h"
|
||||
#include "crypto/scoped_openssl_types.h"
|
||||
#include "net/cert/pem_tokenizer.h"
|
||||
|
||||
namespace {
|
||||
@@ -129,7 +128,7 @@ bool EncryptByteString(const std::vector<uint8_t>& pub_key_der,
|
||||
crypto::EnsureOpenSSLInit();
|
||||
crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE);
|
||||
|
||||
crypto::ScopedRSA rsa(
|
||||
bssl::UniquePtr<RSA> rsa(
|
||||
RSA_public_key_from_bytes(pub_key_der.data(), pub_key_der.size()));
|
||||
if (!rsa || RSA_size(rsa.get()) == 0) {
|
||||
LOG(ERROR) << "Failed to parse public key";
|
||||
@@ -166,17 +165,17 @@ bool DecryptByteString(const std::string& private_key_pem,
|
||||
return false;
|
||||
}
|
||||
|
||||
crypto::ScopedRSA rsa(EVP_PKEY_get1_RSA(private_key->key()));
|
||||
if (!rsa || RSA_size(rsa.get()) == 0) {
|
||||
RSA* rsa = EVP_PKEY_get0_RSA(private_key->key());
|
||||
if (!rsa || RSA_size(rsa) == 0) {
|
||||
LOG(ERROR) << "Failed to get RSA key.";
|
||||
return false;
|
||||
}
|
||||
|
||||
uint8_t* output = reinterpret_cast<uint8_t*>(
|
||||
base::WriteInto(decrypted_output, RSA_size(rsa.get()) + 1));
|
||||
base::WriteInto(decrypted_output, RSA_size(rsa) + 1));
|
||||
int output_length =
|
||||
RSA_private_decrypt(encrypted_data.size(), &encrypted_data[0], output,
|
||||
rsa.get(), RSA_PKCS1_PADDING);
|
||||
rsa, RSA_PKCS1_PADDING);
|
||||
if (output_length < 0) {
|
||||
LOG(ERROR) << "Error during decryption.";
|
||||
return false;
|
||||
|
@@ -13,7 +13,6 @@ component("crypto") {
|
||||
"apple_keychain.h",
|
||||
"apple_keychain_ios.mm",
|
||||
"apple_keychain_mac.mm",
|
||||
"auto_cbb.h",
|
||||
"capi_util.cc",
|
||||
"capi_util.h",
|
||||
"crypto_export.h",
|
||||
|
@@ -1,35 +0,0 @@
|
||||
// Copyright 2016 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef CRYPTO_AUTO_CBB_H_
|
||||
#define CRYPTO_AUTO_CBB_H_
|
||||
|
||||
#include <openssl/bytestring.h>
|
||||
|
||||
#include "base/macros.h"
|
||||
|
||||
namespace crypto {
|
||||
|
||||
// AutoCBB is a wrapper over OpenSSL's CBB type that automatically releases
|
||||
// resources when going out of scope.
|
||||
class AutoCBB {
|
||||
public:
|
||||
AutoCBB() { CBB_zero(&cbb_); }
|
||||
~AutoCBB() { CBB_cleanup(&cbb_); }
|
||||
|
||||
CBB* get() { return &cbb_; }
|
||||
|
||||
void Reset() {
|
||||
CBB_cleanup(&cbb_);
|
||||
CBB_zero(&cbb_);
|
||||
}
|
||||
|
||||
private:
|
||||
CBB cbb_;
|
||||
DISALLOW_COPY_AND_ASSIGN(AutoCBB);
|
||||
};
|
||||
|
||||
} // namespace crypto
|
||||
|
||||
#endif // CRYPTO_AUTO_CBB_H_
|
@@ -1,60 +0,0 @@
|
||||
// Copyright 2014 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef CRYPTO_SCOPED_OPENSSL_TYPES_H_
|
||||
#define CRYPTO_SCOPED_OPENSSL_TYPES_H_
|
||||
|
||||
#include <openssl/bio.h>
|
||||
#include <openssl/bn.h>
|
||||
#include <openssl/dsa.h>
|
||||
#include <openssl/ec.h>
|
||||
#include <openssl/ecdsa.h>
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/mem.h>
|
||||
#include <openssl/rsa.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace crypto {
|
||||
|
||||
// Simplistic helper that wraps a call to a deleter function. In a C++11 world,
|
||||
// this would be std::function<>. An alternative would be to re-use
|
||||
// base::internal::RunnableAdapter<>, but that's far too heavy weight.
|
||||
template <typename Type, void (*Destroyer)(Type*)>
|
||||
struct OpenSSLDestroyer {
|
||||
void operator()(Type* ptr) const { Destroyer(ptr); }
|
||||
};
|
||||
|
||||
template <typename PointerType, void (*Destroyer)(PointerType*)>
|
||||
using ScopedOpenSSL =
|
||||
std::unique_ptr<PointerType, OpenSSLDestroyer<PointerType, Destroyer>>;
|
||||
|
||||
struct OpenSSLFree {
|
||||
void operator()(uint8_t* ptr) const { OPENSSL_free(ptr); }
|
||||
};
|
||||
|
||||
// Several typedefs are provided for crypto-specific primitives, for
|
||||
// short-hand and prevalence. Note that OpenSSL types related to X.509 are
|
||||
// intentionally not included, as crypto/ does not generally deal with
|
||||
// certificates or PKI.
|
||||
using ScopedBIGNUM = ScopedOpenSSL<BIGNUM, BN_free>;
|
||||
using ScopedEC_Key = ScopedOpenSSL<EC_KEY, EC_KEY_free>;
|
||||
using ScopedBIO = ScopedOpenSSL<BIO, BIO_free_all>;
|
||||
using ScopedDSA = ScopedOpenSSL<DSA, DSA_free>;
|
||||
using ScopedECDSA_SIG = ScopedOpenSSL<ECDSA_SIG, ECDSA_SIG_free>;
|
||||
using ScopedEC_GROUP = ScopedOpenSSL<EC_GROUP, EC_GROUP_free>;
|
||||
using ScopedEC_KEY = ScopedOpenSSL<EC_KEY, EC_KEY_free>;
|
||||
using ScopedEC_POINT = ScopedOpenSSL<EC_POINT, EC_POINT_free>;
|
||||
using ScopedEVP_MD_CTX = ScopedOpenSSL<EVP_MD_CTX, EVP_MD_CTX_destroy>;
|
||||
using ScopedEVP_PKEY = ScopedOpenSSL<EVP_PKEY, EVP_PKEY_free>;
|
||||
using ScopedEVP_PKEY_CTX = ScopedOpenSSL<EVP_PKEY_CTX, EVP_PKEY_CTX_free>;
|
||||
using ScopedRSA = ScopedOpenSSL<RSA, RSA_free>;
|
||||
|
||||
// The bytes must have been allocated with OPENSSL_malloc.
|
||||
using ScopedOpenSSLBytes = std::unique_ptr<uint8_t, OpenSSLFree>;
|
||||
|
||||
} // namespace crypto
|
||||
|
||||
#endif // CRYPTO_SCOPED_OPENSSL_TYPES_H_
|
Reference in New Issue
Block a user