cli MVP
This commit is contained in:
parent
367c19386c
commit
1ea50c50bc
62 changed files with 9982 additions and 608 deletions
|
|
@ -1,5 +1,5 @@
|
|||
//SPDX-License-Identifier: LGPL-3.0-only
|
||||
//SPDX-FileCopyrightText: Copyright (C) 2026 Catcrafts®
|
||||
// SPDX-License-Identifier: LGPL-3.0-only
|
||||
// SPDX-FileCopyrightText: Copyright (C) 2026 Catcrafts®
|
||||
|
||||
module;
|
||||
|
||||
|
|
@ -14,7 +14,7 @@ export module Nostro:Crypto;
|
|||
import std;
|
||||
|
||||
export namespace Nostro::Crypto {
|
||||
long ThrowOnOpenssl(long status);
|
||||
std::int64_t ThrowOnOpenssl(std::int64_t status);
|
||||
|
||||
template <typename T>
|
||||
T* ThrowOnOpenssl(T* pointer) {
|
||||
|
|
@ -25,9 +25,22 @@ export namespace Nostro::Crypto {
|
|||
return pointer;
|
||||
}
|
||||
|
||||
// A key that frees itself; copies share it.
|
||||
using Key = std::shared_ptr<EVP_PKEY>;
|
||||
Key OwnKey(EVP_PKEY* key);
|
||||
|
||||
// RSA PKCS#1 v1.5 over SHA-256, base64: what bunq expects in X-Bunq-Client-Signature.
|
||||
std::string SignBody(EVP_PKEY* privateKey, std::string_view body);
|
||||
// Checks a base64 signature made as SignBody makes one, with the signer's public key.
|
||||
bool VerifyBody(EVP_PKEY* publicKey, std::string_view body, std::string_view signature);
|
||||
// A new 2048-bit RSA key pair and its public half in PEM.
|
||||
std::tuple<EVP_PKEY*, std::string> CreateKey();
|
||||
EVP_PKEY* LoadKeyFromPem(std::string_view pem);
|
||||
EVP_PKEY* LoadPublicKeyFromPem(std::string_view pem);
|
||||
std::string PrivateKeyToPem(EVP_PKEY* key);
|
||||
std::string PublicKeyToPem(EVP_PKEY* key);
|
||||
// `bytes` random bytes from the system's CSPRNG, as lower-case hex.
|
||||
std::string RandomHex(std::size_t bytes);
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in a new issue