Add missing register clearing in to SHA-256 and SHA-512 assembly
authorJussi Kivilinna <jussi.kivilinna@iki.fi>
Fri, 13 Dec 2013 14:14:05 +0000 (16:14 +0200)
committerJussi Kivilinna <jussi.kivilinna@iki.fi>
Fri, 13 Dec 2013 14:14:05 +0000 (16:14 +0200)
* cipher/sha256-ssse3-amd64.S: Clear used XMM/YMM registers at return.
* cipher/sha512-avx-amd64.S: Ditto.
* cipher/sha512-avx2-bmi2-amd64.S: Ditto.
* cipher/sha512-ssse3-amd64.S: Ditto.
--

Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
cipher/sha256-ssse3-amd64.S
cipher/sha512-avx-amd64.S
cipher/sha512-avx2-bmi2-amd64.S
cipher/sha512-ssse3-amd64.S

index 06070d1..bcf0e19 100644 (file)
@@ -481,6 +481,20 @@ _gcry_sha256_transform_amd64_ssse3:
        cmp     INP, [rsp + _INP_END]
        jne     .Loop0
 
+       pxor    xmm0, xmm0
+       pxor    xmm1, xmm1
+       pxor    xmm2, xmm2
+       pxor    xmm3, xmm3
+       pxor    xmm4, xmm4
+       pxor    xmm5, xmm5
+       pxor    xmm6, xmm6
+       pxor    xmm7, xmm7
+       pxor    xmm8, xmm8
+       pxor    xmm9, xmm9
+       pxor    xmm10, xmm10
+       pxor    xmm11, xmm11
+       pxor    xmm12, xmm12
+
 .Ldone_hash:
        add     rsp, STACK_SIZE
 
index 691d771..900936e 100644 (file)
@@ -267,6 +267,8 @@ _gcry_sha512_transform_amd64_avx:
        cmp     msglen, 0
        je      .Lnowork
 
+       vzeroupper
+
        /* Allocate Stack Space */
        sub     rsp, frame_size
 
@@ -346,6 +348,18 @@ _gcry_sha512_transform_amd64_avx:
        /* Restore Stack Pointer */
        add     rsp, frame_size
 
+       vzeroupper
+       pxor    xmm0, xmm0
+       pxor    xmm1, xmm1
+       pxor    xmm2, xmm2
+       pxor    xmm3, xmm3
+       pxor    xmm4, xmm4
+       pxor    xmm5, xmm5
+       pxor    xmm6, xmm6
+       pxor    xmm7, xmm7
+       pxor    xmm8, xmm8
+       pxor    xmm9, xmm9
+
        /* Return stack burn depth */
        mov     rax, frame_size
 
index 878c41b..9ece4fd 100644 (file)
@@ -604,6 +604,8 @@ _gcry_sha512_transform_amd64_avx2:
        cmp rdx, 0
        je .Lnowork
 
+       vzeroupper
+
        /* Allocate Stack Space */
        mov     rax, rsp
        sub     rsp, frame_size
@@ -717,6 +719,18 @@ _gcry_sha512_transform_amd64_avx2:
        /* Restore Stack Pointer */
        mov     rsp, [rsp + frame_RSPSAVE]
 
+       vzeroupper
+       pxor    xmm0, xmm0
+       pxor    xmm1, xmm1
+       pxor    xmm2, xmm2
+       pxor    xmm3, xmm3
+       pxor    xmm4, xmm4
+       pxor    xmm5, xmm5
+       pxor    xmm6, xmm6
+       pxor    xmm7, xmm7
+       pxor    xmm8, xmm8
+       pxor    xmm9, xmm9
+
        mov     rax, frame_size
 .Lnowork:
        ret
index 2a719e5..4c80baa 100644 (file)
@@ -348,6 +348,13 @@ _gcry_sha512_transform_amd64_ssse3:
        /* Restore Stack Pointer */
        add     rsp, frame_size
 
+       pxor    xmm0, xmm0
+       pxor    xmm1, xmm1
+       pxor    xmm2, xmm2
+       pxor    xmm3, xmm3
+       pxor    xmm4, xmm4
+       pxor    xmm5, xmm5
+
        /* Return stack burn depth */
        mov     rax, frame_size