Add RSA keypair generation and signing implementation for Overte authentication
This commit is contained in:
32
src/RSAKeypair.hpp
Normal file
32
src/RSAKeypair.hpp
Normal file
@@ -0,0 +1,32 @@
|
||||
// RSAKeypair.hpp - RSA keypair generation and signing for Overte authentication
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <cstdint>
|
||||
|
||||
class RSAKeypair {
|
||||
public:
|
||||
RSAKeypair();
|
||||
~RSAKeypair();
|
||||
|
||||
// Generate a new 2048-bit RSA keypair
|
||||
bool generate();
|
||||
|
||||
// Sign plaintext with SHA256 + RSA
|
||||
std::vector<uint8_t> sign(const std::vector<uint8_t>& plaintext) const;
|
||||
|
||||
// Get DER-encoded keys
|
||||
std::vector<uint8_t> getPublicKeyDER() const { return m_publicKey; }
|
||||
std::vector<uint8_t> getPrivateKeyDER() const { return m_privateKey; }
|
||||
|
||||
// Set keys from DER encoding (for loading from file)
|
||||
void setKeys(const std::vector<uint8_t>& publicKey, const std::vector<uint8_t>& privateKey);
|
||||
|
||||
// Check if keypair is valid
|
||||
bool isValid() const { return !m_privateKey.empty() && !m_publicKey.empty(); }
|
||||
|
||||
private:
|
||||
std::vector<uint8_t> m_publicKey;
|
||||
std::vector<uint8_t> m_privateKey;
|
||||
};
|
||||
Reference in New Issue
Block a user