RSA_SIGN(3ossl)
π RSA_SIGN β bestie's guide to RSA signatures (OpenSSL, 3ossl manual) π
okay so real talk, this page is the RSA_sign / RSA_verify lore, and it comes to you straight from the OpenSSL manual set. sit down, grab a boba, we're doing cryptography gossip. π§β¨
β¨ NAME β¨
RSA_sign, RSA_verify β RSA signatures. that's the whole vibe. π
π¦ SYNOPSIS π¦
first things first, you gotta include the header:
#include <openssl/rsa.h>
π¨ DEPRECATION ALERT, NO CAP π¨ β the following functions have been deprecated since OpenSSL 3.0, and can be hidden entirely by definingOPENSSL_API_COMPATwith a suitable version value, seeopenssl_user_macros(7). so like, they're still here, but they're giving "living in the past" energy.
int RSA_sign(int type, const unsigned char *m, unsigned int m_len,
unsigned char *sigret, unsigned int *siglen, RSA *rsa);
int RSA_verify(int type, const unsigned char *m, unsigned int m_len,
unsigned char *sigbuf, unsigned int siglen, RSA *rsa);
πΈ DESCRIPTION πΈ
okay so, deep breath, all of the functions described on this page are deprecated. all of them. every single one. π
Applications should instead use EVP_PKEY_sign_init(3), EVP_PKEY_sign(3), EVP_PKEY_verify_init(3) and EVP_PKEY_verify(3). that's the glow-up. that's the main character era. go there. π«Ά
π RSA_sign() β the signing one
RSA_sign() signs the message digest m of size m_len using the private key rsa using RSASSA-PKCS1-v1_5 as specified in RFC 3447. it stores the signature in sigret and the signature size in siglen.
sigret must point to RSA_size(rsa) bytes of memory. like, that's not optional, bestie, that's a hard requirement. β
β οΈ Note that PKCS #1 adds meta-data, placing limits on the size of the key that can be used. so your key size options are, in fact, capped. sorry not sorry.
See RSA_private_encrypt(3) for lower-level operations, if you're feeling spicy and want to go deeper down the stack. π₯
type denotes the message digest algorithm that was used to generate m. and here's a fun little special case β if type is NID_md5_sha1, an SSL signature is created (MD5 and SHA1 message digests with PKCS #1 padding and no algorithm identifier). iconic, chaotic, historic. π
π RSA_verify() β the verifying one
RSA_verify() verifies that the signature sigbuf of size siglen matches a given message digest m of size m_len.
type denotes the message digest algorithm that was used to generate the signature. rsa is the signer's public key. π
π RETURN VALUES π
RSA_sign()returns1on success and0for failure. slay or flop, no in-between. β¨RSA_verify()returns1on successful verification and0for failure.
The error codes can be obtained by ERR_get_error(3). go get your receipts, bestie. π§Ύ
π CONFORMING TO π
SSL, PKCS #1 v2.0. certified. periodt. π
π SEE ALSO π
go read those too, iykyk. π¦
β HISTORY β
All of these functions were deprecated in OpenSSL 3.0. that's the whole history section. short, sweet, devastating. π
π COPYRIGHT π
Copyright 2000-2020 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 page, bestie!! π this whole thing came from the OpenSSL 3.5.9 manual, dated 2026-09-29 β so if you're reading it and it feels vintage, that's because it literally is. mwah, stay encrypted, drink water, go use EVP_PKEY_sign(3). π«Άβ¨π
π¦ where this page comes from
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms