summaryrefslogtreecommitdiff
path: root/Libraries
diff options
context:
space:
mode:
authorasynts <asynts@gmail.com>2020-07-27 15:20:27 +0200
committerAndreas Kling <kling@serenityos.org>2020-07-27 19:58:09 +0200
commit3de4e08b465514dd978e4a3c80c9fd0e9e414c7b (patch)
tree294c96faedd63b8c4627ad6bab5391e070db85b5 /Libraries
parent0d782e1dfbee2b48e7f46a2cde7f98357aa244dc (diff)
downloadserenity-3de4e08b465514dd978e4a3c80c9fd0e9e414c7b.zip
LibCrypto: Change the signature of decode_pem to use Span.
Diffstat (limited to 'Libraries')
-rw-r--r--Libraries/LibCrypto/ASN1/PEM.h5
-rw-r--r--Libraries/LibCrypto/PK/RSA.cpp4
2 files changed, 5 insertions, 4 deletions
diff --git a/Libraries/LibCrypto/ASN1/PEM.h b/Libraries/LibCrypto/ASN1/PEM.h
index f55bbc46ad..24afb7c128 100644
--- a/Libraries/LibCrypto/ASN1/PEM.h
+++ b/Libraries/LibCrypto/ASN1/PEM.h
@@ -26,12 +26,13 @@
#pragma once
+#include <AK/Span.h>
#include <LibCrypto/ASN1/ASN1.h>
#include <LibCrypto/ASN1/DER.h>
namespace Crypto {
-static ByteBuffer decode_pem(const ByteBuffer& data_in, size_t cert_index = 0)
+static ByteBuffer decode_pem(ReadonlyBytes data_in, size_t cert_index = 0)
{
size_t i { 0 };
size_t start_at { 0 };
@@ -61,7 +62,7 @@ static ByteBuffer decode_pem(const ByteBuffer& data_in, size_t cert_index = 0)
cert_index--;
start_at = 0;
} else {
- idx = decode_b64(data_in.offset_pointer(start_at), end_idx - start_at, output);
+ idx = decode_b64(data_in.offset(start_at), end_idx - start_at, output);
break;
}
} else
diff --git a/Libraries/LibCrypto/PK/RSA.cpp b/Libraries/LibCrypto/PK/RSA.cpp
index 74b999661e..5e0f12cba7 100644
--- a/Libraries/LibCrypto/PK/RSA.cpp
+++ b/Libraries/LibCrypto/PK/RSA.cpp
@@ -166,7 +166,7 @@ void RSA::verify(const ByteBuffer& in, ByteBuffer& out)
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 decoded_buffer = pem ? decode_pem(buffer.span()) : 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";
@@ -178,7 +178,7 @@ void RSA::import_private_key(const ByteBuffer& buffer, bool pem)
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 decoded_buffer = pem ? decode_pem(buffer.span()) : 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";