12#include "InternalCryptLib.h"
14#include <openssl/bn.h>
15#include <openssl/rsa.h>
16#include <openssl/objects.h>
17#include <openssl/evp.h>
79 EVP_MD_CTX *EvpVerifyCtx;
81 CONST EVP_MD *HashAlg;
89 if (RsaContext ==
NULL) {
93 if ((Message ==
NULL) || (MsgSize == 0) || (MsgSize > INT_MAX)) {
97 if ((Signature ==
NULL) || (SigSize == 0) || (SigSize > INT_MAX)) {
101 if (SaltLen != DigestLen) {
107 if (HashAlg ==
NULL) {
111 EvpRsaKey = EVP_PKEY_new ();
112 if (EvpRsaKey ==
NULL) {
116 EVP_PKEY_set1_RSA (EvpRsaKey, RsaContext);
118 EvpVerifyCtx = EVP_MD_CTX_create ();
119 if (EvpVerifyCtx ==
NULL) {
123 Result = EVP_DigestVerifyInit (EvpVerifyCtx, &KeyCtx, HashAlg,
NULL, EvpRsaKey) > 0;
124 if (KeyCtx ==
NULL) {
129 Result = EVP_PKEY_CTX_set_rsa_padding (KeyCtx, RSA_PKCS1_PSS_PADDING) > 0;
133 Result = EVP_PKEY_CTX_set_rsa_pss_saltlen (KeyCtx, SaltLen) > 0;
137 Result = EVP_PKEY_CTX_set_rsa_mgf1_md (KeyCtx, HashAlg) > 0;
141 Result = EVP_DigestVerifyUpdate (EvpVerifyCtx, Message, (UINT32)MsgSize) > 0;
145 Result = EVP_DigestVerifyFinal (EvpVerifyCtx, Signature, (UINT32)SigSize) > 0;
149 if (EvpRsaKey !=
NULL) {
150 EVP_PKEY_free (EvpRsaKey);
153 if (EvpVerifyCtx !=
NULL) {
154 EVP_MD_CTX_destroy (EvpVerifyCtx);
#define SHA512_DIGEST_SIZE
#define SHA256_DIGEST_SIZE
#define SHA384_DIGEST_SIZE
BOOLEAN EFIAPI RsaPssVerify(IN VOID *RsaContext, IN CONST UINT8 *Message, IN UINTN MsgSize, IN CONST UINT8 *Signature, IN UINTN SigSize, IN UINT16 DigestLen, IN UINT16 SaltLen)
STATIC const EVP_MD * GetEvpMD(IN UINT16 DigestLen)