|
46 | 46 | #include "mbedtls/bignum.h" |
47 | 47 | #include "mbedtls/bn_mul.h" |
48 | 48 | #include "mbedtls/platform_util.h" |
| 49 | +#include "mbedtls/error.h" |
49 | 50 |
|
50 | 51 | #include <string.h> |
51 | 52 |
|
@@ -314,7 +315,7 @@ int mbedtls_mpi_safe_cond_swap( mbedtls_mpi *X, mbedtls_mpi *Y, unsigned char sw |
314 | 315 | */ |
315 | 316 | int mbedtls_mpi_lset( mbedtls_mpi *X, mbedtls_mpi_sint z ) |
316 | 317 | { |
317 | | - int ret; |
| 318 | + int ret = MBEDTLS_ERR_GENERIC_ERROR; |
318 | 319 | MPI_VALIDATE_RET( X != NULL ); |
319 | 320 |
|
320 | 321 | MBEDTLS_MPI_CHK( mbedtls_mpi_grow( X, 1 ) ); |
@@ -457,7 +458,7 @@ static int mpi_get_digit( mbedtls_mpi_uint *d, int radix, char c ) |
457 | 458 | */ |
458 | 459 | int mbedtls_mpi_read_string( mbedtls_mpi *X, int radix, const char *s ) |
459 | 460 | { |
460 | | - int ret; |
| 461 | + int ret = MBEDTLS_ERR_GENERIC_ERROR; |
461 | 462 | size_t i, j, slen, n; |
462 | 463 | mbedtls_mpi_uint d; |
463 | 464 | mbedtls_mpi T; |
@@ -532,7 +533,7 @@ int mbedtls_mpi_read_string( mbedtls_mpi *X, int radix, const char *s ) |
532 | 533 | static int mpi_write_hlp( mbedtls_mpi *X, int radix, |
533 | 534 | char **p, const size_t buflen ) |
534 | 535 | { |
535 | | - int ret; |
| 536 | + int ret = MBEDTLS_ERR_GENERIC_ERROR; |
536 | 537 | mbedtls_mpi_uint r; |
537 | 538 | size_t length = 0; |
538 | 539 | char *p_end = *p + buflen; |
@@ -697,7 +698,7 @@ int mbedtls_mpi_read_file( mbedtls_mpi *X, int radix, FILE *fin ) |
697 | 698 | */ |
698 | 699 | int mbedtls_mpi_write_file( const char *p, const mbedtls_mpi *X, int radix, FILE *fout ) |
699 | 700 | { |
700 | | - int ret; |
| 701 | + int ret = MBEDTLS_ERR_GENERIC_ERROR; |
701 | 702 | size_t n, slen, plen; |
702 | 703 | /* |
703 | 704 | * Buffer should have space for (short) label and decimal formatted MPI, |
@@ -832,7 +833,7 @@ static void mpi_bigendian_to_host( mbedtls_mpi_uint * const p, size_t limbs ) |
832 | 833 | int mbedtls_mpi_read_binary_le( mbedtls_mpi *X, |
833 | 834 | const unsigned char *buf, size_t buflen ) |
834 | 835 | { |
835 | | - int ret; |
| 836 | + int ret = MBEDTLS_ERR_GENERIC_ERROR; |
836 | 837 | size_t i; |
837 | 838 | size_t const limbs = CHARS_TO_LIMBS( buflen ); |
838 | 839 |
|
@@ -864,7 +865,7 @@ int mbedtls_mpi_read_binary_le( mbedtls_mpi *X, |
864 | 865 | */ |
865 | 866 | int mbedtls_mpi_read_binary( mbedtls_mpi *X, const unsigned char *buf, size_t buflen ) |
866 | 867 | { |
867 | | - int ret; |
| 868 | + int ret = MBEDTLS_ERR_GENERIC_ERROR; |
868 | 869 | size_t const limbs = CHARS_TO_LIMBS( buflen ); |
869 | 870 | size_t const overhead = ( limbs * ciL ) - buflen; |
870 | 871 | unsigned char *Xp; |
@@ -991,7 +992,7 @@ int mbedtls_mpi_write_binary( const mbedtls_mpi *X, |
991 | 992 | */ |
992 | 993 | int mbedtls_mpi_shift_l( mbedtls_mpi *X, size_t count ) |
993 | 994 | { |
994 | | - int ret; |
| 995 | + int ret = MBEDTLS_ERR_GENERIC_ERROR; |
995 | 996 | size_t i, v0, t1; |
996 | 997 | mbedtls_mpi_uint r0 = 0, r1; |
997 | 998 | MPI_VALIDATE_RET( X != NULL ); |
@@ -1170,7 +1171,7 @@ int mbedtls_mpi_cmp_int( const mbedtls_mpi *X, mbedtls_mpi_sint z ) |
1170 | 1171 | */ |
1171 | 1172 | int mbedtls_mpi_add_abs( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *B ) |
1172 | 1173 | { |
1173 | | - int ret; |
| 1174 | + int ret = MBEDTLS_ERR_GENERIC_ERROR; |
1174 | 1175 | size_t i, j; |
1175 | 1176 | mbedtls_mpi_uint *o, *p, c, tmp; |
1176 | 1177 | MPI_VALIDATE_RET( X != NULL ); |
@@ -1251,7 +1252,7 @@ static void mpi_sub_hlp( size_t n, mbedtls_mpi_uint *s, mbedtls_mpi_uint *d ) |
1251 | 1252 | int mbedtls_mpi_sub_abs( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *B ) |
1252 | 1253 | { |
1253 | 1254 | mbedtls_mpi TB; |
1254 | | - int ret; |
| 1255 | + int ret = MBEDTLS_ERR_GENERIC_ERROR; |
1255 | 1256 | size_t n; |
1256 | 1257 | MPI_VALIDATE_RET( X != NULL ); |
1257 | 1258 | MPI_VALIDATE_RET( A != NULL ); |
@@ -1474,7 +1475,7 @@ void mpi_mul_hlp( size_t i, mbedtls_mpi_uint *s, mbedtls_mpi_uint *d, mbedtls_mp |
1474 | 1475 | */ |
1475 | 1476 | int mbedtls_mpi_mul_mpi( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *B ) |
1476 | 1477 | { |
1477 | | - int ret; |
| 1478 | + int ret = MBEDTLS_ERR_GENERIC_ERROR; |
1478 | 1479 | size_t i, j; |
1479 | 1480 | mbedtls_mpi TA, TB; |
1480 | 1481 | MPI_VALIDATE_RET( X != NULL ); |
@@ -1629,7 +1630,7 @@ static mbedtls_mpi_uint mbedtls_int_div_int( mbedtls_mpi_uint u1, |
1629 | 1630 | int mbedtls_mpi_div_mpi( mbedtls_mpi *Q, mbedtls_mpi *R, const mbedtls_mpi *A, |
1630 | 1631 | const mbedtls_mpi *B ) |
1631 | 1632 | { |
1632 | | - int ret; |
| 1633 | + int ret = MBEDTLS_ERR_GENERIC_ERROR; |
1633 | 1634 | size_t i, n, t, k; |
1634 | 1635 | mbedtls_mpi X, Y, Z, T1, T2; |
1635 | 1636 | mbedtls_mpi_uint TP2[3]; |
@@ -1775,7 +1776,7 @@ int mbedtls_mpi_div_int( mbedtls_mpi *Q, mbedtls_mpi *R, |
1775 | 1776 | */ |
1776 | 1777 | int mbedtls_mpi_mod_mpi( mbedtls_mpi *R, const mbedtls_mpi *A, const mbedtls_mpi *B ) |
1777 | 1778 | { |
1778 | | - int ret; |
| 1779 | + int ret = MBEDTLS_ERR_GENERIC_ERROR; |
1779 | 1780 | MPI_VALIDATE_RET( R != NULL ); |
1780 | 1781 | MPI_VALIDATE_RET( A != NULL ); |
1781 | 1782 | MPI_VALIDATE_RET( B != NULL ); |
@@ -1937,7 +1938,7 @@ int mbedtls_mpi_exp_mod( mbedtls_mpi *X, const mbedtls_mpi *A, |
1937 | 1938 | const mbedtls_mpi *E, const mbedtls_mpi *N, |
1938 | 1939 | mbedtls_mpi *_RR ) |
1939 | 1940 | { |
1940 | | - int ret; |
| 1941 | + int ret = MBEDTLS_ERR_GENERIC_ERROR; |
1941 | 1942 | size_t wbits, wsize, one = 1; |
1942 | 1943 | size_t i, j, nblimbs; |
1943 | 1944 | size_t bufsize, nbits; |
@@ -2152,7 +2153,7 @@ int mbedtls_mpi_exp_mod( mbedtls_mpi *X, const mbedtls_mpi *A, |
2152 | 2153 | */ |
2153 | 2154 | int mbedtls_mpi_gcd( mbedtls_mpi *G, const mbedtls_mpi *A, const mbedtls_mpi *B ) |
2154 | 2155 | { |
2155 | | - int ret; |
| 2156 | + int ret = MBEDTLS_ERR_GENERIC_ERROR; |
2156 | 2157 | size_t lz, lzt; |
2157 | 2158 | mbedtls_mpi TA, TB; |
2158 | 2159 |
|
@@ -2214,7 +2215,7 @@ int mbedtls_mpi_fill_random( mbedtls_mpi *X, size_t size, |
2214 | 2215 | int (*f_rng)(void *, unsigned char *, size_t), |
2215 | 2216 | void *p_rng ) |
2216 | 2217 | { |
2217 | | - int ret; |
| 2218 | + int ret = MBEDTLS_ERR_GENERIC_ERROR; |
2218 | 2219 | size_t const limbs = CHARS_TO_LIMBS( size ); |
2219 | 2220 | size_t const overhead = ( limbs * ciL ) - size; |
2220 | 2221 | unsigned char *Xp; |
@@ -2245,7 +2246,7 @@ int mbedtls_mpi_fill_random( mbedtls_mpi *X, size_t size, |
2245 | 2246 | */ |
2246 | 2247 | int mbedtls_mpi_inv_mod( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *N ) |
2247 | 2248 | { |
2248 | | - int ret; |
| 2249 | + int ret = MBEDTLS_ERR_GENERIC_ERROR; |
2249 | 2250 | mbedtls_mpi G, TA, TU, U1, U2, TB, TV, V1, V2; |
2250 | 2251 | MPI_VALIDATE_RET( X != NULL ); |
2251 | 2252 | MPI_VALIDATE_RET( A != NULL ); |
@@ -2498,7 +2499,7 @@ int mbedtls_mpi_is_prime_ext( const mbedtls_mpi *X, int rounds, |
2498 | 2499 | int (*f_rng)(void *, unsigned char *, size_t), |
2499 | 2500 | void *p_rng ) |
2500 | 2501 | { |
2501 | | - int ret; |
| 2502 | + int ret = MBEDTLS_ERR_GENERIC_ERROR; |
2502 | 2503 | mbedtls_mpi XX; |
2503 | 2504 | MPI_VALIDATE_RET( X != NULL ); |
2504 | 2505 | MPI_VALIDATE_RET( f_rng != NULL ); |
|
0 commit comments