TianoCore EDK2 master
Loading...
Searching...
No Matches
CryptRsaBasic.c File Reference
#include "InternalCryptLib.h"
#include <mbedtls/rsa.h>

Go to the source code of this file.

Functions

VOID *EFIAPI RsaNew (VOID)
 
VOID EFIAPI RsaFree (IN VOID *RsaContext)
 
BOOLEAN EFIAPI RsaSetKey (IN OUT VOID *RsaContext, IN RSA_KEY_TAG KeyTag, IN CONST UINT8 *BigNumber, IN UINTN BnSize)
 
BOOLEAN EFIAPI RsaPkcs1Verify (IN VOID *RsaContext, IN CONST UINT8 *MessageHash, IN UINTN HashSize, IN CONST UINT8 *Signature, IN UINTN SigSize)
 

Detailed Description

RSA Asymmetric Cipher Wrapper Implementation over MbedTLS.

This file implements following APIs which provide basic capabilities for RSA: 1) RsaNew 2) RsaFree 3) RsaSetKey 4) RsaPkcs1Verify

RFC 8017 - PKCS #1: RSA Cryptography Specifications Version 2.2

Copyright (c) 2023, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file CryptRsaBasic.c.

Function Documentation

◆ RsaFree()

VOID EFIAPI RsaFree ( IN VOID *  RsaContext)

Release the specified RSA context.

Parameters
[in]RsaContextPointer to the RSA context to be released.

Definition at line 57 of file CryptRsaBasic.c.

◆ RsaNew()

VOID *EFIAPI RsaNew ( VOID  )

Allocates and initializes one RSA context for subsequent use.

Returns
Pointer to the RSA context that has been initialized. If the allocations fails, RsaNew() returns NULL.

Definition at line 30 of file CryptRsaBasic.c.

◆ RsaPkcs1Verify()

BOOLEAN EFIAPI RsaPkcs1Verify ( IN VOID *  RsaContext,
IN CONST UINT8 *  MessageHash,
IN UINTN  HashSize,
IN CONST UINT8 *  Signature,
IN UINTN  SigSize 
)

Verifies the RSA-SSA signature with EMSA-PKCS1-v1_5 encoding scheme defined in RSA PKCS#1.

If RsaContext is NULL, then return FALSE. If MessageHash is NULL, then return FALSE. If Signature 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.

Parameters
[in]RsaContextPointer to RSA context for signature verification.
[in]MessageHashPointer to octet message hash to be checked.
[in]HashSizeSize of the message hash in bytes.
[in]SignaturePointer to RSA PKCS1-v1_5 signature to be verified.
[in]SigSizeSize of signature in bytes.
Return values
TRUEValid signature encoded in PKCS1-v1_5.
FALSEInvalid signature or invalid RSA context.

Definition at line 206 of file CryptRsaBasic.c.

◆ RsaSetKey()

BOOLEAN EFIAPI RsaSetKey ( IN OUT VOID *  RsaContext,
IN RSA_KEY_TAG  KeyTag,
IN CONST UINT8 *  BigNumber,
IN UINTN  BnSize 
)

Sets the tag-designated key component into the established RSA context.

This function sets the tag-designated RSA key component into the established RSA context from the user-specified non-negative integer (octet string format represented in RSA PKCS#1). If BigNumber is NULL, then the specified key component in RSA context is cleared.

If RsaContext is NULL, then return FALSE.

Parameters
[in,out]RsaContextPointer to RSA context being set.
[in]KeyTagTag of RSA key component being set.
[in]BigNumberPointer to octet integer buffer. If NULL, then the specified key component in RSA context is cleared.
[in]BnSizeSize of big number buffer in bytes. If BigNumber is NULL, then it is ignored.
Return values
TRUERSA key component was set successfully.
FALSEInvalid RSA key component tag.

Definition at line 91 of file CryptRsaBasic.c.