TianoCore EDK2 master
|
#include "InternalCryptLib.h"
#include <mbedtls/rsa.h>
Go to the source code of this file.
Functions | |
BOOLEAN EFIAPI | RsaGetKey (IN OUT VOID *RsaContext, IN RSA_KEY_TAG KeyTag, OUT UINT8 *BigNumber, IN OUT UINTN *BnSize) |
BOOLEAN EFIAPI | RsaGenerateKey (IN OUT VOID *RsaContext, IN UINTN ModulusLength, IN CONST UINT8 *PublicExponent, IN UINTN PublicExponentSize) |
BOOLEAN EFIAPI | RsaCheckKey (IN VOID *RsaContext) |
BOOLEAN EFIAPI | RsaPkcs1Sign (IN VOID *RsaContext, IN CONST UINT8 *MessageHash, IN UINTN HashSize, OUT UINT8 *Signature, IN OUT UINTN *SigSize) |
RSA Asymmetric Cipher Wrapper Implementation over MbedTLS.
This file implements following APIs which provide more capabilities for RSA: 1) RsaGetKey 2) RsaGenerateKey 3) RsaCheckKey 4) RsaPkcs1Sign
RFC 8017 - PKCS #1: RSA Cryptography Specifications Version 2.2
Copyright (c) 2024, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
Definition in file CryptRsaExt.c.
BOOLEAN EFIAPI RsaCheckKey | ( | IN VOID * | RsaContext | ) |
Validates key components of RSA context. NOTE: This function performs integrity checks on all the RSA key material, so the RSA key structure must contain all the private key data.
This function validates key components of RSA context in following aspects:
If RsaContext is NULL, then return FALSE.
[in] | RsaContext | Pointer to RSA context to check. |
TRUE | RSA key components are valid. |
FALSE | RSA key components are not valid. |
Definition at line 236 of file CryptRsaExt.c.
BOOLEAN EFIAPI RsaGenerateKey | ( | IN OUT VOID * | RsaContext, |
IN UINTN | ModulusLength, | ||
IN CONST UINT8 * | PublicExponent, | ||
IN UINTN | PublicExponentSize | ||
) |
Generates RSA key components.
This function generates RSA key components. It takes RSA public exponent Pe and length in bits of RSA modulus N as input, and generates all key components. If PublicExponent is NULL, the default RSA public exponent (0x10001) will be used.
Before this function can be invoked, pseudorandom number generator must be correctly initialized by RandomSeed().
If RsaContext is NULL, then return FALSE.
[in,out] | RsaContext | Pointer to RSA context being set. |
[in] | ModulusLength | Length of RSA modulus N in bits. |
[in] | PublicExponent | Pointer to RSA public exponent. |
[in] | PublicExponentSize | Size of RSA public exponent buffer in bytes. |
TRUE | RSA key component was generated successfully. |
FALSE | Invalid RSA key component tag. |
Definition at line 157 of file CryptRsaExt.c.
BOOLEAN EFIAPI RsaGetKey | ( | IN OUT VOID * | RsaContext, |
IN RSA_KEY_TAG | KeyTag, | ||
OUT UINT8 * | BigNumber, | ||
IN OUT UINTN * | BnSize | ||
) |
Gets the tag-designated RSA key component from the established RSA context.
This function retrieves the tag-designated RSA key component from the established RSA context as a non-negative integer (octet string format represented in RSA PKCS#1). If specified key component has not been set or has been cleared, then returned BnSize is set to 0. If the BigNumber buffer is too small to hold the contents of the key, FALSE is returned and BnSize is set to the required buffer size to obtain the key.
If RsaContext is NULL, then return FALSE. If BnSize is NULL, then return FALSE. If BnSize is large enough but BigNumber is NULL, then return FALSE.
[in,out] | RsaContext | Pointer to RSA context being set. |
[in] | KeyTag | Tag of RSA key component being set. |
[out] | BigNumber | Pointer to octet integer buffer. |
[in,out] | BnSize | On input, the size of big number buffer in bytes. On output, the size of data returned in big number buffer in bytes. |
TRUE | RSA key component was retrieved successfully. |
FALSE | Invalid RSA key component tag. |
FALSE | BnSize is too small. |
Definition at line 48 of file CryptRsaExt.c.
BOOLEAN EFIAPI RsaPkcs1Sign | ( | IN VOID * | RsaContext, |
IN CONST UINT8 * | MessageHash, | ||
IN UINTN | HashSize, | ||
OUT UINT8 * | Signature, | ||
IN OUT UINTN * | SigSize | ||
) |
Carries out the RSA-SSA signature generation with EMSA-PKCS1-v1_5 encoding scheme.
This function carries out the RSA-SSA signature generation with EMSA-PKCS1-v1_5 encoding scheme defined in RSA PKCS#1. If the Signature buffer is too small to hold the contents of signature, FALSE is returned and SigSize is set to the required buffer size to obtain the signature.
If RsaContext is NULL, then return FALSE. If MessageHash is NULL, then return FALSE. If HashSize is not equal to the size of MD5, SHA-1, SHA-256, SHA-384 or SHA-512 digest, then return FALSE. If SigSize is large enough but Signature is NULL, then return FALSE.
[in] | RsaContext | Pointer to RSA context for signature generation. |
[in] | MessageHash | Pointer to octet message hash to be signed. |
[in] | HashSize | Size of the message hash in bytes. |
[out] | Signature | Pointer to buffer to receive RSA PKCS1-v1_5 signature. |
[in,out] | SigSize | On input, the size of Signature buffer in bytes. On output, the size of data returned in Signature buffer in bytes. |
TRUE | Signature successfully generated in PKCS1-v1_5. |
FALSE | Signature generation failed. |
FALSE | SigSize is too small. |
Definition at line 281 of file CryptRsaExt.c.