diff options
author | fschildt <florian.schildt@protonmail.com> | 2025-08-22 15:23:11 +0200 |
---|---|---|
committer | fschildt <florian.schildt@protonmail.com> | 2025-08-22 15:23:11 +0200 |
commit | 2050c0e0576f05156f192aa4caf48834d2f28b14 (patch) | |
tree | ee58bd35b0df0a1bacfbc9700ed99ce80c99294e /src/crypto/rsa.h |
Diffstat (limited to 'src/crypto/rsa.h')
-rw-r--r-- | src/crypto/rsa.h | 19 |
1 files changed, 19 insertions, 0 deletions
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 <basic/basic.h> +#include <basic/arena.h> +#include <openssl/evp.h> + +// 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); + |