diff options
author | Daiki Ueno <ueno@gnu.org> | 2020-09-03 16:28:34 +0000 |
---|---|---|
committer | Daiki Ueno <ueno@gnu.org> | 2020-09-03 16:28:34 +0000 |
commit | a91a70076cd39a050b036e1a7902451f060d205a (patch) | |
tree | 2c33728e93efc947384c89025245fea4e809ac2f | |
parent | 939683e5f8797f5baaf610f75e0f1fd31ca08567 (diff) | |
parent | f2ee5bed85acc2b393b9f48f0ead1e8189d99de0 (diff) | |
download | gnutls-a91a70076cd39a050b036e1a7902451f060d205a.tar.gz |
Merge branch 'tmp-sizeof' into 'master'
Fix padlock partial PHE detection and sizeof usage
Closes #1076
See merge request gnutls/gnutls!1316
-rw-r--r-- | lib/accelerated/x86/x86-common.c | 16 | ||||
-rw-r--r-- | tests/suite/mini-record-timing.c | 2 |
2 files changed, 11 insertions, 7 deletions
diff --git a/lib/accelerated/x86/x86-common.c b/lib/accelerated/x86/x86-common.c index 3845c6b4c9..29410e51fd 100644 --- a/lib/accelerated/x86/x86-common.c +++ b/lib/accelerated/x86/x86-common.c @@ -306,17 +306,21 @@ static int check_phe_sha512(unsigned edx) static int check_phe_partial(void) { - const char *text = "test and test"; + const char text[64] = + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; uint32_t iv[5] = { 0x67452301UL, 0xEFCDAB89UL, 0x98BADCFEUL, 0x10325476UL, 0xC3D2E1F0UL }; - padlock_sha1_blocks(iv, text, sizeof(text) - 1); - padlock_sha1_blocks(iv, text, sizeof(text) - 1); + /* If EAX is set to -1 (this is the case with padlock_sha1_blocks), the + * xsha1 instruction takes a complete SHA-1 block (64 bytes), while it + * takes arbitrary length data otherwise. */ + padlock_sha1_blocks(iv, text, 1); - if (iv[0] == 0x9096E2D8UL && iv[1] == 0xA33074EEUL && - iv[2] == 0xCDBEE447UL && iv[3] == 0xEC7979D2UL && - iv[4] == 0x9D3FF5CFUL) + if (iv[0] == 0xDA4968EBUL && iv[1] == 0x2E377C1FUL && + iv[2] == 0x884E8F52UL && iv[3] == 0x83524BEBUL && + iv[4] == 0xE74EBDBDUL) return 1; else return 0; diff --git a/tests/suite/mini-record-timing.c b/tests/suite/mini-record-timing.c index 354f733d63..093f3d5d32 100644 --- a/tests/suite/mini-record-timing.c +++ b/tests/suite/mini-record-timing.c @@ -232,7 +232,7 @@ client(int fd, const char *prio, unsigned int text_size, restart: do { - ret = gnutls_record_send(session, text, sizeof(text)); + ret = gnutls_record_send(session, text, text_size); } while (ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED); /* measure peer's processing time */ |