From 2050c0e0576f05156f192aa4caf48834d2f28b14 Mon Sep 17 00:00:00 2001 From: fschildt Date: Fri, 22 Aug 2025 15:23:11 +0200 Subject: first commit --- src/crypto/rsa.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/crypto/rsa.h (limited to 'src/crypto/rsa.h') diff --git a/src/crypto/rsa.h b/src/crypto/rsa.h new file mode 100644 index 0000000..cace9dc --- /dev/null +++ b/src/crypto/rsa.h @@ -0,0 +1,19 @@ +#include +#include +#include + +// Note: The rsa input size is calculated by modulus_size - 2*hash_len - 2 +// The rsa input size for 4096bit key and SHA-512 = 512-(2*64)-2 = 382 bytes +// The rsa output size is always equal to the modulus_size (key_size) + +// Note: The arena in rsa_create_via_file only uses it temporarily and cleans it up. + +EVP_PKEY *rsa_create_via_file(Arena *arena, char *filepath, b32 is_public); +EVP_PKEY *rsa_create_via_gen(i32 keysize_in_bits); +EVP_PKEY *rsa_create_via_pem(char *pem, size_t pem_len, b32 is_public); +void rsa_destroy(EVP_PKEY *key); + +b32 rsa_get_pem(EVP_PKEY *key, char *dest, size_t dest_size); +b32 rsa_encrypt(EVP_PKEY *key, void *dest, void *src, size_t size); +b32 rsa_decrypt(EVP_PKEY *key, void *dest, void *src, size_t size); + -- cgit v1.2.3