#include <openssl/objects.h>\r
#include <openssl/evp.h>\r
\r
-\r
/**\r
Retrieve a pointer to EVP message digest object.\r
\r
**/\r
STATIC\r
const\r
-EVP_MD*\r
+EVP_MD *\r
GetEvpMD (\r
- IN UINT16 DigestLen\r
+ IN UINT16 DigestLen\r
)\r
{\r
- switch (DigestLen){\r
+ switch (DigestLen) {\r
case SHA256_DIGEST_SIZE:\r
- return EVP_sha256();\r
+ return EVP_sha256 ();\r
break;\r
case SHA384_DIGEST_SIZE:\r
- return EVP_sha384();\r
+ return EVP_sha384 ();\r
break;\r
case SHA512_DIGEST_SIZE:\r
- return EVP_sha512();\r
+ return EVP_sha512 ();\r
break;\r
default:\r
return NULL;\r
}\r
}\r
\r
-\r
/**\r
Carries out the RSA-SSA signature generation with EMSA-PSS encoding scheme.\r
\r
IN OUT UINTN *SigSize\r
)\r
{\r
- BOOLEAN Result;\r
- UINTN RsaSigSize;\r
- EVP_PKEY *EvpRsaKey;\r
- EVP_MD_CTX *EvpVerifyCtx;\r
- EVP_PKEY_CTX *KeyCtx;\r
- CONST EVP_MD *HashAlg;\r
-\r
- Result = FALSE;\r
- EvpRsaKey = NULL;\r
+ BOOLEAN Result;\r
+ UINTN RsaSigSize;\r
+ EVP_PKEY *EvpRsaKey;\r
+ EVP_MD_CTX *EvpVerifyCtx;\r
+ EVP_PKEY_CTX *KeyCtx;\r
+ CONST EVP_MD *HashAlg;\r
+\r
+ Result = FALSE;\r
+ EvpRsaKey = NULL;\r
EvpVerifyCtx = NULL;\r
- KeyCtx = NULL;\r
- HashAlg = NULL;\r
+ KeyCtx = NULL;\r
+ HashAlg = NULL;\r
\r
if (RsaContext == NULL) {\r
return FALSE;\r
}\r
- if (Message == NULL || MsgSize == 0 || MsgSize > INT_MAX) {\r
+\r
+ if ((Message == NULL) || (MsgSize == 0) || (MsgSize > INT_MAX)) {\r
return FALSE;\r
}\r
\r
return FALSE;\r
}\r
\r
- HashAlg = GetEvpMD(DigestLen);\r
+ HashAlg = GetEvpMD (DigestLen);\r
\r
if (HashAlg == NULL) {\r
return FALSE;\r
}\r
\r
- EvpRsaKey = EVP_PKEY_new();\r
+ EvpRsaKey = EVP_PKEY_new ();\r
if (EvpRsaKey == NULL) {\r
goto _Exit;\r
}\r
\r
- EVP_PKEY_set1_RSA(EvpRsaKey, RsaContext);\r
+ EVP_PKEY_set1_RSA (EvpRsaKey, RsaContext);\r
\r
- EvpVerifyCtx = EVP_MD_CTX_create();\r
+ EvpVerifyCtx = EVP_MD_CTX_create ();\r
if (EvpVerifyCtx == NULL) {\r
goto _Exit;\r
}\r
\r
- Result = EVP_DigestSignInit(EvpVerifyCtx, &KeyCtx, HashAlg, NULL, EvpRsaKey) > 0;\r
+ Result = EVP_DigestSignInit (EvpVerifyCtx, &KeyCtx, HashAlg, NULL, EvpRsaKey) > 0;\r
if (KeyCtx == NULL) {\r
goto _Exit;\r
}\r
\r
if (Result) {\r
- Result = EVP_PKEY_CTX_set_rsa_padding(KeyCtx, RSA_PKCS1_PSS_PADDING) > 0;\r
+ Result = EVP_PKEY_CTX_set_rsa_padding (KeyCtx, RSA_PKCS1_PSS_PADDING) > 0;\r
}\r
+\r
if (Result) {\r
- Result = EVP_PKEY_CTX_set_rsa_pss_saltlen(KeyCtx, SaltLen) > 0;\r
+ Result = EVP_PKEY_CTX_set_rsa_pss_saltlen (KeyCtx, SaltLen) > 0;\r
}\r
+\r
if (Result) {\r
- Result = EVP_PKEY_CTX_set_rsa_mgf1_md(KeyCtx, HashAlg) > 0;\r
+ Result = EVP_PKEY_CTX_set_rsa_mgf1_md (KeyCtx, HashAlg) > 0;\r
}\r
+\r
if (Result) {\r
- Result = EVP_DigestSignUpdate(EvpVerifyCtx, Message, (UINT32)MsgSize) > 0;\r
+ Result = EVP_DigestSignUpdate (EvpVerifyCtx, Message, (UINT32)MsgSize) > 0;\r
}\r
+\r
if (Result) {\r
- Result = EVP_DigestSignFinal(EvpVerifyCtx, Signature, SigSize) > 0;\r
+ Result = EVP_DigestSignFinal (EvpVerifyCtx, Signature, SigSize) > 0;\r
}\r
\r
-_Exit :\r
+_Exit:\r
if (EvpRsaKey != NULL) {\r
- EVP_PKEY_free(EvpRsaKey);\r
+ EVP_PKEY_free (EvpRsaKey);\r
}\r
+\r
if (EvpVerifyCtx != NULL) {\r
- EVP_MD_CTX_destroy(EvpVerifyCtx);\r
+ EVP_MD_CTX_destroy (EvpVerifyCtx);\r
}\r
\r
return Result;\r