12#include "InternalCryptLib.h"
13#include <mbedtls/rsa.h>
14#include <mbedtls/sha256.h>
15#include <mbedtls/sha512.h>
62 mbedtls_md_type_t MdAlg;
65 if (RsaContext ==
NULL) {
69 if (mbedtls_rsa_complete ((mbedtls_rsa_context *)RsaContext) != 0) {
73 if ((Message ==
NULL) || (MsgSize == 0) || (MsgSize > INT_MAX)) {
77 if (SaltLen != DigestLen) {
85 MdAlg = MBEDTLS_MD_SHA256;
86 if (mbedtls_sha256 (Message, MsgSize, HashValue,
FALSE) != 0) {
93 MdAlg = MBEDTLS_MD_SHA384;
94 if (mbedtls_sha512 (Message, MsgSize, HashValue,
TRUE) != 0) {
101 MdAlg = MBEDTLS_MD_SHA512;
102 if (mbedtls_sha512 (Message, MsgSize, HashValue,
FALSE) != 0) {
112 if (Signature ==
NULL) {
116 *SigSize = MBEDTLS_MPI_MAX_SIZE;
120 Ret = mbedtls_rsa_set_padding (RsaContext, MBEDTLS_RSA_PKCS_V21, MdAlg);
125 Ret = mbedtls_rsa_rsassa_pss_sign (
138 *SigSize = ((mbedtls_rsa_context *)RsaContext)->len;
#define SHA512_DIGEST_SIZE
#define SHA256_DIGEST_SIZE
#define SHA384_DIGEST_SIZE
INT32 MbedtlsRand(VOID *RngState, UINT8 *Output, UINTN Len)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
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)