Big number operations.
More...
|
typedef struct BigNum | BigNum |
| Internal representation of large numbers.
|
|
|
EpidStatus | NewBigNum (size_t data_size_bytes, BigNum **bignum) |
| Constructs a new BigNum. More...
|
|
void | DeleteBigNum (BigNum **bignum) |
| Deletes a previously allocated BigNum. More...
|
|
EpidStatus | ReadBigNum (void const *bn_str, size_t strlen, BigNum *bn) |
| Deserializes a BigNum from a string. More...
|
|
EpidStatus | WriteBigNum (BigNum const *bn, size_t strlen, void *bn_str) |
| Serializes a BigNum to a string. More...
|
|
EpidStatus | BigNumAdd (BigNum const *a, BigNum const *b, BigNum *r) |
| Adds two BigNum values. More...
|
|
EpidStatus | BigNumSub (BigNum const *a, BigNum const *b, BigNum *r) |
| Subtracts two BigNum values. More...
|
|
EpidStatus | BigNumMul (BigNum const *a, BigNum const *b, BigNum *r) |
| Multiplies two BigNum values. More...
|
|
EpidStatus | BigNumDiv (BigNum const *a, BigNum const *b, BigNum *q, BigNum *r) |
| Divides two BigNum values. More...
|
|
EpidStatus | BigNumMod (BigNum const *a, BigNum const *b, BigNum *r) |
| Computes modular reduction for BigNum value by specified modulus. More...
|
|
EpidStatus | BigNumIsEven (BigNum const *a, bool *is_even) |
| Checks if a BigNum is even. More...
|
|
EpidStatus | BigNumIsZero (BigNum const *a, bool *is_zero) |
| Checks if a BigNum is zero. More...
|
|
EpidStatus | BigNumPow2N (unsigned int n, BigNum *r) |
| Raises 2 to the given power. More...
|
|
Big number operations.
This module provides an API for working with large numbers. BigNums represent non-negative integers.
Each BigNum variable represents a number of a byte-size set when the variable was created. BigNum variables cannot be re-sized after they are created.
Adds two BigNum values.
- Parameters
-
[in] | a | The first operand to be added. |
[in] | b | The second operand to be added. |
[out] | r | The result of adding a and b. |
- Returns
- EpidStatus
Divides two BigNum values.
- Note
- Only needed for Intel(R) EPID 1.1 verification.
- Parameters
-
[in] | a | Dividend parameter. |
[in] | b | Divisor parameter. |
[out] | q | Quotient of result. |
[out] | r | Remainder of result. |
- Returns
- EpidStatus
Checks if a BigNum is even.
- Parameters
-
[in] | a | The BigNum to check. |
[out] | is_even | The result of the check. |
- Returns
- EpidStatus
Checks if a BigNum is zero.
- Parameters
-
[in] | a | The BigNum to check. |
[out] | is_zero | The result of the check. |
- Returns
- EpidStatus
Computes modular reduction for BigNum value by specified modulus.
- Parameters
-
[in] | a | The BigNum value. |
[in] | b | The modulus. |
[out] | r | Modular reduction result. |
- Returns
- EpidStatus
Multiplies two BigNum values.
- Parameters
-
[in] | a | The first operand to be multiplied. |
[in] | b | The second operand to be multiplied. |
[out] | r | The result of multiplying a and b. |
- Returns
- EpidStatus
Raises 2 to the given power.
- Parameters
-
[in] | n | The power. |
[out] | r | The result of 2^n. |
- Returns
- EpidStatus
Subtracts two BigNum values.
- Parameters
-
[in] | a | The first operand to use in subtraction. |
[in] | b | The second operand to use in subtraction. |
[out] | r | The result of subtracting a and b. |
- Returns
- EpidStatus
void DeleteBigNum |
( |
BigNum ** |
bignum | ) |
|
Deletes a previously allocated BigNum.
Frees memory pointed to by bignum. Nulls the pointer.
- Parameters
-
[in] | bignum | The BigNum. Can be NULL. |
- See also
- NewBigNum
Constructs a new BigNum.
Allocates memory and creates a new BigNum.
Use DeleteBigNum() to free memory.
- Parameters
-
[in] | data_size_bytes | The size in bytes of the new number. |
[out] | bignum | The BigNum. |
- Returns
- EpidStatus
- See also
- DeleteBigNum
Deserializes a BigNum from a string.
- Parameters
-
[in] | bn_str | The serialized value. |
[in] | strlen | The size of bn_str in bytes. |
[out] | bn | The target BigNum. |
- Returns
- EpidStatus
Serializes a BigNum to a string.
- Parameters
-
[in] | bn | The BigNum to be serialized. |
[in] | strlen | The size of bn_str in bytes. |
[out] | bn_str | The target string. |
- Returns
- EpidStatus