Skip to content

Commit

Permalink
Use span in RSAPrivateKey factory method
Browse files Browse the repository at this point in the history
Use base::span for accepting the input in the
crypto::RSAPrivateKey::CreateFromPrivateKeyInfo() method.

This allows to make using this method slightly more convenient, without
needing to convert the data into std::vector<uint8_t>.

This is a pure refactoring CL; no functional changes expected.

Bug: 1067683
Change-Id: I180980cabf868d464eb5278332a3d06cd119246d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2270446
Commit-Queue: Maksim Ivanov <emaxx@chromium.org>
Reviewed-by: David Benjamin <davidben@chromium.org>
Cr-Commit-Position: refs/heads/master@{#783593}
  • Loading branch information
Maksim Ivanov authored and Commit Bot committed Jun 29, 2020
1 parent e49d10b commit bc97782
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion crypto/rsa_private_key.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <utility>

#include "base/check.h"
#include "base/containers/span.h"
#include "crypto/openssl_util.h"
#include "third_party/boringssl/src/include/openssl/bn.h"
#include "third_party/boringssl/src/include/openssl/bytestring.h"
Expand Down Expand Up @@ -41,7 +42,7 @@ std::unique_ptr<RSAPrivateKey> RSAPrivateKey::Create(uint16_t num_bits) {

// static
std::unique_ptr<RSAPrivateKey> RSAPrivateKey::CreateFromPrivateKeyInfo(
const std::vector<uint8_t>& input) {
base::span<const uint8_t> input) {
OpenSSLErrStackTracer err_tracer(FROM_HERE);

CBS cbs;
Expand Down
3 changes: 2 additions & 1 deletion crypto/rsa_private_key.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <memory>
#include <vector>

#include "base/containers/span.h"
#include "base/macros.h"
#include "build/build_config.h"
#include "crypto/crypto_export.h"
Expand All @@ -32,7 +33,7 @@ class CRYPTO_EXPORT RSAPrivateKey {
// an ASN.1-encoded PrivateKeyInfo block from PKCS #8. This can return NULL if
// initialization fails.
static std::unique_ptr<RSAPrivateKey> CreateFromPrivateKeyInfo(
const std::vector<uint8_t>& input);
base::span<const uint8_t> input);

// Create a new instance from an existing EVP_PKEY, taking a
// reference to it. |key| must be an RSA key. Returns NULL on
Expand Down

0 comments on commit bc97782

Please sign in to comment.