Lines Matching +full:- +full:a
4 * \brief Multi-precision integer library
8 * SPDX-License-Identifier: Apache-2.0
12 * You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
35 …_ERR_MPI_FILE_IO_ERROR -0x0002 /**< An error occurred while reading from or w…
36 #define MBEDTLS_ERR_MPI_BAD_INPUT_DATA -0x0004 /**< Bad input parameters to fun…
37 #define MBEDTLS_ERR_MPI_INVALID_CHARACTER -0x0006 /**< There is an invalid charact…
38 #define MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL -0x0008 /**< The buffer is too small to …
39 #define MBEDTLS_ERR_MPI_NEGATIVE_VALUE -0x000A /**< The input arguments are neg…
40 #define MBEDTLS_ERR_MPI_DIVISION_BY_ZERO -0x000C /**< The input argument for divi…
41 #define MBEDTLS_ERR_MPI_NOT_ACCEPTABLE -0x000E /**< The input arguments are not…
42 #define MBEDTLS_ERR_MPI_ALLOC_FAILED -0x0010 /**< Memory allocation failed. */
71 * Maximum size of MPIs allowed in bits and bytes for user-MPIs.
85 * for a (short) label, the MPI (in the provided radix), the newline
88 * By default we assume at least a 10 char label, a minimum radix of 10
89 * (decimal) and a maximum of 4096 bit numbers (1234 decimal chars).
90 * Autosized at compile time for at least a 10 char label, a minimum radix
91 * of 10 (decimal) for a number of MBEDTLS_MPI_MAX_BITS size.
93 * This used to be statically sized to 1250 for a maximum of 4096 bit
102 … ( ((MBEDTLS_MPI_MAX_BITS_SCALE100 + MBEDTLS_LN_2_DIV_LN_10_SCALE100 - 1) / MBEDTLS_LN_2_DI…
105 * Define the base integer type, architecture-wise.
107 * 32 or 64-bit integer types can be forced regardless of the underlying
111 * Double-width integers (e.g. 128-bit in 64-bit architectures) can be
116 /* Always choose 64-bit when using MSC */
135 /* mbedtls_t_udbl defined as 128-bit unsigned int */
142 * __aarch64__ is only defined by armclang when compiling 64-bit code
150 /* mbedtls_t_udbl defined as 128-bit unsigned int */
155 /* Force 64-bit integers with unknown compiler */
162 /* Default to 32-bit compilation */
183 int MBEDTLS_PRIVATE(s); /*!< Sign: -1 if the mpi is negative, 1 otherwise */
193 * but does not define a value for the MPI.
203 * in which case this function is a no-op. If it is
241 * \brief Make a copy of an MPI.
246 * \note The limb-buffer in the destination MPI is enlarged
264 * \brief Perform a safe conditional copy of MPI which doesn't
290 * \brief Perform a safe conditional swap which doesn't
327 * \brief Get a specific bit from an MPI.
330 * \param pos Zero-based index of the bit to query.
334 * \return A negative error code on failure.
339 * \brief Modify a specific bit in an MPI.
341 * \note This function will grow the target MPI if necessary to set a
342 * bit to \c 1 in a not yet existing limb. It will not grow if
346 * \param pos Zero-based index of the bit to modify.
359 * \note This is the same as the zero-based index of
373 * * \note This is same as the one-based index of the most
403 * \param s Null-terminated string buffer.
406 * \return A negative error code on failure.
429 * size of \p buf required for a successful call.
437 * \brief Read an MPI from a line in an opened file.
449 * Leading whitespaces are ignored, as is a
462 * \param p A string prefix to emit prior to the MPI data.
463 * For example, this might be a label, or "0x" when
472 * \return A negative error code on failure.
482 * \param buf The input buffer. This must be a readable buffer of length
497 * \param buf The input buffer. This must be a readable buffer of length
514 * \param buf The output buffer. This must be a writable buffer of length
532 * \param buf The output buffer. This must be a writable buffer of length
545 * \brief Perform a left-shift on an MPI: X <<= count
551 * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if a memory allocation failed.
557 * \brief Perform a right-shift on an MPI: X >>= count
563 * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if a memory allocation failed.
571 * \param X The left-hand MPI. This must point to an initialized MPI.
572 * \param Y The right-hand MPI. This must point to an initialized MPI.
575 * \return \c -1 if `|X|` is lesser than `|Y|`.
583 * \param X The left-hand MPI. This must point to an initialized MPI.
584 * \param Y The right-hand MPI. This must point to an initialized MPI.
587 * \return \c -1 if \p X is lesser than \p Y.
595 * \param X The left-hand MPI. This must point to an initialized MPI
597 * \param Y The right-hand MPI. This must point to an initialized MPI
613 * \param X The left-hand MPI. This must point to an initialized MPI.
617 * \return \c -1 if \p X is lesser than \p z.
623 * \brief Perform an unsigned addition of MPIs: X = |A| + |B|
626 * \param A The first summand. This must point to an initialized MPI.
630 * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if a memory allocation failed.
633 int mbedtls_mpi_add_abs( mbedtls_mpi *X, const mbedtls_mpi *A,
637 * \brief Perform an unsigned subtraction of MPIs: X = |A| - |B|
640 * \param A The minuend. This must point to an initialized MPI.
644 * \return #MBEDTLS_ERR_MPI_NEGATIVE_VALUE if \p B is greater than \p A.
648 int mbedtls_mpi_sub_abs( mbedtls_mpi *X, const mbedtls_mpi *A,
652 * \brief Perform a signed addition of MPIs: X = A + B
655 * \param A The first summand. This must point to an initialized MPI.
659 * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if a memory allocation failed.
662 int mbedtls_mpi_add_mpi( mbedtls_mpi *X, const mbedtls_mpi *A,
666 * \brief Perform a signed subtraction of MPIs: X = A - B
669 * \param A The minuend. This must point to an initialized MPI.
673 * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if a memory allocation failed.
676 int mbedtls_mpi_sub_mpi( mbedtls_mpi *X, const mbedtls_mpi *A,
680 * \brief Perform a signed addition of an MPI and an integer: X = A + b
683 * \param A The first summand. This must point to an initialized MPI.
687 * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if a memory allocation failed.
690 int mbedtls_mpi_add_int( mbedtls_mpi *X, const mbedtls_mpi *A,
694 * \brief Perform a signed subtraction of an MPI and an integer:
695 * X = A - b
698 * \param A The minuend. This must point to an initialized MPI.
702 * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if a memory allocation failed.
705 int mbedtls_mpi_sub_int( mbedtls_mpi *X, const mbedtls_mpi *A,
709 * \brief Perform a multiplication of two MPIs: X = A * B
712 * \param A The first factor. This must point to an initialized MPI.
716 * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if a memory allocation failed.
720 int mbedtls_mpi_mul_mpi( mbedtls_mpi *X, const mbedtls_mpi *A,
724 * \brief Perform a multiplication of an MPI with an unsigned integer:
725 * X = A * b
728 * \param A The first factor. This must point to an initialized MPI.
732 * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if a memory allocation failed.
736 int mbedtls_mpi_mul_int( mbedtls_mpi *X, const mbedtls_mpi *A,
740 * \brief Perform a division with remainder of two MPIs:
741 * A = Q * B + R
749 * \param A The dividend. This must point to an initialized MPi.
757 int mbedtls_mpi_div_mpi( mbedtls_mpi *Q, mbedtls_mpi *R, const mbedtls_mpi *A,
761 * \brief Perform a division with remainder of an MPI by an integer:
762 * A = Q * b + R
770 * \param A The dividend. This must point to an initialized MPi.
778 int mbedtls_mpi_div_int( mbedtls_mpi *Q, mbedtls_mpi *R, const mbedtls_mpi *A,
782 * \brief Perform a modular reduction. R = A mod B
786 * \param A The MPI to compute the residue of.
792 * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if a memory allocation failed.
798 int mbedtls_mpi_mod_mpi( mbedtls_mpi *R, const mbedtls_mpi *A,
802 * \brief Perform a modular reduction with respect to an integer.
803 * r = A mod b
807 * \param A The MPI to compute the residue of.
812 * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if a memory allocation failed.
817 int mbedtls_mpi_mod_int( mbedtls_mpi_uint *r, const mbedtls_mpi *A,
821 * \brief Perform a sliding-window exponentiation: X = A^E mod N
824 * \param A The base of the exponentiation.
829 * \param _RR A helper MPI depending solely on \p N which can be used to
830 * speed-up multiple modular exponentiations for the same value
836 * will assume that \p _RR holds the helper value set by a
840 * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if a memory allocation failed.
846 int mbedtls_mpi_exp_mod( mbedtls_mpi *X, const mbedtls_mpi *A,
851 * \brief Fill an MPI with a number of random bytes.
857 * \c NULL if \p f_rng doesn't need a context argument.
860 * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if a memory allocation failed.
864 * as a big-endian representation of an MPI; this can
871 /** Generate a random number uniformly in a range.
873 * This function generates a random number between \p min inclusive and
877 * when the RNG is a suitably parametrized instance of HMAC_DRBG
880 * \note There are `N - min` possible outputs. The lower bound
893 * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if a memory allocation failed.
897 * unable to find a suitable value within a limited number
898 * of attempts. This has a negligible probability if \p N
910 * \brief Compute the greatest common divisor: G = gcd(A, B)
913 * \param A The first operand. This must point to an initialized MPI.
917 * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if a memory allocation failed.
920 int mbedtls_mpi_gcd( mbedtls_mpi *G, const mbedtls_mpi *A,
924 * \brief Compute the modular inverse: X = A^-1 mod N
927 * \param A The MPI to calculate the modular inverse of. This must point
933 * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if a memory allocation failed.
939 int mbedtls_mpi_inv_mod( mbedtls_mpi *X, const mbedtls_mpi *A,
943 * \brief Miller-Rabin primality test.
950 * if \p X is chosen uniformly or non-adversially (as is the
956 * \param rounds The number of bases to perform the Miller-Rabin primality
957 * test for. The probability of returning 0 on a composite is
958 * at most 2<sup>-2*\p rounds</sup>.
962 * a context parameter.
965 * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if a memory allocation failed.
975 * Each of these flags is a constraint on the result X returned by
979 MBEDTLS_MPI_GEN_PRIME_FLAG_DH = 0x0001, /**< (X-1)/2 is prime too */
980 …_GEN_PRIME_FLAG_LOW_ERR = 0x0002, /**< lower error rate from 2<sup>-80</sup> to 2<sup>-128</sup> */
984 * \brief Generate a prime number.
990 * \param flags A mask of flags of type #mbedtls_mpi_gen_prime_flag_t.
994 * a context parameter.
996 * \return \c 0 if successful, in which case \p X holds a
998 * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if a memory allocation failed.