OpenCore
1.0.4
OpenCore Bootloader
|
#include "BigNumLib.h"
Go to the source code of this file.
Functions | |
STATIC BOOLEAN | InternalRsaModulusSizeIsAllowed (IN OC_BN_SIZE ModulusSize) |
STATIC BOOLEAN | InternalSigHashTypeIsAllowed (IN OC_SIG_HASH_TYPE Type) |
INTN | SigVerifyShaHashBySize (IN CONST VOID *Data, IN UINTN DataSize, IN CONST UINT8 *Hash, IN UINTN HashSize) |
STATIC BOOLEAN | RsaVerifySigHashFromProcessed (IN CONST OC_BN_WORD *N, IN OC_BN_NUM_WORDS NumWords, IN OC_BN_WORD N0Inv, IN CONST OC_BN_WORD *RSqrMod, IN UINT32 Exponent, IN CONST UINT8 *Signature, IN UINTN SignatureSize, IN CONST UINT8 *Hash, IN UINTN HashSize, IN OC_SIG_HASH_TYPE Algorithm, IN OC_BN_WORD *Scratch) |
STATIC BOOLEAN | RsaVerifySigDataFromProcessed (IN CONST OC_BN_WORD *N, IN OC_BN_NUM_WORDS NumWords, IN OC_BN_WORD N0Inv, IN CONST OC_BN_WORD *RSqrMod, IN UINT32 Exponent, IN CONST UINT8 *Signature, IN UINTN SignatureSize, IN CONST UINT8 *Data, IN UINTN DataSize, IN OC_SIG_HASH_TYPE Algorithm, IN OC_BN_WORD *Scratch) |
BOOLEAN | RsaVerifySigDataFromData (IN CONST UINT8 *Modulus, IN UINTN ModulusSize, IN UINT32 Exponent, IN CONST UINT8 *Signature, IN UINTN SignatureSize, IN CONST UINT8 *Data, IN UINTN DataSize, IN OC_SIG_HASH_TYPE Algorithm) |
BOOLEAN | RsaVerifySigHashFromKey (IN CONST OC_RSA_PUBLIC_KEY *Key, IN CONST UINT8 *Signature, IN UINTN SignatureSize, IN CONST UINT8 *Hash, IN UINTN HashSize, IN OC_SIG_HASH_TYPE Algorithm, IN VOID *Scratch) |
BOOLEAN | RsaVerifySigHashFromKeyDynalloc (IN CONST OC_RSA_PUBLIC_KEY *Key, IN CONST UINT8 *Signature, IN UINTN SignatureSize, IN CONST UINT8 *Hash, IN UINTN HashSize, IN OC_SIG_HASH_TYPE Algorithm) |
BOOLEAN | RsaVerifySigDataFromKey (IN CONST OC_RSA_PUBLIC_KEY *Key, IN CONST UINT8 *Signature, IN UINTN SignatureSize, IN CONST UINT8 *Data, IN UINTN DataSize, IN OC_SIG_HASH_TYPE Algorithm, IN VOID *Scratch) |
BOOLEAN | RsaVerifySigDataFromKeyDynalloc (IN CONST OC_RSA_PUBLIC_KEY *Key, IN CONST UINT8 *Signature, IN UINTN SignatureSize, IN CONST UINT8 *Data, IN UINTN DataSize, IN OC_SIG_HASH_TYPE Algorithm) |
This library performs RSA-based cryptography operations.
SECURITY: Currently, no security measures have been taken. This code is vulnerable to both timing and side channel attacks for value leakage. However, its current purpose is the verification of public binaries with public certificates, for which this is perfectly acceptable, especially in regards to performance.
Copyright (C) 2019, Download-Fritz. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Definition in file RsaDigitalSign.c.
STATIC BOOLEAN InternalRsaModulusSizeIsAllowed | ( | IN OC_BN_SIZE | ModulusSize | ) |
Returns whether the RSA modulus size is allowed.
[in] | ModulusSize | The size, in bytes, of the RSA modulus. |
Definition at line 57 of file RsaDigitalSign.c.
STATIC BOOLEAN InternalSigHashTypeIsAllowed | ( | IN OC_SIG_HASH_TYPE | Type | ) |
Returns whether the signature hashing algorithm is allowed.
[in] | Type | The signature hashing algorithm type. |
Definition at line 79 of file RsaDigitalSign.c.
BOOLEAN RsaVerifySigDataFromData | ( | IN CONST UINT8 * | Modulus, |
IN UINTN | ModulusSize, | ||
IN UINT32 | Exponent, | ||
IN CONST UINT8 * | Signature, | ||
IN UINTN | SignatureSize, | ||
IN CONST UINT8 * | Data, | ||
IN UINTN | DataSize, | ||
IN OC_SIG_HASH_TYPE | Algorithm ) |
Verify RSA PKCS1.5 signed data against its signature. The modulus' size must be a multiple of the configured BIGNUM word size. This will be true for any conventional RSA, which use two's potencies.
[in] | Modulus | The RSA modulus byte array. |
[in] | ModulusSize | The size, in bytes, of Modulus. |
[in] | Exponent | The RSA exponent. |
[in] | Signature | The RSA signature to be verified. |
[in] | SignatureSize | Size, in bytes, of Signature. |
[in] | Data | The signed data to verify. |
[in] | DataSize | Size, in bytes, of Data. |
[in] | Algorithm | The RSA algorithm used. |
Definition at line 488 of file RsaDigitalSign.c.
BOOLEAN RsaVerifySigDataFromKey | ( | IN CONST OC_RSA_PUBLIC_KEY * | Key, |
IN CONST UINT8 * | Signature, | ||
IN UINTN | SignatureSize, | ||
IN CONST UINT8 * | Data, | ||
IN UINTN | DataSize, | ||
IN OC_SIG_HASH_TYPE | Algorithm, | ||
IN VOID * | Scratch ) |
Verify RSA PKCS1.5 signed data against its signature. The modulus' size must be a multiple of the configured BIGNUM word size. This will be true for any conventional RSA, which use two's potencies. The exponent is always 65537 as per the format specification.
[in] | Key | The RSA Public Key. |
[in] | Signature | The RSA signature to be verified. |
[in] | SignatureSize | Size, in bytes, of Signature. |
[in] | Data | The signed data to verify. |
[in] | DataSize | Size, in bytes, of Data. |
[in] | Algorithm | The RSA algorithm used. |
[in] | Scratch | Scratch buffer 3xModulo. |
Definition at line 673 of file RsaDigitalSign.c.
BOOLEAN RsaVerifySigDataFromKeyDynalloc | ( | IN CONST OC_RSA_PUBLIC_KEY * | Key, |
IN CONST UINT8 * | Signature, | ||
IN UINTN | SignatureSize, | ||
IN CONST UINT8 * | Data, | ||
IN UINTN | DataSize, | ||
IN OC_SIG_HASH_TYPE | Algorithm ) |
Verify RSA PKCS1.5 signed data against its signature. The modulus' size must be a multiple of the configured BIGNUM word size. This will be true for any conventional RSA, which use two's potencies. The exponent is always 65537 as per the format specification.
[in] | Key | The RSA Public Key. |
[in] | Signature | The RSA signature to be verified. |
[in] | SignatureSize | Size, in bytes, of Signature. |
[in] | Data | The signed data to verify. |
[in] | DataSize | Size, in bytes, of Data. |
[in] | Algorithm | The RSA algorithm used. |
Definition at line 715 of file RsaDigitalSign.c.
STATIC BOOLEAN RsaVerifySigDataFromProcessed | ( | IN CONST OC_BN_WORD * | N, |
IN OC_BN_NUM_WORDS | NumWords, | ||
IN OC_BN_WORD | N0Inv, | ||
IN CONST OC_BN_WORD * | RSqrMod, | ||
IN UINT32 | Exponent, | ||
IN CONST UINT8 * | Signature, | ||
IN UINTN | SignatureSize, | ||
IN CONST UINT8 * | Data, | ||
IN UINTN | DataSize, | ||
IN OC_SIG_HASH_TYPE | Algorithm, | ||
IN OC_BN_WORD * | Scratch ) |
Verify RSA PKCS1.5 signed data against its signature. The modulus' size must be a multiple of the configured BIGNUM word size. This will be true for any conventional RSA, which use two's potencies.
[in] | N | The RSA modulus. |
[in] | NumWords | The number of Words of N and RSqrMod. |
[in] | N0Inv | The Montgomery Inverse of N. |
[in] | RSqrMod | Montgomery's R^2 mod N. |
[in] | Exponent | The RSA exponent. |
[in] | Signature | The RSA signature to be verified. |
[in] | SignatureSize | Size, in bytes, of Signature. |
[in] | Data | The signed data to verify. |
[in] | DataSize | Size, in bytes, of Data. |
[in] | Algorithm | The RSA algorithm used. |
[in] | Scratch | Scratch buffer 3xModulo. |
Definition at line 401 of file RsaDigitalSign.c.
BOOLEAN RsaVerifySigHashFromKey | ( | IN CONST OC_RSA_PUBLIC_KEY * | Key, |
IN CONST UINT8 * | Signature, | ||
IN UINTN | SignatureSize, | ||
IN CONST UINT8 * | Hash, | ||
IN UINTN | HashSize, | ||
IN OC_SIG_HASH_TYPE | Algorithm, | ||
IN VOID * | Scratch ) |
Verify a RSA PKCS1.5 signature against an expected hash. The exponent is always 65537 as per the format specification.
[in] | Key | The RSA Public Key. |
[in] | Signature | The RSA signature to be verified. |
[in] | SignatureSize | Size, in bytes, of Signature. |
[in] | Hash | The Hash digest of the signed data. |
[in] | HashSize | Size, in bytes, of Hash. |
[in] | Algorithm | The RSA algorithm used. |
[in] | Scratch | Scratch buffer 3xModulo. |
Definition at line 589 of file RsaDigitalSign.c.
BOOLEAN RsaVerifySigHashFromKeyDynalloc | ( | IN CONST OC_RSA_PUBLIC_KEY * | Key, |
IN CONST UINT8 * | Signature, | ||
IN UINTN | SignatureSize, | ||
IN CONST UINT8 * | Hash, | ||
IN UINTN | HashSize, | ||
IN OC_SIG_HASH_TYPE | Algorithm ) |
Verify a RSA PKCS1.5 signature against an expected hash. The exponent is always 65537 as per the format specification.
[in] | Key | The RSA Public Key. |
[in] | Signature | The RSA signature to be verified. |
[in] | SignatureSize | Size, in bytes, of Signature. |
[in] | Hash | The Hash digest of the signed data. |
[in] | HashSize | Size, in bytes, of Hash. |
[in] | Algorithm | The RSA algorithm used. |
Definition at line 631 of file RsaDigitalSign.c.
STATIC BOOLEAN RsaVerifySigHashFromProcessed | ( | IN CONST OC_BN_WORD * | N, |
IN OC_BN_NUM_WORDS | NumWords, | ||
IN OC_BN_WORD | N0Inv, | ||
IN CONST OC_BN_WORD * | RSqrMod, | ||
IN UINT32 | Exponent, | ||
IN CONST UINT8 * | Signature, | ||
IN UINTN | SignatureSize, | ||
IN CONST UINT8 * | Hash, | ||
IN UINTN | HashSize, | ||
IN OC_SIG_HASH_TYPE | Algorithm, | ||
IN OC_BN_WORD * | Scratch ) |
Verify a RSA PKCS1.5 signature against an expected hash.
[in] | N | The RSA modulus. |
[in] | N0Inv | The Montgomery Inverse of N. |
[in] | RSqrMod | Montgomery's R^2 mod N. |
[in] | NumWords | The number of Words of N and RSqrMod. |
[in] | Exponent | The RSA exponent. |
[in] | Signature | The RSA signature to be verified. |
[in] | SignatureSize | Size, in bytes, of Signature. |
[in] | Hash | The Hash digest of the signed data. |
[in] | HashSize | Size, in bytes, of Hash. |
[in] | Algorithm | The RSA algorithm used. |
[in] | Scratch | Scratch buffer 3xModulo. |
Definition at line 164 of file RsaDigitalSign.c.
INTN SigVerifyShaHashBySize | ( | IN CONST VOID * | Data, |
IN UINTN | DataSize, | ||
IN CONST UINT8 * | Hash, | ||
IN UINTN | HashSize ) |
Verifies Data against Hash with the appropiate SHA2 algorithm for HashSize.
[in] | Data | The data to verify the hash of. |
[in] | DataSize | The, in bytes, of Data. |
[in] | Hash | The reference hash to verify against. |
[in] | HashSize | The size, in bytes, of Hash. |
Non-zero | If HashSize is not a valid SHA2 digest size, -1. Otherwise, the first mismatched byte in Data's hash subtracted from the first mismatched byte in Hash. |
Definition at line 87 of file RsaDigitalSign.c.