git://git.exim.org
/
exim.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Bugzilla #1097: PDKIM: Update embedded PolarSSL code to 0.14.2, thanks to Andreas...
[exim.git]
/
src
/
src
/
pdkim
/
bignum.h
diff --git
a/src/src/pdkim/bignum.h
b/src/src/pdkim/bignum.h
index aaca67ff8d6244690ef2a29a17ef88734442f4f5..55ff6ee8aafe9794ee21f456b804f1fd4075b165 100644
(file)
--- a/
src/src/pdkim/bignum.h
+++ b/
src/src/pdkim/bignum.h
@@
-1,10
+1,12
@@
/**
* \file bignum.h
*
/**
* \file bignum.h
*
- * Copyright (C) 2006-2009, Paul Bakker <polarssl_maintainer at polarssl.org>
- * All rights reserved.
+ * Copyright (C) 2006-2010, Brainspark B.V.
+ *
+ * This file is part of PolarSSL (http://www.polarssl.org)
+ * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
*
*
- *
Joined copyright on original XySSL code with: Christophe Devine
+ *
All rights reserved.
*
* 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
*
* 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
@@
-111,7
+113,7
@@
int mpi_grow( mpi *X, int nblimbs );
* \return 0 if successful,
* 1 if memory allocation failed
*/
* \return 0 if successful,
* 1 if memory allocation failed
*/
-int mpi_copy( mpi *X, mpi *Y );
+int mpi_copy( mpi *X,
const
mpi *Y );
/**
* \brief Swap the contents of X and Y
/**
* \brief Swap the contents of X and Y
@@
-137,21
+139,21
@@
int mpi_lset( mpi *X, int z );
*
* \param X MPI to use
*/
*
* \param X MPI to use
*/
-int mpi_lsb( mpi *X );
+int mpi_lsb(
const
mpi *X );
/**
* \brief Return the number of most significant bits
*
* \param X MPI to use
*/
/**
* \brief Return the number of most significant bits
*
* \param X MPI to use
*/
-int mpi_msb( mpi *X );
+int mpi_msb(
const
mpi *X );
/**
* \brief Return the total size in bytes
*
* \param X MPI to use
*/
/**
* \brief Return the total size in bytes
*
* \param X MPI to use
*/
-int mpi_size( mpi *X );
+int mpi_size(
const
mpi *X );
/**
* \brief Import from an ASCII string
/**
* \brief Import from an ASCII string
@@
-162,7
+164,7
@@
int mpi_size( mpi *X );
*
* \return 0 if successful, or an POLARSSL_ERR_MPI_XXX error code
*/
*
* \return 0 if successful, or an POLARSSL_ERR_MPI_XXX error code
*/
-int mpi_read_string( mpi *X, int radix, char *s );
+int mpi_read_string( mpi *X, int radix, c
onst c
har *s );
/**
* \brief Export into an ASCII string
/**
* \brief Export into an ASCII string
@@
-172,12
+174,14
@@
int mpi_read_string( mpi *X, int radix, char *s );
* \param s String buffer
* \param slen String buffer size
*
* \param s String buffer
* \param slen String buffer size
*
- * \return 0 if successful, or an POLARSSL_ERR_MPI_XXX error code
+ * \return 0 if successful, or an POLARSSL_ERR_MPI_XXX error code.
+ * *slen is always updated to reflect the amount
+ * of data that has (or would have) been written.
*
* \note Call this function with *slen = 0 to obtain the
* minimum required buffer size in *slen.
*/
*
* \note Call this function with *slen = 0 to obtain the
* minimum required buffer size in *slen.
*/
-int mpi_write_string( mpi *X, int radix, char *s, int *slen );
+int mpi_write_string(
const
mpi *X, int radix, char *s, int *slen );
/**
* \brief Read X from an opened file
/**
* \brief Read X from an opened file
@@
-202,7
+206,7
@@
int mpi_read_file( mpi *X, int radix, FILE *fin );
*
* \note Set fout == NULL to print X on the console.
*/
*
* \note Set fout == NULL to print X on the console.
*/
-int mpi_write_file( c
har *p,
mpi *X, int radix, FILE *fout );
+int mpi_write_file( c
onst char *p, const
mpi *X, int radix, FILE *fout );
/**
* \brief Import X from unsigned binary data, big endian
/**
* \brief Import X from unsigned binary data, big endian
@@
-214,7
+218,7
@@
int mpi_write_file( char *p, mpi *X, int radix, FILE *fout );
* \return 0 if successful,
* 1 if memory allocation failed
*/
* \return 0 if successful,
* 1 if memory allocation failed
*/
-int mpi_read_binary( mpi *X, unsigned char *buf, int buflen );
+int mpi_read_binary( mpi *X,
const
unsigned char *buf, int buflen );
/**
* \brief Export X into unsigned binary data, big endian
/**
* \brief Export X into unsigned binary data, big endian
@@
-226,7
+230,7
@@
int mpi_read_binary( mpi *X, unsigned char *buf, int buflen );
* \return 0 if successful,
* POLARSSL_ERR_MPI_BUFFER_TOO_SMALL if buf isn't large enough
*/
* \return 0 if successful,
* POLARSSL_ERR_MPI_BUFFER_TOO_SMALL if buf isn't large enough
*/
-int mpi_write_binary( mpi *X, unsigned char *buf, int buflen );
+int mpi_write_binary(
const
mpi *X, unsigned char *buf, int buflen );
/**
* \brief Left-shift: X <<= count
/**
* \brief Left-shift: X <<= count
@@
-260,7
+264,7
@@
int mpi_shift_r( mpi *X, int count );
* -1 if |X| is lesser than |Y| or
* 0 if |X| is equal to |Y|
*/
* -1 if |X| is lesser than |Y| or
* 0 if |X| is equal to |Y|
*/
-int mpi_cmp_abs(
mpi *X,
mpi *Y );
+int mpi_cmp_abs(
const mpi *X, const
mpi *Y );
/**
* \brief Compare signed values
/**
* \brief Compare signed values
@@
-272,7
+276,7
@@
int mpi_cmp_abs( mpi *X, mpi *Y );
* -1 if X is lesser than Y or
* 0 if X is equal to Y
*/
* -1 if X is lesser than Y or
* 0 if X is equal to Y
*/
-int mpi_cmp_mpi(
mpi *X,
mpi *Y );
+int mpi_cmp_mpi(
const mpi *X, const
mpi *Y );
/**
* \brief Compare signed values
/**
* \brief Compare signed values
@@
-284,7
+288,7
@@
int mpi_cmp_mpi( mpi *X, mpi *Y );
* -1 if X is lesser than z or
* 0 if X is equal to z
*/
* -1 if X is lesser than z or
* 0 if X is equal to z
*/
-int mpi_cmp_int( mpi *X, int z );
+int mpi_cmp_int(
const
mpi *X, int z );
/**
* \brief Unsigned addition: X = |A| + |B|
/**
* \brief Unsigned addition: X = |A| + |B|
@@
-296,7
+300,7
@@
int mpi_cmp_int( mpi *X, int z );
* \return 0 if successful,
* 1 if memory allocation failed
*/
* \return 0 if successful,
* 1 if memory allocation failed
*/
-int mpi_add_abs( mpi *X,
mpi *A,
mpi *B );
+int mpi_add_abs( mpi *X,
const mpi *A, const
mpi *B );
/**
* \brief Unsigned substraction: X = |A| - |B|
/**
* \brief Unsigned substraction: X = |A| - |B|
@@
-308,7
+312,7
@@
int mpi_add_abs( mpi *X, mpi *A, mpi *B );
* \return 0 if successful,
* POLARSSL_ERR_MPI_NEGATIVE_VALUE if B is greater than A
*/
* \return 0 if successful,
* POLARSSL_ERR_MPI_NEGATIVE_VALUE if B is greater than A
*/
-int mpi_sub_abs( mpi *X,
mpi *A,
mpi *B );
+int mpi_sub_abs( mpi *X,
const mpi *A, const
mpi *B );
/**
* \brief Signed addition: X = A + B
/**
* \brief Signed addition: X = A + B
@@
-320,7
+324,7
@@
int mpi_sub_abs( mpi *X, mpi *A, mpi *B );
* \return 0 if successful,
* 1 if memory allocation failed
*/
* \return 0 if successful,
* 1 if memory allocation failed
*/
-int mpi_add_mpi( mpi *X,
mpi *A,
mpi *B );
+int mpi_add_mpi( mpi *X,
const mpi *A, const
mpi *B );
/**
* \brief Signed substraction: X = A - B
/**
* \brief Signed substraction: X = A - B
@@
-332,7
+336,7
@@
int mpi_add_mpi( mpi *X, mpi *A, mpi *B );
* \return 0 if successful,
* 1 if memory allocation failed
*/
* \return 0 if successful,
* 1 if memory allocation failed
*/
-int mpi_sub_mpi( mpi *X,
mpi *A,
mpi *B );
+int mpi_sub_mpi( mpi *X,
const mpi *A, const
mpi *B );
/**
* \brief Signed addition: X = A + b
/**
* \brief Signed addition: X = A + b
@@
-344,7
+348,7
@@
int mpi_sub_mpi( mpi *X, mpi *A, mpi *B );
* \return 0 if successful,
* 1 if memory allocation failed
*/
* \return 0 if successful,
* 1 if memory allocation failed
*/
-int mpi_add_int( mpi *X, mpi *A, int b );
+int mpi_add_int( mpi *X,
const
mpi *A, int b );
/**
* \brief Signed substraction: X = A - b
/**
* \brief Signed substraction: X = A - b
@@
-356,7
+360,7
@@
int mpi_add_int( mpi *X, mpi *A, int b );
* \return 0 if successful,
* 1 if memory allocation failed
*/
* \return 0 if successful,
* 1 if memory allocation failed
*/
-int mpi_sub_int( mpi *X, mpi *A, int b );
+int mpi_sub_int( mpi *X,
const
mpi *A, int b );
/**
* \brief Baseline multiplication: X = A * B
/**
* \brief Baseline multiplication: X = A * B
@@
-368,7
+372,7
@@
int mpi_sub_int( mpi *X, mpi *A, int b );
* \return 0 if successful,
* 1 if memory allocation failed
*/
* \return 0 if successful,
* 1 if memory allocation failed
*/
-int mpi_mul_mpi( mpi *X,
mpi *A,
mpi *B );
+int mpi_mul_mpi( mpi *X,
const mpi *A, const
mpi *B );
/**
* \brief Baseline multiplication: X = A * b
/**
* \brief Baseline multiplication: X = A * b
@@
-382,7
+386,7
@@
int mpi_mul_mpi( mpi *X, mpi *A, mpi *B );
* \return 0 if successful,
* 1 if memory allocation failed
*/
* \return 0 if successful,
* 1 if memory allocation failed
*/
-int mpi_mul_int( mpi *X, mpi *A, t_int b );
+int mpi_mul_int( mpi *X,
const
mpi *A, t_int b );
/**
* \brief Division by mpi: A = Q * B + R
/**
* \brief Division by mpi: A = Q * B + R
@@
-398,7
+402,7
@@
int mpi_mul_int( mpi *X, mpi *A, t_int b );
*
* \note Either Q or R can be NULL.
*/
*
* \note Either Q or R can be NULL.
*/
-int mpi_div_mpi( mpi *Q, mpi *R,
mpi *A,
mpi *B );
+int mpi_div_mpi( mpi *Q, mpi *R,
const mpi *A, const
mpi *B );
/**
* \brief Division by int: A = Q * b + R
/**
* \brief Division by int: A = Q * b + R
@@
-414,7
+418,7
@@
int mpi_div_mpi( mpi *Q, mpi *R, mpi *A, mpi *B );
*
* \note Either Q or R can be NULL.
*/
*
* \note Either Q or R can be NULL.
*/
-int mpi_div_int( mpi *Q, mpi *R, mpi *A, int b );
+int mpi_div_int( mpi *Q, mpi *R,
const
mpi *A, int b );
/**
* \brief Modulo: R = A mod B
/**
* \brief Modulo: R = A mod B
@@
-428,12
+432,12
@@
int mpi_div_int( mpi *Q, mpi *R, mpi *A, int b );
* POLARSSL_ERR_MPI_DIVISION_BY_ZERO if B == 0,
* POLARSSL_ERR_MPI_NEGATIVE_VALUE if B < 0
*/
* POLARSSL_ERR_MPI_DIVISION_BY_ZERO if B == 0,
* POLARSSL_ERR_MPI_NEGATIVE_VALUE if B < 0
*/
-int mpi_mod_mpi( mpi *R,
mpi *A,
mpi *B );
+int mpi_mod_mpi( mpi *R,
const mpi *A, const
mpi *B );
/**
* \brief Modulo: r = A mod b
*
/**
* \brief Modulo: r = A mod b
*
- * \param
a
Destination t_int
+ * \param
r
Destination t_int
* \param A Left-hand MPI
* \param b Integer to divide by
*
* \param A Left-hand MPI
* \param b Integer to divide by
*
@@
-442,7
+446,7
@@
int mpi_mod_mpi( mpi *R, mpi *A, mpi *B );
* POLARSSL_ERR_MPI_DIVISION_BY_ZERO if b == 0,
* POLARSSL_ERR_MPI_NEGATIVE_VALUE if b < 0
*/
* POLARSSL_ERR_MPI_DIVISION_BY_ZERO if b == 0,
* POLARSSL_ERR_MPI_NEGATIVE_VALUE if b < 0
*/
-int mpi_mod_int( t_int *r, mpi *A, int b );
+int mpi_mod_int( t_int *r,
const
mpi *A, int b );
/**
* \brief Sliding-window exponentiation: X = A^E mod N
/**
* \brief Sliding-window exponentiation: X = A^E mod N
@@
-461,7
+465,7
@@
int mpi_mod_int( t_int *r, mpi *A, int b );
* multiple calls, which speeds up things a bit. It can
* be set to NULL if the extra performance is unneeded.
*/
* multiple calls, which speeds up things a bit. It can
* be set to NULL if the extra performance is unneeded.
*/
-int mpi_exp_mod( mpi *X,
mpi *A, mpi *E,
mpi *N, mpi *_RR );
+int mpi_exp_mod( mpi *X,
const mpi *A, const mpi *E, const
mpi *N, mpi *_RR );
/**
* \brief Greatest common divisor: G = gcd(A, B)
/**
* \brief Greatest common divisor: G = gcd(A, B)
@@
-473,7
+477,7
@@
int mpi_exp_mod( mpi *X, mpi *A, mpi *E, mpi *N, mpi *_RR );
* \return 0 if successful,
* 1 if memory allocation failed
*/
* \return 0 if successful,
* 1 if memory allocation failed
*/
-int mpi_gcd( mpi *G,
mpi *A,
mpi *B );
+int mpi_gcd( mpi *G,
const mpi *A, const
mpi *B );
/**
* \brief Modular inverse: X = A^-1 mod N
/**
* \brief Modular inverse: X = A^-1 mod N
@@
-487,7
+491,7
@@
int mpi_gcd( mpi *G, mpi *A, mpi *B );
* POLARSSL_ERR_MPI_BAD_INPUT_DATA if N is negative or nil
POLARSSL_ERR_MPI_NOT_ACCEPTABLE if A has no inverse mod N
*/
* POLARSSL_ERR_MPI_BAD_INPUT_DATA if N is negative or nil
POLARSSL_ERR_MPI_NOT_ACCEPTABLE if A has no inverse mod N
*/
-int mpi_inv_mod( mpi *X,
mpi *A,
mpi *N );
+int mpi_inv_mod( mpi *X,
const mpi *A, const
mpi *N );
/**
* \brief Miller-Rabin primality test
/**
* \brief Miller-Rabin primality test