Const-correct some of the low-level BIGNUM functions.
Change-Id: I8c6257e336f54a3a1786df9c4103fcf29177030a Reviewed-on: https://boringssl-review.googlesource.com/23067 Reviewed-by: Adam Langley <agl@google.com>
This commit is contained in:
parent
bd275702d2
commit
64619deaa3
@ -281,7 +281,7 @@ BN_ULONG bn_sub_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,
|
|||||||
|
|
||||||
#define sqr_add_c2(a, i, j, c0, c1, c2) mul_add_c2((a)[i], (a)[j], c0, c1, c2)
|
#define sqr_add_c2(a, i, j, c0, c1, c2) mul_add_c2((a)[i], (a)[j], c0, c1, c2)
|
||||||
|
|
||||||
void bn_mul_comba8(BN_ULONG r[16], BN_ULONG a[8], BN_ULONG b[8]) {
|
void bn_mul_comba8(BN_ULONG r[16], const BN_ULONG a[8], const BN_ULONG b[8]) {
|
||||||
BN_ULONG c1, c2, c3;
|
BN_ULONG c1, c2, c3;
|
||||||
|
|
||||||
c1 = 0;
|
c1 = 0;
|
||||||
@ -383,7 +383,7 @@ void bn_mul_comba8(BN_ULONG r[16], BN_ULONG a[8], BN_ULONG b[8]) {
|
|||||||
r[15] = c1;
|
r[15] = c1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void bn_mul_comba4(BN_ULONG r[8], BN_ULONG a[4], BN_ULONG b[4]) {
|
void bn_mul_comba4(BN_ULONG r[8], const BN_ULONG a[4], const BN_ULONG b[4]) {
|
||||||
BN_ULONG c1, c2, c3;
|
BN_ULONG c1, c2, c3;
|
||||||
|
|
||||||
c1 = 0;
|
c1 = 0;
|
||||||
|
@ -453,7 +453,7 @@ BN_ULONG bn_sub_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,
|
|||||||
|
|
||||||
#endif // !BN_ULLONG
|
#endif // !BN_ULLONG
|
||||||
|
|
||||||
void bn_mul_comba8(BN_ULONG r[16], BN_ULONG a[8], BN_ULONG b[8]) {
|
void bn_mul_comba8(BN_ULONG r[16], const BN_ULONG a[8], const BN_ULONG b[8]) {
|
||||||
BN_ULONG c1, c2, c3;
|
BN_ULONG c1, c2, c3;
|
||||||
|
|
||||||
c1 = 0;
|
c1 = 0;
|
||||||
@ -555,7 +555,7 @@ void bn_mul_comba8(BN_ULONG r[16], BN_ULONG a[8], BN_ULONG b[8]) {
|
|||||||
r[15] = c1;
|
r[15] = c1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void bn_mul_comba4(BN_ULONG r[8], BN_ULONG a[4], BN_ULONG b[4]) {
|
void bn_mul_comba4(BN_ULONG r[8], const BN_ULONG a[4], const BN_ULONG b[4]) {
|
||||||
BN_ULONG c1, c2, c3;
|
BN_ULONG c1, c2, c3;
|
||||||
|
|
||||||
c1 = 0;
|
c1 = 0;
|
||||||
|
@ -244,10 +244,10 @@ BN_ULONG bn_sub_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,
|
|||||||
size_t num);
|
size_t num);
|
||||||
|
|
||||||
// bn_mul_comba4 sets |r| to the product of |a| and |b|.
|
// bn_mul_comba4 sets |r| to the product of |a| and |b|.
|
||||||
void bn_mul_comba4(BN_ULONG r[8], BN_ULONG a[4], BN_ULONG b[4]);
|
void bn_mul_comba4(BN_ULONG r[8], const BN_ULONG a[4], const BN_ULONG b[4]);
|
||||||
|
|
||||||
// bn_mul_comba8 sets |r| to the product of |a| and |b|.
|
// bn_mul_comba8 sets |r| to the product of |a| and |b|.
|
||||||
void bn_mul_comba8(BN_ULONG r[16], BN_ULONG a[8], BN_ULONG b[8]);
|
void bn_mul_comba8(BN_ULONG r[16], const BN_ULONG a[8], const BN_ULONG b[8]);
|
||||||
|
|
||||||
// bn_sqr_comba8 sets |r| to |a|^2.
|
// bn_sqr_comba8 sets |r| to |a|^2.
|
||||||
void bn_sqr_comba8(BN_ULONG r[16], const BN_ULONG a[4]);
|
void bn_sqr_comba8(BN_ULONG r[16], const BN_ULONG a[4]);
|
||||||
|
@ -67,13 +67,13 @@
|
|||||||
#define BN_SQR_RECURSIVE_SIZE_NORMAL BN_MUL_RECURSIVE_SIZE_NORMAL
|
#define BN_SQR_RECURSIVE_SIZE_NORMAL BN_MUL_RECURSIVE_SIZE_NORMAL
|
||||||
|
|
||||||
|
|
||||||
static void bn_mul_normal(BN_ULONG *r, BN_ULONG *a, size_t na, BN_ULONG *b,
|
static void bn_mul_normal(BN_ULONG *r, const BN_ULONG *a, size_t na,
|
||||||
size_t nb) {
|
const BN_ULONG *b, size_t nb) {
|
||||||
if (na < nb) {
|
if (na < nb) {
|
||||||
size_t itmp = na;
|
size_t itmp = na;
|
||||||
na = nb;
|
na = nb;
|
||||||
nb = itmp;
|
nb = itmp;
|
||||||
BN_ULONG *ltmp = a;
|
const BN_ULONG *ltmp = a;
|
||||||
a = b;
|
a = b;
|
||||||
b = ltmp;
|
b = ltmp;
|
||||||
}
|
}
|
||||||
@ -289,8 +289,8 @@ BN_ULONG bn_sub_part_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,
|
|||||||
// a[0]*b[0]+a[1]*b[1]+(a[0]-a[1])*(b[1]-b[0])
|
// a[0]*b[0]+a[1]*b[1]+(a[0]-a[1])*(b[1]-b[0])
|
||||||
// a[1]*b[1]
|
// a[1]*b[1]
|
||||||
// dnX may not be positive, but n2/2+dnX has to be
|
// dnX may not be positive, but n2/2+dnX has to be
|
||||||
static void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,
|
static void bn_mul_recursive(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,
|
||||||
int dna, int dnb, BN_ULONG *t) {
|
int n2, int dna, int dnb, BN_ULONG *t) {
|
||||||
int n = n2 / 2, c1, c2;
|
int n = n2 / 2, c1, c2;
|
||||||
int tna = n + dna, tnb = n + dnb;
|
int tna = n + dna, tnb = n + dnb;
|
||||||
unsigned int neg, zero;
|
unsigned int neg, zero;
|
||||||
@ -421,8 +421,9 @@ static void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,
|
|||||||
// n+tn is the word length
|
// n+tn is the word length
|
||||||
// t needs to be n*4 is size, as does r
|
// t needs to be n*4 is size, as does r
|
||||||
// tnX may not be negative but less than n
|
// tnX may not be negative but less than n
|
||||||
static void bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n,
|
static void bn_mul_part_recursive(BN_ULONG *r, const BN_ULONG *a,
|
||||||
int tna, int tnb, BN_ULONG *t) {
|
const BN_ULONG *b, int n, int tna, int tnb,
|
||||||
|
BN_ULONG *t) {
|
||||||
int i, j, n2 = n * 2;
|
int i, j, n2 = n * 2;
|
||||||
int c1, c2, neg;
|
int c1, c2, neg;
|
||||||
BN_ULONG ln, lo, *p;
|
BN_ULONG ln, lo, *p;
|
||||||
|
Loading…
Reference in New Issue
Block a user