Webserver+3d print
mpi.c File Reference
MPI (Multiple Precision Integer Arithmetic) More...
Go to the source code of this file.
Functions | |
void | mpiInit (Mpi *r) |
Initialize a multiple precision integer. | |
void | mpiFree (Mpi *r) |
Release a multiple precision integer. | |
error_t | mpiGrow (Mpi *r, uint_t size) |
Adjust the size of multiple precision integer. | |
uint_t | mpiGetLength (const Mpi *a) |
Get the actual length in words. | |
uint_t | mpiGetByteLength (const Mpi *a) |
Get the actual length in bytes. | |
uint_t | mpiGetBitLength (const Mpi *a) |
Get the actual length in bits. | |
error_t | mpiSetBitValue (Mpi *r, uint_t index, uint_t value) |
Set the bit value at the specified index. | |
uint_t | mpiGetBitValue (const Mpi *a, uint_t index) |
Get the bit value at the specified index. | |
int_t | mpiComp (const Mpi *a, const Mpi *b) |
Compare two multiple precision integers. | |
int_t | mpiCompInt (const Mpi *a, int_t b) |
Compare a multiple precision integer with an integer. | |
int_t | mpiCompAbs (const Mpi *a, const Mpi *b) |
Compare the absolute value of two multiple precision integers. | |
error_t | mpiCopy (Mpi *r, const Mpi *a) |
Copy a multiple precision integer. | |
error_t | mpiSetValue (Mpi *r, int_t a) |
Set the value of a multiple precision integer. | |
error_t | mpiRand (Mpi *r, uint_t length, const PrngAlgo *prngAlgo, void *prngContext) |
Generate a random value. | |
error_t | mpiReadRaw (Mpi *r, const uint8_t *data, uint_t length) |
Octet string to integer conversion. | |
error_t | mpiWriteRaw (const Mpi *a, uint8_t *data, uint_t length) |
Integer to octet string conversion. | |
error_t | mpiAdd (Mpi *r, const Mpi *a, const Mpi *b) |
Multiple precision addition. | |
error_t | mpiAddInt (Mpi *r, const Mpi *a, int_t b) |
Add an integer to a multiple precision integer. | |
error_t | mpiSub (Mpi *r, const Mpi *a, const Mpi *b) |
Multiple precision subtraction. | |
error_t | mpiSubInt (Mpi *r, const Mpi *a, int_t b) |
Subtract an integer from a multiple precision integer. | |
error_t | mpiAddAbs (Mpi *r, const Mpi *a, const Mpi *b) |
Helper routine for multiple precision addition. | |
error_t | mpiSubAbs (Mpi *r, const Mpi *a, const Mpi *b) |
Helper routine for multiple precision subtraction. | |
error_t | mpiShiftLeft (Mpi *r, uint_t n) |
Left shift operation. | |
error_t | mpiShiftRight (Mpi *r, uint_t n) |
Right shift operation. | |
error_t | mpiMul (Mpi *r, const Mpi *a, const Mpi *b) |
Multiple precision multiplication. | |
error_t | mpiMulInt (Mpi *r, const Mpi *a, int_t b) |
Multiply a multiple precision integer by an integer. | |
error_t | mpiDiv (Mpi *q, Mpi *r, const Mpi *a, const Mpi *b) |
Multiple precision division. | |
error_t | mpiDivInt (Mpi *q, Mpi *r, const Mpi *a, int_t b) |
Divide a multiple precision integer by an integer. | |
error_t | mpiMod (Mpi *r, const Mpi *a, const Mpi *p) |
Modulo operation. | |
error_t | mpiAddMod (Mpi *r, const Mpi *a, const Mpi *b, const Mpi *p) |
Modular addition. | |
error_t | mpiSubMod (Mpi *r, const Mpi *a, const Mpi *b, const Mpi *p) |
Modular subtraction. | |
error_t | mpiMulMod (Mpi *r, const Mpi *a, const Mpi *b, const Mpi *p) |
Modular multiplication. | |
error_t | mpiInvMod (Mpi *r, const Mpi *a, const Mpi *p) |
Modular inverse. | |
error_t | mpiExpMod (Mpi *r, const Mpi *a, const Mpi *e, const Mpi *p) |
Modular exponentiation. | |
error_t | mpiMontgomeryMul (Mpi *r, const Mpi *a, const Mpi *b, uint_t k, const Mpi *p, Mpi *t) |
Montgomery multiplication. | |
error_t | mpiMontgomeryRed (Mpi *r, const Mpi *a, uint_t k, const Mpi *p, Mpi *t) |
Montgomery reduction. | |
void | mpiMulAccCore (uint_t *r, const uint_t *a, int_t m, const uint_t b) |
Multiply-accumulate operation. | |
void | mpiDump (FILE *stream, const char_t *prepend, const Mpi *a) |
Display the contents of a multiple precision integer. |
Detailed Description
MPI (Multiple Precision Integer Arithmetic)
License
Copyright (C) 2010-2017 Oryx Embedded SARL. All rights reserved.
This file is part of CycloneCrypto Open.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- Version:
- 1.7.6
Definition in file mpi.c.
Function Documentation
int_t mpiCompInt | ( | const Mpi * | a, |
int_t | b | ||
) |
void mpiDump | ( | FILE * | stream, |
const char_t * | prepend, | ||
const Mpi * | a | ||
) |
void mpiFree | ( | Mpi * | r ) |
uint_t mpiGetBitLength | ( | const Mpi * | a ) |
uint_t mpiGetBitValue | ( | const Mpi * | a, |
uint_t | index | ||
) |
uint_t mpiGetByteLength | ( | const Mpi * | a ) |
uint_t mpiGetLength | ( | const Mpi * | a ) |
void mpiInit | ( | Mpi * | r ) |
error_t mpiMontgomeryMul | ( | Mpi * | r, |
const Mpi * | a, | ||
const Mpi * | b, | ||
uint_t | k, | ||
const Mpi * | p, | ||
Mpi * | t | ||
) |
Montgomery multiplication.
- Parameters:
-
[out] r Resulting integer R = A * B / 2^k mod P [in] a An integer A such as 0 <= A < 2^k [in] b An integer B such as 0 <= B < 2^k [in] k An integer k such as P < 2^k [in] p Modulus P [in] t An preallocated integer T (for internal operation)
- Returns:
- Error code
void mpiMulAccCore | ( | uint_t * | r, |
const uint_t * | a, | ||
int_t | m, | ||
const uint_t | b | ||
) |
Integer to octet string conversion.
Converts an integer to an octet string of a specified length
- Parameters:
-
[in] a Non-negative integer to be converted [out] data Octet string resulting from the conversion [in] length Intended length of the resulting octet string
- Returns:
- Error code
Generated on Tue Jul 12 2022 17:10:21 by
