TianoCore EDK2 master
|
Go to the source code of this file.
Functions | |
VOID *EFIAPI | BigNumInit (VOID) |
VOID *EFIAPI | BigNumFromBin (IN CONST UINT8 *Buf, IN UINTN Len) |
INTN EFIAPI | BigNumToBin (IN CONST VOID *Bn, OUT UINT8 *Buf) |
VOID EFIAPI | BigNumFree (IN VOID *Bn, IN BOOLEAN Clear) |
BOOLEAN EFIAPI | BigNumAdd (IN CONST VOID *BnA, IN CONST VOID *BnB, OUT VOID *BnRes) |
BOOLEAN EFIAPI | BigNumSub (IN CONST VOID *BnA, IN CONST VOID *BnB, OUT VOID *BnRes) |
BOOLEAN EFIAPI | BigNumMod (IN CONST VOID *BnA, IN CONST VOID *BnB, OUT VOID *BnRes) |
BOOLEAN EFIAPI | BigNumExpMod (IN CONST VOID *BnA, IN CONST VOID *BnP, IN CONST VOID *BnM, OUT VOID *BnRes) |
BOOLEAN EFIAPI | BigNumInverseMod (IN CONST VOID *BnA, IN CONST VOID *BnM, OUT VOID *BnRes) |
BOOLEAN EFIAPI | BigNumDiv (IN CONST VOID *BnA, IN CONST VOID *BnB, OUT VOID *BnRes) |
BOOLEAN EFIAPI | BigNumMulMod (IN CONST VOID *BnA, IN CONST VOID *BnB, IN CONST VOID *BnM, OUT VOID *BnRes) |
INTN EFIAPI | BigNumCmp (IN CONST VOID *BnA, IN CONST VOID *BnB) |
UINTN EFIAPI | BigNumBits (IN CONST VOID *Bn) |
UINTN EFIAPI | BigNumBytes (IN CONST VOID *Bn) |
BOOLEAN EFIAPI | BigNumIsWord (IN CONST VOID *Bn, IN UINTN Num) |
BOOLEAN EFIAPI | BigNumIsOdd (IN CONST VOID *Bn) |
VOID *EFIAPI | BigNumCopy (OUT VOID *BnDst, IN CONST VOID *BnSrc) |
CONST VOID *EFIAPI | BigNumValueOne (VOID) |
BOOLEAN EFIAPI | BigNumRShift (IN CONST VOID *Bn, IN UINTN N, OUT VOID *BnRes) |
VOID EFIAPI | BigNumConstTime (IN VOID *Bn) |
BOOLEAN EFIAPI | BigNumSqrMod (IN CONST VOID *BnA, IN CONST VOID *BnM, OUT VOID *BnRes) |
VOID *EFIAPI | BigNumNewContext (VOID) |
VOID EFIAPI | BigNumContextFree (IN VOID *BnCtx) |
BOOLEAN EFIAPI | BigNumSetUint (IN VOID *Bn, IN UINTN Val) |
BOOLEAN EFIAPI | BigNumAddMod (IN CONST VOID *BnA, IN CONST VOID *BnB, IN CONST VOID *BnM, OUT VOID *BnRes) |
Big number API implementation based on OpenSSL
Copyright (c) 2022, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
Definition in file CryptBnNull.c.
Calculate the sum of two Big Numbers. Please note, all "out" Big number arguments should be properly initialized by calling to BigNumInit() or BigNumFromBin() functions.
[in] | BnA | Big number. |
[in] | BnB | Big number. |
[out] | BnRes | The result of BnA + BnB. |
TRUE | On success. |
FALSE | Otherwise. |
Definition at line 96 of file CryptBnNull.c.
BOOLEAN EFIAPI BigNumAddMod | ( | IN CONST VOID * | BnA, |
IN CONST VOID * | BnB, | ||
IN CONST VOID * | BnM, | ||
OUT VOID * | BnRes | ||
) |
Add two Big Numbers modulo BnM.
[in] | BnA | Big number. |
[in] | BnB | Big number. |
[in] | BnM | Big number (modulo). |
[out] | BnRes | The result, such that (BnA + BnB) % BnM. |
TRUE | On success. |
FALSE | Otherwise. |
Definition at line 511 of file CryptBnNull.c.
Get number of bits in Bn.
[in] | Bn | Big number. |
Number | of bits. |
Definition at line 284 of file CryptBnNull.c.
Get number of bytes in Bn.
[in] | Bn | Big number. |
Number | of bytes. |
Definition at line 301 of file CryptBnNull.c.
Compare two Big Numbers.
[in] | BnA | Big number. |
[in] | BnB | Big number. |
0 | BnA == BnB. |
1 | BnA > BnB. |
-1 | BnA < BnB. |
Definition at line 266 of file CryptBnNull.c.
VOID EFIAPI BigNumConstTime | ( | IN VOID * | Bn | ) |
Mark Big Number for constant time computations. This function should be called before any constant time computations are performed on the given Big number.
[in] | Bn | Big number |
Definition at line 416 of file CryptBnNull.c.
VOID EFIAPI BigNumContextFree | ( | IN VOID * | BnCtx | ) |
Free Big Number context that was allocated with BigNumNewContext().
[in] | BnCtx | Big number context to free. |
Definition at line 471 of file CryptBnNull.c.
Copy Big number.
[out] | BnDst | Destination. |
[in] | BnSrc | Source. |
BnDst | on success. |
NULL | otherwise. |
Definition at line 358 of file CryptBnNull.c.
Divide two Big Numbers. Please note, all "out" Big number arguments should be properly initialized by calling to BigNumInit() or BigNumFromBin() functions.
[in] | BnA | Big number. |
[in] | BnB | Big number. |
[out] | BnRes | The result, such that BnA / BnB. |
TRUE | On success. |
FALSE | Otherwise. |
Definition at line 218 of file CryptBnNull.c.
BOOLEAN EFIAPI BigNumExpMod | ( | IN CONST VOID * | BnA, |
IN CONST VOID * | BnP, | ||
IN CONST VOID * | BnM, | ||
OUT VOID * | BnRes | ||
) |
Compute BnA to the BnP-th power modulo BnM. Please note, all "out" Big number arguments should be properly initialized by calling to BigNumInit() or BigNumFromBin() functions.
[in] | BnA | Big number. |
[in] | BnP | Big number (power). |
[in] | BnM | Big number (modulo). |
[out] | BnRes | The result of (BnA ^ BnP) % BnM. |
TRUE | On success. |
FALSE | Otherwise. |
Definition at line 169 of file CryptBnNull.c.
Free the Big Number.
[in] | Bn | Big number to free. |
[in] | Clear | TRUE if the buffer should be cleared. |
Definition at line 74 of file CryptBnNull.c.
Allocate new Big Number and assign the provided value to it.
[in] | Buf | Big endian encoded buffer. |
[in] | Len | Buffer length. |
New | BigNum opaque structure or NULL on failure. |
Definition at line 37 of file CryptBnNull.c.
VOID *EFIAPI BigNumInit | ( | VOID | ) |
Allocate new Big Number.
New | BigNum opaque structure or NULL on failure. |
Definition at line 19 of file CryptBnNull.c.
Compute BnA inverse modulo BnM. Please note, all "out" Big number arguments should be properly initialized by calling to BigNumInit() or BigNumFromBin() functions.
[in] | BnA | Big number. |
[in] | BnM | Big number (modulo). |
[out] | BnRes | The result, such that (BnA * BnRes) % BnM == 1. |
TRUE | On success. |
FALSE | Otherwise. |
Definition at line 194 of file CryptBnNull.c.
Checks if Big Number is odd.
[in] | Bn | Big number. |
TRUE | Bn is odd (Bn % 2 == 1). |
FALSE | otherwise. |
Definition at line 339 of file CryptBnNull.c.
Checks if Big Number equals to the given Num.
[in] | Bn | Big number. |
[in] | Num | Number. |
TRUE | iff Bn == Num. |
FALSE | otherwise. |
Definition at line 320 of file CryptBnNull.c.
Calculate remainder: BnRes = BnA % BnB. Please note, all "out" Big number arguments should be properly initialized by calling to BigNumInit() or BigNumFromBin() functions.
[in] | BnA | Big number. |
[in] | BnB | Big number. |
[out] | BnRes | The result of BnA % BnB. |
TRUE | On success. |
FALSE | Otherwise. |
Definition at line 144 of file CryptBnNull.c.
BOOLEAN EFIAPI BigNumMulMod | ( | IN CONST VOID * | BnA, |
IN CONST VOID * | BnB, | ||
IN CONST VOID * | BnM, | ||
OUT VOID * | BnRes | ||
) |
Multiply two Big Numbers modulo BnM. Please note, all "out" Big number arguments should be properly initialized by calling to BigNumInit() or BigNumFromBin() functions.
[in] | BnA | Big number. |
[in] | BnB | Big number. |
[in] | BnM | Big number (modulo). |
[out] | BnRes | The result, such that (BnA * BnB) % BnM. |
TRUE | On success. |
FALSE | Otherwise. |
Definition at line 243 of file CryptBnNull.c.
VOID *EFIAPI BigNumNewContext | ( | VOID | ) |
Create new Big Number computation context. This is an opaque structure which should be passed to any function that requires it. The BN context is needed to optimize calculations and expensive allocations.
Big | Number context struct or NULL on failure. |
Definition at line 456 of file CryptBnNull.c.
Shift right Big Number. Please note, all "out" Big number arguments should be properly initialized by calling to BigNumInit() or BigNumFromBin() functions.
[in] | Bn | Big number. |
[in] | N | Number of bits to shift. |
[out] | BnRes | The result. |
TRUE | On success. |
FALSE | Otherwise. |
Definition at line 397 of file CryptBnNull.c.
Set Big Number to a given value.
[in] | Bn | Big number to set. |
[in] | Val | Value to set. |
TRUE | On success. |
FALSE | Otherwise. |
Definition at line 489 of file CryptBnNull.c.
Calculate square modulo. Please note, all "out" Big number arguments should be properly initialized by calling to BigNumInit() or BigNumFromBin() functions.
[in] | BnA | Big number. |
[in] | BnM | Big number (modulo). |
[out] | BnRes | The result, such that (BnA ^ 2) % BnM. |
TRUE | On success. |
FALSE | Otherwise. |
Definition at line 437 of file CryptBnNull.c.
Subtract two Big Numbers. Please note, all "out" Big number arguments should be properly initialized by calling to BigNumInit() or BigNumFromBin() functions.
[in] | BnA | Big number. |
[in] | BnB | Big number. |
[out] | BnRes | The result of BnA - BnB. |
TRUE | On success. |
FALSE | Otherwise. |
Definition at line 120 of file CryptBnNull.c.
Convert the absolute value of Bn into big-endian form and store it at Buf. The Buf array should have at least BigNumBytes() in it.
[in] | Bn | Big number to convert. |
[out] | Buf | Output buffer. |
The | length of the big-endian number placed at Buf or -1 on error. |
Definition at line 57 of file CryptBnNull.c.
CONST VOID *EFIAPI BigNumValueOne | ( | VOID | ) |
Get constant Big number with value of "1". This may be used to save expensive allocations.
Big | Number with value of 1. |
Definition at line 375 of file CryptBnNull.c.