rc4 amd64 assembler implementation is buggy

Dima Kukulniak dima.ky at gmail.com
Wed Apr 29 16:40:26 CEST 2015


Hello, I've checked the code available via git and it turned out rc4 in
amd64 assembly is not correctly implemented. The following change fixed it
for me.

diff --git a/cipher/arcfour-amd64.S b/cipher/arcfour-amd64.S
index c32cd6f..6ffd78f 100644
--- a/cipher/arcfour-amd64.S
+++ b/cipher/arcfour-amd64.S
@@ -85,8 +85,8 @@ _gcry_arcfour_amd64:

 .Lfinished:
        dec     %rcx                            # x--
-       movb    %dl,            (4*256)(%rbp)   # key->y = y
-       movb    %cl,            (4*256+4)(%rbp) # key->x = x
+       movb    %dl,            (4*256+4)(%rbp) # key->y = y
+       movb    %cl,            (4*256)(%rbp)   # key->x = x
        pop     %rbx
        pop     %rbp
        ret

I'd appreciate to have it pushed to the master. Thank you.

-- 
regards, Dima
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/attachments/20150429/700d5e1b/attachment.html>


More information about the Gcrypt-devel mailing list