From 0d782e1dfbee2b48e7f46a2cde7f98357aa244dc Mon Sep 17 00:00:00 2001 From: asynts Date: Mon, 27 Jul 2020 15:14:44 +0200 Subject: [PATCH] LibCrypto: Change the signature of RSA::parse_rsa_key to use Span. --- Libraries/LibCrypto/PK/RSA.cpp | 6 +++--- Libraries/LibCrypto/PK/RSA.h | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Libraries/LibCrypto/PK/RSA.cpp b/Libraries/LibCrypto/PK/RSA.cpp index 67a46c7e5d..74b999661e 100644 --- a/Libraries/LibCrypto/PK/RSA.cpp +++ b/Libraries/LibCrypto/PK/RSA.cpp @@ -33,7 +33,7 @@ namespace Crypto { namespace PK { -RSA::KeyPairType RSA::parse_rsa_key(const ByteBuffer& in) +RSA::KeyPairType RSA::parse_rsa_key(ReadonlyBytes in) { // we are going to assign to at least one of these KeyPairType keypair; @@ -167,7 +167,7 @@ void RSA::import_private_key(const ByteBuffer& buffer, bool pem) { // so gods help me, I hate DER auto decoded_buffer = pem ? decode_pem(buffer) : buffer; - auto key = parse_rsa_key(decoded_buffer); + auto key = parse_rsa_key(decoded_buffer.span()); if (!key.private_key.length()) { dbg() << "We expected to see a private key, but we found none"; ASSERT_NOT_REACHED(); @@ -179,7 +179,7 @@ void RSA::import_public_key(const ByteBuffer& buffer, bool pem) { // so gods help me, I hate DER auto decoded_buffer = pem ? decode_pem(buffer) : buffer; - auto key = parse_rsa_key(decoded_buffer); + auto key = parse_rsa_key(decoded_buffer.span()); if (!key.public_key.length()) { dbg() << "We expected to see a public key, but we found none"; ASSERT_NOT_REACHED(); diff --git a/Libraries/LibCrypto/PK/RSA.h b/Libraries/LibCrypto/PK/RSA.h index a4f758efbc..6a5f56ad1b 100644 --- a/Libraries/LibCrypto/PK/RSA.h +++ b/Libraries/LibCrypto/PK/RSA.h @@ -26,6 +26,7 @@ #pragma once +#include #include #include #include @@ -119,7 +120,7 @@ class RSA : public PKSystem, RSAPublicKey; - static KeyPairType parse_rsa_key(const ByteBuffer&); + static KeyPairType parse_rsa_key(ReadonlyBytes); static KeyPairType generate_key_pair(size_t bits = 256) { IntegerType e { 65537 }; // :P