# Intel® Enhanced Privacy ID SDK: bignum

bignum
epid » common » math

Big number operations. More...

## Typedefs

typedef struct BigNum | BigNum
| Internal representation of large numbers.

## Functions

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 const *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 | BigNumMod (BigNum const *a, BigNum const *b, BigNum *r)
| Computes modular reduction for BigNum value by specified modulus. More...

## Detailed Description

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.

## Function Documentation

EpidStatus BigNumAdd | ( | BigNum const * | a,
|  | BigNum const * | b,
|  | BigNum * | r
| ) |  |

Adds two BigNum values.

Parameters

  [in] | a | The left hand parameter.
  [in] | b | The right hand parameter.
  [out] | r | The result of adding a and b.

Returns
  EpidStatus

EpidStatus BigNumMod | ( | BigNum const * | a,
|  | BigNum const * | b,
|  | BigNum * | r
| ) |  |

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

EpidStatus BigNumMul | ( | BigNum const * | a,
|  | BigNum const * | b,
|  | BigNum * | r
| ) |  |

Multiplies two BigNum values.

Parameters

  [in] | a | The left hand parameter.
  [in] | b | The right hand parameter.
  [out] | r | The result of multiplying a and b.

Returns
  EpidStatus

EpidStatus BigNumSub | ( | BigNum const * | a,
|  | BigNum const * | b,
|  | BigNum * | r
| ) |  |

Subtracts two BigNum values.

Parameters

  [in] | a | The left hand parameter.
  [in] | b | The right hand parameter.
  [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

EpidStatus NewBigNum | ( | size_t | data_size_bytes,
|  | BigNum ** | bignum
| ) |  |

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

EpidStatus ReadBigNum | ( | void const * | bn_str,
|  | size_t | strlen,
|  | BigNum * | bn
| ) |  |

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

EpidStatus WriteBigNum | ( | BigNum const * | bn,
|  | size_t | strlen,
|  | void const * | bn_str
| ) |  |

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