OpenCore
1.0.4
OpenCore Bootloader
|
#include "CryptoInternal.h"
Go to the source code of this file.
Macros | |
#define | OC_BN_WORD_SIZE (sizeof (OC_BN_WORD)) |
#define | OC_BN_WORD_NUM_BITS ((OC_BN_NUM_BITS) (OC_BN_WORD_SIZE * OC_CHAR_BIT)) |
#define | OC_BN_MAX_SIZE ((OC_BN_SIZE) SIZE_64KB) |
#define | OC_BN_MAX_LEN ((OC_BN_NUM_WORDS) (OC_BN_MAX_SIZE / OC_BN_WORD_SIZE)) |
#define | OC_BN_SIZE(NumWords) |
#define | OC_BN_BITS(NumWords) |
#define | OC_BN_MONT_MAX_LEN (OC_BN_MAX_LEN / 2U - 1U) |
#define | OC_BN_MONT_MAX_SIZE (OC_BN_SIZE (OC_BN_MONT_MAX_LEN)) |
#define | OC_BN_MONT_RSQR_LEN(NumWords) |
#define | OC_BN_MONT_RSQR_SIZE(NumWords) |
#define | BIG_NUM_MONT_PARAMS_SCRATCH_SIZE(NumWords) |
Typedefs | |
typedef UINTN | OC_BN_WORD |
typedef UINT16 | OC_BN_NUM_WORDS |
typedef UINT32 | OC_BN_SIZE |
typedef UINT32 | OC_BN_NUM_BITS |
#define BIG_NUM_MONT_PARAMS_SCRATCH_SIZE | ( | NumWords | ) |
1 + 2 * NumWords for RSqr, and then twice more than that for Mod.
[in] | NumWords | The number of Words of RSqrMod and N. Must be at most OC_BN_MONT_MAX_LEN. |
Definition at line 136 of file BigNumLib.h.
#define OC_BN_BITS | ( | NumWords | ) |
The size, in Bits, required to store a BigNum with NumWords words.
[in] | NumWords | The number of Words. Must be at most OC_BN_MAX_LEN. |
Definition at line 59 of file BigNumLib.h.
#define OC_BN_MAX_LEN ((OC_BN_NUM_WORDS) (OC_BN_MAX_SIZE / OC_BN_WORD_SIZE)) |
Definition at line 39 of file BigNumLib.h.
#define OC_BN_MAX_SIZE ((OC_BN_SIZE) SIZE_64KB) |
Definition at line 38 of file BigNumLib.h.
#define OC_BN_MONT_MAX_LEN (OC_BN_MAX_LEN / 2U - 1U) |
Definition at line 106 of file BigNumLib.h.
#define OC_BN_MONT_MAX_SIZE (OC_BN_SIZE (OC_BN_MONT_MAX_LEN)) |
Definition at line 107 of file BigNumLib.h.
#define OC_BN_MONT_RSQR_LEN | ( | NumWords | ) |
The length, in BigNum words, of RSqr.
[in] | NumWords | The number of Words of N. Must be at most OC_BN_MONT_MAX_LEN. |
Definition at line 115 of file BigNumLib.h.
#define OC_BN_MONT_RSQR_SIZE | ( | NumWords | ) |
The size, in Bytes, of RSqr.
[in] | NumWords | The number of Words of N. Must be at most OC_BN_MONT_MAX_LEN. |
Definition at line 128 of file BigNumLib.h.
#define OC_BN_SIZE | ( | NumWords | ) |
The size, in Bytes, required to store a BigNum with NumWords words.
[in] | NumWords | The number of Words. Must be at most OC_BN_MAX_LEN. |
Definition at line 46 of file BigNumLib.h.
#define OC_BN_WORD_NUM_BITS ((OC_BN_NUM_BITS) (OC_BN_WORD_SIZE * OC_CHAR_BIT)) |
Definition at line 31 of file BigNumLib.h.
#define OC_BN_WORD_SIZE (sizeof (OC_BN_WORD)) |
Definition at line 30 of file BigNumLib.h.
typedef UINT32 OC_BN_NUM_BITS |
Definition at line 37 of file BigNumLib.h.
typedef UINT16 OC_BN_NUM_WORDS |
Definition at line 35 of file BigNumLib.h.
typedef UINT32 OC_BN_SIZE |
Definition at line 36 of file BigNumLib.h.
typedef UINTN OC_BN_WORD |
This library performs arbitrary precision arithmetic operations. For more details, please refer to the source files and function headers.
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. A BIGNUM word. This is at best an integer of the platform's natural size to optimize memory accesses and arithmetic operation count.
Definition at line 26 of file BigNumLib.h.
OC_BN_WORD BigNumCalculateMontParams | ( | IN OUT OC_BN_WORD * | RSqrMod, |
IN OC_BN_NUM_WORDS | NumWords, | ||
IN CONST OC_BN_WORD * | N, | ||
IN OC_BN_WORD * | Scratch ) |
Calculates the Montgomery Inverse and R^2 mod N.
[in,out] | RSqrMod | The buffer to return R^2 mod N into. |
[in] | NumWords | The number of Words of RSqrMod and N. Must be at most OC_BN_MONT_MAX_LEN. |
[in] | N | The Montgomery Modulus. |
[in] | Scratch | Scratch buffer BIG_NUM_MONT_PARAMS_SCRATCH_SIZE(NumWords). |
Definition at line 156 of file BigNumMontgomery.c.
VOID BigNumParseBuffer | ( | IN OUT OC_BN_WORD * | Result, |
IN OC_BN_NUM_WORDS | NumWords, | ||
IN CONST UINT8 * | Buffer, | ||
IN UINTN | BufferSize ) |
Parses a data array into a number. The buffer size must be a multiple of the Word size. The length of Result must precisely fit the required size.
[in,out] | Result | The buffer to store the result in. |
[in] | NumWords | The number of Words of Result. |
[in] | Buffer | The buffer to parse. |
[in] | BufferSize | The size, in bytes, of Buffer. |
Definition at line 748 of file BigNumPrimitives.c.
BOOLEAN BigNumPowMod | ( | IN OUT OC_BN_WORD * | Result, |
IN OC_BN_NUM_WORDS | NumWords, | ||
IN CONST OC_BN_WORD * | A, | ||
IN UINT32 | B, | ||
IN CONST OC_BN_WORD * | N, | ||
IN OC_BN_WORD | N0Inv, | ||
IN CONST OC_BN_WORD * | RSqrMod, | ||
IN OC_BN_WORD * | ATmp ) |
Caulculates the exponentiation of A with B mod N.
[in,out] | Result | The buffer to return the result into. |
[in] | NumWords | The number of Words of Result, A, N and RSqrMod. |
[in] | A | The base. |
[in] | B | The exponent. |
[in] | N | The modulus. |
[in] | N0Inv | The Montgomery Inverse of N. |
[in] | RSqrMod | Montgomery's R^2 mod N. |
[in] | ATmp | Scratch buffer of NumWords. |
Definition at line 555 of file BigNumMontgomery.c.
OC_BN_WORD BigNumSwapWord | ( | IN OC_BN_WORD | Word | ) |
Swaps the byte order of Word.
[in] | Word | The Word to swap. |
Definition at line 44 of file BigNumPrimitives.c.
STATIC_ASSERT | ( | OC_BN_BITS(OC_BN_MAX_LEN)<=MAX_UINTN/ | OC_CHAR_BIT, |
"The definition of OC_BN_BITS may cause an overflow" | ) |
STATIC_ASSERT | ( | OC_BN_MAX_LEN<=MAX_UINTN/ | OC_BN_WORD_SIZE, |
"The definition of OC_BN_SIZE may cause an overflow" | ) |
STATIC_ASSERT | ( | OC_BN_MONT_RSQR_LEN(OC_BN_MONT_MAX_LEN) | = =OC_BN_MAX_LEN, |
"The definition of OC_BN_MONT_RSQR_LEN is faulty" | ) |
STATIC_ASSERT | ( | OC_BN_MONT_RSQR_SIZE(OC_BN_MONT_MAX_SIZE)<=MAX_UINTN/ | 3, |
"The definition of BIG_NUM_MONT_PARAMS_SCRATCH_SIZE may cause an overflow" | ) |