"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "crypto/bn/rsaz_exp.c" between
openssl-1.1.1o.tar.gz and openssl-1.1.1p.tar.gz

About: OpenSSL is a toolkit implementing the Transport Layer Security (TLS) protocols (including SSLv3) as well as a full-strength general purpose cryptographic library. Long Term Support (LTS) version (includes support for TLSv1.3).

rsaz_exp.c  (openssl-1.1.1o):rsaz_exp.c  (openssl-1.1.1p)
/* /*
* Copyright 2013-2016 The OpenSSL Project Authors. All Rights Reserved. * Copyright 2013-2022 The OpenSSL Project Authors. All Rights Reserved.
* Copyright (c) 2012, Intel Corporation. All Rights Reserved. * Copyright (c) 2012, Intel Corporation. All Rights Reserved.
* *
* Licensed under the OpenSSL license (the "License"). You may not use * Licensed under the OpenSSL license (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy * this file except in compliance with the License. You can obtain a copy
* in the file LICENSE in the source distribution or at * in the file LICENSE in the source distribution or at
* https://www.openssl.org/source/license.html * https://www.openssl.org/source/license.html
* *
* Originally written by Shay Gueron (1, 2), and Vlad Krasnov (1) * Originally written by Shay Gueron (1, 2), and Vlad Krasnov (1)
* (1) Intel Corporation, Israel Development Center, Haifa, Israel * (1) Intel Corporation, Israel Development Center, Haifa, Israel
* (2) University of Haifa, Israel * (2) University of Haifa, Israel
skipping to change at line 69 skipping to change at line 69
const BN_ULONG m_norm[16], const BN_ULONG RR[16], const BN_ULONG m_norm[16], const BN_ULONG RR[16],
BN_ULONG k0) BN_ULONG k0)
{ {
unsigned char storage[320 * 3 + 32 * 9 * 16 + 64]; /* 5.5KB */ unsigned char storage[320 * 3 + 32 * 9 * 16 + 64]; /* 5.5KB */
unsigned char *p_str = storage + (64 - ((size_t)storage % 64)); unsigned char *p_str = storage + (64 - ((size_t)storage % 64));
unsigned char *a_inv, *m, *result; unsigned char *a_inv, *m, *result;
unsigned char *table_s = p_str + 320 * 3; unsigned char *table_s = p_str + 320 * 3;
unsigned char *R2 = table_s; /* borrow */ unsigned char *R2 = table_s; /* borrow */
int index; int index;
int wvalue; int wvalue;
BN_ULONG tmp[16];
if ((((size_t)p_str & 4095) + 320) >> 12) { if ((((size_t)p_str & 4095) + 320) >> 12) {
result = p_str; result = p_str;
a_inv = p_str + 320; a_inv = p_str + 320;
m = p_str + 320 * 2; /* should not cross page */ m = p_str + 320 * 2; /* should not cross page */
} else { } else {
m = p_str; /* should not cross page */ m = p_str; /* should not cross page */
result = p_str + 320; result = p_str + 320;
a_inv = p_str + 320 * 2; a_inv = p_str + 320 * 2;
} }
skipping to change at line 240 skipping to change at line 241
wvalue = p_str[0] & 15; wvalue = p_str[0] & 15;
rsaz_1024_gather5_avx2(a_inv, table_s, wvalue); /* borrow a_inv */ rsaz_1024_gather5_avx2(a_inv, table_s, wvalue); /* borrow a_inv */
rsaz_1024_mul_avx2(result, result, a_inv, m, k0); rsaz_1024_mul_avx2(result, result, a_inv, m, k0);
/* from Montgomery */ /* from Montgomery */
rsaz_1024_mul_avx2(result, result, one, m, k0); rsaz_1024_mul_avx2(result, result, one, m, k0);
rsaz_1024_red2norm_avx2(result_norm, result); rsaz_1024_red2norm_avx2(result_norm, result);
bn_reduce_once_in_place(result_norm, /*carry=*/0, m_norm, tmp, 16);
OPENSSL_cleanse(storage, sizeof(storage)); OPENSSL_cleanse(storage, sizeof(storage));
OPENSSL_cleanse(tmp, sizeof(tmp));
} }
/* /*
* See crypto/bn/rsaz-x86_64.pl for further details. * See crypto/bn/rsaz-x86_64.pl for further details.
*/ */
void rsaz_512_mul(void *ret, const void *a, const void *b, const void *n, void rsaz_512_mul(void *ret, const void *a, const void *b, const void *n,
BN_ULONG k); BN_ULONG k);
void rsaz_512_mul_scatter4(void *ret, const void *a, const void *n, void rsaz_512_mul_scatter4(void *ret, const void *a, const void *n,
BN_ULONG k, const void *tbl, unsigned int power); BN_ULONG k, const void *tbl, unsigned int power);
void rsaz_512_mul_gather4(void *ret, const void *a, const void *tbl, void rsaz_512_mul_gather4(void *ret, const void *a, const void *tbl,
skipping to change at line 269 skipping to change at line 273
const BN_ULONG base[8], const BN_ULONG exponent[8], const BN_ULONG base[8], const BN_ULONG exponent[8],
const BN_ULONG m[8], BN_ULONG k0, const BN_ULONG RR[8]) const BN_ULONG m[8], BN_ULONG k0, const BN_ULONG RR[8])
{ {
unsigned char storage[16 * 8 * 8 + 64 * 2 + 64]; /* 1.2KB */ unsigned char storage[16 * 8 * 8 + 64 * 2 + 64]; /* 1.2KB */
unsigned char *table = storage + (64 - ((size_t)storage % 64)); unsigned char *table = storage + (64 - ((size_t)storage % 64));
BN_ULONG *a_inv = (BN_ULONG *)(table + 16 * 8 * 8); BN_ULONG *a_inv = (BN_ULONG *)(table + 16 * 8 * 8);
BN_ULONG *temp = (BN_ULONG *)(table + 16 * 8 * 8 + 8 * 8); BN_ULONG *temp = (BN_ULONG *)(table + 16 * 8 * 8 + 8 * 8);
unsigned char *p_str = (unsigned char *)exponent; unsigned char *p_str = (unsigned char *)exponent;
int index; int index;
unsigned int wvalue; unsigned int wvalue;
BN_ULONG tmp[8];
/* table[0] = 1_inv */ /* table[0] = 1_inv */
temp[0] = 0 - m[0]; temp[0] = 0 - m[0];
temp[1] = ~m[1]; temp[1] = ~m[1];
temp[2] = ~m[2]; temp[2] = ~m[2];
temp[3] = ~m[3]; temp[3] = ~m[3];
temp[4] = ~m[4]; temp[4] = ~m[4];
temp[5] = ~m[5]; temp[5] = ~m[5];
temp[6] = ~m[6]; temp[6] = ~m[6];
temp[7] = ~m[7]; temp[7] = ~m[7];
skipping to change at line 312 skipping to change at line 317
rsaz_512_sqr(temp, temp, m, k0, 4); rsaz_512_sqr(temp, temp, m, k0, 4);
rsaz_512_mul_gather4(temp, temp, table, m, k0, wvalue >> 4); rsaz_512_mul_gather4(temp, temp, table, m, k0, wvalue >> 4);
rsaz_512_sqr(temp, temp, m, k0, 4); rsaz_512_sqr(temp, temp, m, k0, 4);
rsaz_512_mul_gather4(temp, temp, table, m, k0, wvalue & 0x0f); rsaz_512_mul_gather4(temp, temp, table, m, k0, wvalue & 0x0f);
} }
/* from Montgomery */ /* from Montgomery */
rsaz_512_mul_by_one(result, temp, m, k0); rsaz_512_mul_by_one(result, temp, m, k0);
bn_reduce_once_in_place(result, /*carry=*/0, m, tmp, 8);
OPENSSL_cleanse(storage, sizeof(storage)); OPENSSL_cleanse(storage, sizeof(storage));
OPENSSL_cleanse(tmp, sizeof(tmp));
} }
#endif #endif
 End of changes. 7 change blocks. 
1 lines changed or deleted 9 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)