12#include "InternalCryptLib.h"
14#include <openssl/bn.h>
15#include <openssl/rsa.h>
16#include <openssl/objects.h>
17#include <openssl/evp.h>
94 EVP_MD_CTX *EvpVerifyCtx;
96 CONST EVP_MD *HashAlg;
104 if (RsaContext ==
NULL) {
108 if ((Message ==
NULL) || (MsgSize == 0) || (MsgSize > INT_MAX)) {
112 RsaSigSize = RSA_size (RsaContext);
113 if (*SigSize < RsaSigSize) {
114 *SigSize = RsaSigSize;
118 if (Signature ==
NULL) {
122 if (SaltLen != DigestLen) {
128 if (HashAlg ==
NULL) {
132 EvpRsaKey = EVP_PKEY_new ();
133 if (EvpRsaKey ==
NULL) {
137 EVP_PKEY_set1_RSA (EvpRsaKey, RsaContext);
139 EvpVerifyCtx = EVP_MD_CTX_create ();
140 if (EvpVerifyCtx ==
NULL) {
144 Result = EVP_DigestSignInit (EvpVerifyCtx, &KeyCtx, HashAlg,
NULL, EvpRsaKey) > 0;
145 if (KeyCtx ==
NULL) {
150 Result = EVP_PKEY_CTX_set_rsa_padding (KeyCtx, RSA_PKCS1_PSS_PADDING) > 0;
154 Result = EVP_PKEY_CTX_set_rsa_pss_saltlen (KeyCtx, SaltLen) > 0;
158 Result = EVP_PKEY_CTX_set_rsa_mgf1_md (KeyCtx, HashAlg) > 0;
162 Result = EVP_DigestSignUpdate (EvpVerifyCtx, Message, (UINT32)MsgSize) > 0;
166 Result = EVP_DigestSignFinal (EvpVerifyCtx, Signature, SigSize) > 0;
170 if (EvpRsaKey !=
NULL) {
171 EVP_PKEY_free (EvpRsaKey);
174 if (EvpVerifyCtx !=
NULL) {
175 EVP_MD_CTX_destroy (EvpVerifyCtx);
#define SHA512_DIGEST_SIZE
#define SHA256_DIGEST_SIZE
#define SHA384_DIGEST_SIZE
BOOLEAN EFIAPI RsaPssSign(IN VOID *RsaContext, IN CONST UINT8 *Message, IN UINTN MsgSize, IN UINT16 DigestLen, IN UINT16 SaltLen, OUT UINT8 *Signature, IN OUT UINTN *SigSize)
STATIC const EVP_MD * GetEvpMD(IN UINT16 DigestLen)