RSA_PRIVATE_ENCRYPT(3SSL)
π RSA_PRIVATE_ENCRYPT π
okay bestie so this is a page from the OpenSSL manual, and it's filed under 3SSL β and listen, the two functions here are RSA_private_encrypt and RSA_public_decrypt, which do low-level signature operations. low-level. like, down in the basement. we're gonna talk about them anyway bc you deserve to know, but also I'm gonna tell you the whole time that they're deprecated, so don't get attached π«Ά
β¨ NAME β¨
RSA_private_encrypt, RSA_public_decrypt β low-level signature operations π
β¨ SYNOPSIS β¨
#include <openssl/rsa.h>
The following functions have been deprecated since OpenSSL 3.0, and can be hidden entirely by defining OPENSSL_API_COMPAT with a suitable version value, see openssl_user_macros(7):
int RSA_private_encrypt(int flen, unsigned char *from,
unsigned char *to, RSA *rsa, int padding);
int RSA_public_decrypt(int flen, unsigned char *from,
unsigned char *to, RSA *rsa, int padding);
β¨ DESCRIPTION β¨
π¨ the big disclaimer, read it first π¨
Both of the functions described on this page are deprecated. π I'm not being dramatic (okay I'm being a little dramatic, but it's true). Applications should instead use EVP_PKEY_sign_init_ex(3), EVP_PKEY_sign(3), EVP_PKEY_verify_recover_init(3), and EVP_PKEY_verify_recover(3). those are the icons. those are the main characters. go use those π
These functions handle RSA signatures at a low-level. like, manual-transmission level. iykyk.
π« RSA_private_encrypt()
RSA_private_encrypt() signs the flen bytes at from (usually a message digest with an algorithm identifier) using the private key rsa and stores the signature in to. to must point to RSA_size(rsa) bytes of memory. no more, no less, she's specific like that β¨
padding denotes one of the following modes:
RSA_PKCS1_PADDINGβ PKCS #1 v1.5 padding. heads up: this function does not handle thealgorithmIdentifierspecified in PKCS #1. So when you're generating or verifying PKCS #1 signatures,RSA_sign(3)andRSA_verify(3)should be used instead. not me warning you in advance π«ΆRSA_NO_PADDINGβ Raw RSA signature. this mode should only be used to implement cryptographically sound padding modes in the application code. and listen: signing user data directly with RSA is insecure. that's not me being cute, that's just facts, fr fr. π
π« RSA_public_decrypt()
RSA_public_decrypt() recovers the message digest from the flen bytes long signature at from using the signer's public key rsa. to must point to a memory section large enough to hold the message digest β and the digest is smaller than RSA_size(rsa) - 11. do the math, girlie, allocate accordingly πΈ
padding is the padding mode that was used to sign the data. it's giving "match your keys to your locks" energy π
β¨ RETURN VALUES β¨
RSA_private_encrypt()returns the size of the signature (i.e.,RSA_size(rsa)). slay, predictable πRSA_public_decrypt()returns the size of the recovered message digest.
On error, -1 is returned; the error codes can be obtained by ERR_get_error(3). so if you see a -1, go ask ERR_get_error(3) what went wrong, she'll tell you π
β¨ SEE ALSO β¨
ERR_get_error(3), RSA_sign(3), RSA_verify(3), EVP_PKEY_sign(3), EVP_PKEY_verify_recover(3)
(the first three are the old crew, the last two are the glow-up π)
β¨ HISTORY β¨
Both of these functions were deprecated in OpenSSL 3.0. that's it, that's the history, she was iconic and then she was deprecated π
β¨ COPYRIGHT β¨
Copyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.
and that's the whole page, bestie!! this was OpenSSL version 4.0.3, dated 2026-09-29, filed under RSA_PRIVATE_ENCRYPT(3SSL). go forth, use the EVP functions, hydrate, and don't sign raw user data with RSA π§πβ¨
π¦ where this page comes from
- ubuntu stonking: libssl-doc 4.0.3-1ubuntu1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms