mpi_misc.c File Reference

Helper routines for MPI. More...

#include "core/crypto.h"
#include "mpi/mpi.h"
#include "mpi/mpi_misc.h"
#include "debug.h"

Go to the source code of this file.

Macros

#define TRACE_LEVEL   CRYPTO_TRACE_LEVEL
 

Functions

error_t mpiMontgomeryMul (Mpi *r, const Mpi *a, const Mpi *b, uint_t k, const Mpi *p, Mpi *t)
 Montgomery multiplication. More...
 
error_t mpiMontgomeryRed (Mpi *r, const Mpi *a, uint_t k, const Mpi *p, Mpi *t)
 Montgomery reduction. More...
 
void mpiMulAccCore (mpi_word_t *r, const mpi_word_t *a, int_t m, const mpi_word_t b)
 Multiply-accumulate operation. More...
 

Detailed Description

Helper routines for MPI.

License

SPDX-License-Identifier: GPL-2.0-or-later

Copyright (C) 2010-2025 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.

Author
Oryx Embedded SARL (www.oryx-embedded.com)
Version
2.5.4

Definition in file mpi_misc.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   CRYPTO_TRACE_LEVEL

Definition at line 32 of file mpi_misc.c.

Function Documentation

◆ mpiMontgomeryMul()

error_t mpiMontgomeryMul ( Mpi r,
const Mpi a,
const Mpi b,
uint_t  k,
const Mpi p,
Mpi t 
)

Montgomery multiplication.

Parameters
[out]rResulting integer R = A * B / 2^k mod P
[in]aAn integer A such as 0 <= A < 2^k
[in]bAn integer B such as 0 <= B < 2^k
[in]kAn integer k such as P < 2^k
[in]pModulus P
[in]tAn preallocated integer T (for internal operation)
Returns
Error code

Definition at line 55 of file mpi_misc.c.

◆ mpiMontgomeryRed()

error_t mpiMontgomeryRed ( Mpi r,
const Mpi a,
uint_t  k,
const Mpi p,
Mpi t 
)

Montgomery reduction.

Parameters
[out]rResulting integer R = A / 2^k mod P
[in]aAn integer A such as 0 <= A < 2^k
[in]kAn integer k such as P < 2^k
[in]pModulus P
[in]tAn preallocated integer T (for internal operation)
Returns
Error code

Definition at line 128 of file mpi_misc.c.

◆ mpiMulAccCore()

void mpiMulAccCore ( mpi_word_t r,
const mpi_word_t a,
int_t  m,
const mpi_word_t  b 
)

Multiply-accumulate operation.

Parameters
[out]rResulting integer
[in]aFirst operand A
[in]mSize of A in words
[in]bSecond operand B

Definition at line 159 of file mpi_misc.c.