summaryrefslogtreecommitdiffstats
path: root/src/crypto/cipher
diff options
context:
space:
mode:
Diffstat (limited to 'src/crypto/cipher')
-rw-r--r--src/crypto/cipher/salsa20/xmm/salsa20_amd64_xmm6.s111
-rw-r--r--src/crypto/cipher/salsa20/xmm/salsa20_x86_xmm5.s101
-rw-r--r--src/crypto/cipher/salsa20/xmm/salsa20_xmm.c13
-rw-r--r--src/crypto/cipher/salsa2012/xmm/salsa2012_amd64_xmm6.s111
-rw-r--r--src/crypto/cipher/salsa2012/xmm/salsa2012_x86_xmm5.s101
-rw-r--r--src/crypto/cipher/salsa2012/xmm/salsa2012_xmm.c13
6 files changed, 20 insertions, 430 deletions
diff --git a/src/crypto/cipher/salsa20/xmm/salsa20_amd64_xmm6.s b/src/crypto/cipher/salsa20/xmm/salsa20_amd64_xmm6.s
index ce75445..b85b4f9 100644
--- a/src/crypto/cipher/salsa20/xmm/salsa20_amd64_xmm6.s
+++ b/src/crypto/cipher/salsa20/xmm/salsa20_amd64_xmm6.s
@@ -333,116 +333,13 @@
# qhasm: stack64 bytes_backup
-# qhasm: enter crypto_stream_salsa20_amd64_xmm6
-.text
-.p2align 5
-.globl _crypto_stream_salsa20_amd64_xmm6
-.globl crypto_stream_salsa20_amd64_xmm6
-_crypto_stream_salsa20_amd64_xmm6:
-crypto_stream_salsa20_amd64_xmm6:
-mov %rsp,%r11
-and $31,%r11
-add $480,%r11
-sub %r11,%rsp
-
-# qhasm: r11_stack = r11_caller
-# asm 1: movq <r11_caller=int64#9,>r11_stack=stack64#1
-# asm 2: movq <r11_caller=%r11,>r11_stack=352(%rsp)
-movq %r11,352(%rsp)
-
-# qhasm: r12_stack = r12_caller
-# asm 1: movq <r12_caller=int64#10,>r12_stack=stack64#2
-# asm 2: movq <r12_caller=%r12,>r12_stack=360(%rsp)
-movq %r12,360(%rsp)
-
-# qhasm: r13_stack = r13_caller
-# asm 1: movq <r13_caller=int64#11,>r13_stack=stack64#3
-# asm 2: movq <r13_caller=%r13,>r13_stack=368(%rsp)
-movq %r13,368(%rsp)
-
-# qhasm: r14_stack = r14_caller
-# asm 1: movq <r14_caller=int64#12,>r14_stack=stack64#4
-# asm 2: movq <r14_caller=%r14,>r14_stack=376(%rsp)
-movq %r14,376(%rsp)
-
-# qhasm: r15_stack = r15_caller
-# asm 1: movq <r15_caller=int64#13,>r15_stack=stack64#5
-# asm 2: movq <r15_caller=%r15,>r15_stack=384(%rsp)
-movq %r15,384(%rsp)
-
-# qhasm: rbx_stack = rbx_caller
-# asm 1: movq <rbx_caller=int64#14,>rbx_stack=stack64#6
-# asm 2: movq <rbx_caller=%rbx,>rbx_stack=392(%rsp)
-movq %rbx,392(%rsp)
-
-# qhasm: rbp_stack = rbp_caller
-# asm 1: movq <rbp_caller=int64#15,>rbp_stack=stack64#7
-# asm 2: movq <rbp_caller=%rbp,>rbp_stack=400(%rsp)
-movq %rbp,400(%rsp)
-
-# qhasm: bytes = arg2
-# asm 1: mov <arg2=int64#2,>bytes=int64#6
-# asm 2: mov <arg2=%rsi,>bytes=%r9
-mov %rsi,%r9
-
-# qhasm: out = arg1
-# asm 1: mov <arg1=int64#1,>out=int64#1
-# asm 2: mov <arg1=%rdi,>out=%rdi
-mov %rdi,%rdi
-
-# qhasm: m = out
-# asm 1: mov <out=int64#1,>m=int64#2
-# asm 2: mov <out=%rdi,>m=%rsi
-mov %rdi,%rsi
-
-# qhasm: iv = arg3
-# asm 1: mov <arg3=int64#3,>iv=int64#3
-# asm 2: mov <arg3=%rdx,>iv=%rdx
-mov %rdx,%rdx
-
-# qhasm: k = arg4
-# asm 1: mov <arg4=int64#4,>k=int64#8
-# asm 2: mov <arg4=%rcx,>k=%r10
-mov %rcx,%r10
-
-# qhasm: unsigned>? bytes - 0
-# asm 1: cmp $0,<bytes=int64#6
-# asm 2: cmp $0,<bytes=%r9
-cmp $0,%r9
-# comment:fp stack unchanged by jump
-
-# qhasm: goto done if !unsigned>
-jbe ._done
-
-# qhasm: a = 0
-# asm 1: mov $0,>a=int64#7
-# asm 2: mov $0,>a=%rax
-mov $0,%rax
-
-# qhasm: i = bytes
-# asm 1: mov <bytes=int64#6,>i=int64#4
-# asm 2: mov <bytes=%r9,>i=%rcx
-mov %r9,%rcx
-
-# qhasm: while (i) { *out++ = a; --i }
-rep stosb
-
-# qhasm: out -= bytes
-# asm 1: sub <bytes=int64#6,<out=int64#1
-# asm 2: sub <bytes=%r9,<out=%rdi
-sub %r9,%rdi
-# comment:fp stack unchanged by jump
-
-# qhasm: goto start
-jmp ._start
-
# qhasm: enter crypto_stream_salsa20_amd64_xmm6_xor
.text
.p2align 5
-.globl _crypto_stream_salsa20_amd64_xmm6_xor
-.globl crypto_stream_salsa20_amd64_xmm6_xor
-_crypto_stream_salsa20_amd64_xmm6_xor:
-crypto_stream_salsa20_amd64_xmm6_xor:
+.globl _fastd_salsa20_xmm_xor
+.globl fastd_salsa20_xmm_xor
+_fastd_salsa20_xmm_xor:
+fastd_salsa20_xmm_xor:
mov %rsp,%r11
and $31,%r11
add $480,%r11
diff --git a/src/crypto/cipher/salsa20/xmm/salsa20_x86_xmm5.s b/src/crypto/cipher/salsa20/xmm/salsa20_x86_xmm5.s
index 408f201..73dcdf6 100644
--- a/src/crypto/cipher/salsa20/xmm/salsa20_x86_xmm5.s
+++ b/src/crypto/cipher/salsa20/xmm/salsa20_x86_xmm5.s
@@ -285,106 +285,13 @@
# qhasm: stack32 ctarget
-# qhasm: enter crypto_stream_salsa20_x86_xmm5
-.text
-.p2align 5
-.globl _crypto_stream_salsa20_x86_xmm5
-.globl crypto_stream_salsa20_x86_xmm5
-_crypto_stream_salsa20_x86_xmm5:
-crypto_stream_salsa20_x86_xmm5:
-mov %esp,%eax
-and $31,%eax
-add $704,%eax
-sub %eax,%esp
-
-# qhasm: eax_stack = eax
-# asm 1: movl <eax=int32#1,>eax_stack=stack32#1
-# asm 2: movl <eax=%eax,>eax_stack=0(%esp)
-movl %eax,0(%esp)
-
-# qhasm: ebx_stack = ebx
-# asm 1: movl <ebx=int32#4,>ebx_stack=stack32#2
-# asm 2: movl <ebx=%ebx,>ebx_stack=4(%esp)
-movl %ebx,4(%esp)
-
-# qhasm: esi_stack = esi
-# asm 1: movl <esi=int32#5,>esi_stack=stack32#3
-# asm 2: movl <esi=%esi,>esi_stack=8(%esp)
-movl %esi,8(%esp)
-
-# qhasm: edi_stack = edi
-# asm 1: movl <edi=int32#6,>edi_stack=stack32#4
-# asm 2: movl <edi=%edi,>edi_stack=12(%esp)
-movl %edi,12(%esp)
-
-# qhasm: ebp_stack = ebp
-# asm 1: movl <ebp=int32#7,>ebp_stack=stack32#5
-# asm 2: movl <ebp=%ebp,>ebp_stack=16(%esp)
-movl %ebp,16(%esp)
-
-# qhasm: bytes = arg2
-# asm 1: movl <arg2=stack32#-2,>bytes=int32#3
-# asm 2: movl <arg2=8(%esp,%eax),>bytes=%edx
-movl 8(%esp,%eax),%edx
-
-# qhasm: out = arg1
-# asm 1: movl <arg1=stack32#-1,>out=int32#6
-# asm 2: movl <arg1=4(%esp,%eax),>out=%edi
-movl 4(%esp,%eax),%edi
-
-# qhasm: m = out
-# asm 1: mov <out=int32#6,>m=int32#5
-# asm 2: mov <out=%edi,>m=%esi
-mov %edi,%esi
-
-# qhasm: iv = arg4
-# asm 1: movl <arg4=stack32#-4,>iv=int32#4
-# asm 2: movl <arg4=16(%esp,%eax),>iv=%ebx
-movl 16(%esp,%eax),%ebx
-
-# qhasm: k = arg5
-# asm 1: movl <arg5=stack32#-5,>k=int32#7
-# asm 2: movl <arg5=20(%esp,%eax),>k=%ebp
-movl 20(%esp,%eax),%ebp
-
-# qhasm: unsigned>? bytes - 0
-# asm 1: cmp $0,<bytes=int32#3
-# asm 2: cmp $0,<bytes=%edx
-cmp $0,%edx
-# comment:fp stack unchanged by jump
-
-# qhasm: goto done if !unsigned>
-jbe ._done
-
-# qhasm: a = 0
-# asm 1: mov $0,>a=int32#1
-# asm 2: mov $0,>a=%eax
-mov $0,%eax
-
-# qhasm: i = bytes
-# asm 1: mov <bytes=int32#3,>i=int32#2
-# asm 2: mov <bytes=%edx,>i=%ecx
-mov %edx,%ecx
-
-# qhasm: while (i) { *out++ = a; --i }
-rep stosb
-
-# qhasm: out -= bytes
-# asm 1: subl <bytes=int32#3,<out=int32#6
-# asm 2: subl <bytes=%edx,<out=%edi
-subl %edx,%edi
-# comment:fp stack unchanged by jump
-
-# qhasm: goto start
-jmp ._start
-
# qhasm: enter crypto_stream_salsa20_x86_xmm5_xor
.text
.p2align 5
-.globl _crypto_stream_salsa20_x86_xmm5_xor
-.globl crypto_stream_salsa20_x86_xmm5_xor
-_crypto_stream_salsa20_x86_xmm5_xor:
-crypto_stream_salsa20_x86_xmm5_xor:
+.globl _fastd_salsa20_xmm_xor
+.globl fastd_salsa20_xmm_xor
+_fastd_salsa20_xmm_xor:
+fastd_salsa20_xmm_xor:
mov %esp,%eax
and $31,%eax
add $704,%eax
diff --git a/src/crypto/cipher/salsa20/xmm/salsa20_xmm.c b/src/crypto/cipher/salsa20/xmm/salsa20_xmm.c
index 2025c98..1c8c721 100644
--- a/src/crypto/cipher/salsa20/xmm/salsa20_xmm.c
+++ b/src/crypto/cipher/salsa20/xmm/salsa20_xmm.c
@@ -42,17 +42,8 @@
#define KEYBYTES 32
-#ifdef __x86_64__
-#define crypto_stream_salsa20_xor crypto_stream_salsa20_amd64_xmm6_xor
-#endif
-
-#ifdef __i386__
-#define crypto_stream_salsa20_xor crypto_stream_salsa20_x86_xmm5_xor
-#endif
-
-
/** The actual Salsa20 assembly implementation */
-int crypto_stream_salsa20_xor(unsigned char *c, const unsigned char *m, unsigned long long mlen, const unsigned char *n, const unsigned char *k);
+int fastd_salsa20_xmm_xor(unsigned char *c, const unsigned char *m, unsigned long long mlen, const unsigned char *n, const unsigned char *k);
/** The cipher state */
@@ -76,7 +67,7 @@ static fastd_cipher_state_t * salsa20_init(const uint8_t *key) {
/** XORs data with the Salsa20 cipher stream */
static bool salsa20_crypt(const fastd_cipher_state_t *state, fastd_block128_t *out, const fastd_block128_t *in, size_t len, const uint8_t *iv) {
- crypto_stream_salsa20_xor(out->b, in->b, len, iv, state->key);
+ fastd_salsa20_xmm_xor(out->b, in->b, len, iv, state->key);
return true;
}
diff --git a/src/crypto/cipher/salsa2012/xmm/salsa2012_amd64_xmm6.s b/src/crypto/cipher/salsa2012/xmm/salsa2012_amd64_xmm6.s
index 71249b7..1f39454 100644
--- a/src/crypto/cipher/salsa2012/xmm/salsa2012_amd64_xmm6.s
+++ b/src/crypto/cipher/salsa2012/xmm/salsa2012_amd64_xmm6.s
@@ -333,116 +333,13 @@
# qhasm: stack64 bytes_backup
-# qhasm: enter crypto_stream_salsa2012_amd64_xmm6
-.text
-.p2align 5
-.globl _crypto_stream_salsa2012_amd64_xmm6
-.globl crypto_stream_salsa2012_amd64_xmm6
-_crypto_stream_salsa2012_amd64_xmm6:
-crypto_stream_salsa2012_amd64_xmm6:
-mov %rsp,%r11
-and $31,%r11
-add $480,%r11
-sub %r11,%rsp
-
-# qhasm: r11_stack = r11_caller
-# asm 1: movq <r11_caller=int64#9,>r11_stack=stack64#1
-# asm 2: movq <r11_caller=%r11,>r11_stack=352(%rsp)
-movq %r11,352(%rsp)
-
-# qhasm: r12_stack = r12_caller
-# asm 1: movq <r12_caller=int64#10,>r12_stack=stack64#2
-# asm 2: movq <r12_caller=%r12,>r12_stack=360(%rsp)
-movq %r12,360(%rsp)
-
-# qhasm: r13_stack = r13_caller
-# asm 1: movq <r13_caller=int64#11,>r13_stack=stack64#3
-# asm 2: movq <r13_caller=%r13,>r13_stack=368(%rsp)
-movq %r13,368(%rsp)
-
-# qhasm: r14_stack = r14_caller
-# asm 1: movq <r14_caller=int64#12,>r14_stack=stack64#4
-# asm 2: movq <r14_caller=%r14,>r14_stack=376(%rsp)
-movq %r14,376(%rsp)
-
-# qhasm: r15_stack = r15_caller
-# asm 1: movq <r15_caller=int64#13,>r15_stack=stack64#5
-# asm 2: movq <r15_caller=%r15,>r15_stack=384(%rsp)
-movq %r15,384(%rsp)
-
-# qhasm: rbx_stack = rbx_caller
-# asm 1: movq <rbx_caller=int64#14,>rbx_stack=stack64#6
-# asm 2: movq <rbx_caller=%rbx,>rbx_stack=392(%rsp)
-movq %rbx,392(%rsp)
-
-# qhasm: rbp_stack = rbp_caller
-# asm 1: movq <rbp_caller=int64#15,>rbp_stack=stack64#7
-# asm 2: movq <rbp_caller=%rbp,>rbp_stack=400(%rsp)
-movq %rbp,400(%rsp)
-
-# qhasm: bytes = arg2
-# asm 1: mov <arg2=int64#2,>bytes=int64#6
-# asm 2: mov <arg2=%rsi,>bytes=%r9
-mov %rsi,%r9
-
-# qhasm: out = arg1
-# asm 1: mov <arg1=int64#1,>out=int64#1
-# asm 2: mov <arg1=%rdi,>out=%rdi
-mov %rdi,%rdi
-
-# qhasm: m = out
-# asm 1: mov <out=int64#1,>m=int64#2
-# asm 2: mov <out=%rdi,>m=%rsi
-mov %rdi,%rsi
-
-# qhasm: iv = arg3
-# asm 1: mov <arg3=int64#3,>iv=int64#3
-# asm 2: mov <arg3=%rdx,>iv=%rdx
-mov %rdx,%rdx
-
-# qhasm: k = arg4
-# asm 1: mov <arg4=int64#4,>k=int64#8
-# asm 2: mov <arg4=%rcx,>k=%r10
-mov %rcx,%r10
-
-# qhasm: unsigned>? bytes - 0
-# asm 1: cmp $0,<bytes=int64#6
-# asm 2: cmp $0,<bytes=%r9
-cmp $0,%r9
-# comment:fp stack unchanged by jump
-
-# qhasm: goto done if !unsigned>
-jbe ._done
-
-# qhasm: a = 0
-# asm 1: mov $0,>a=int64#7
-# asm 2: mov $0,>a=%rax
-mov $0,%rax
-
-# qhasm: i = bytes
-# asm 1: mov <bytes=int64#6,>i=int64#4
-# asm 2: mov <bytes=%r9,>i=%rcx
-mov %r9,%rcx
-
-# qhasm: while (i) { *out++ = a; --i }
-rep stosb
-
-# qhasm: out -= bytes
-# asm 1: sub <bytes=int64#6,<out=int64#1
-# asm 2: sub <bytes=%r9,<out=%rdi
-sub %r9,%rdi
-# comment:fp stack unchanged by jump
-
-# qhasm: goto start
-jmp ._start
-
# qhasm: enter crypto_stream_salsa2012_amd64_xmm6_xor
.text
.p2align 5
-.globl _crypto_stream_salsa2012_amd64_xmm6_xor
-.globl crypto_stream_salsa2012_amd64_xmm6_xor
-_crypto_stream_salsa2012_amd64_xmm6_xor:
-crypto_stream_salsa2012_amd64_xmm6_xor:
+.globl _fastd_salsa2012_xmm_xor
+.globl fastd_salsa2012_xmm_xor
+_fastd_salsa2012_xmm_xor:
+fastd_salsa2012_xmm_xor:
mov %rsp,%r11
and $31,%r11
add $480,%r11
diff --git a/src/crypto/cipher/salsa2012/xmm/salsa2012_x86_xmm5.s b/src/crypto/cipher/salsa2012/xmm/salsa2012_x86_xmm5.s
index a03e652..0148cff 100644
--- a/src/crypto/cipher/salsa2012/xmm/salsa2012_x86_xmm5.s
+++ b/src/crypto/cipher/salsa2012/xmm/salsa2012_x86_xmm5.s
@@ -285,106 +285,13 @@
# qhasm: stack32 ctarget
-# qhasm: enter crypto_stream_salsa2012_x86_xmm5
-.text
-.p2align 5
-.globl _crypto_stream_salsa2012_x86_xmm5
-.globl crypto_stream_salsa2012_x86_xmm5
-_crypto_stream_salsa2012_x86_xmm5:
-crypto_stream_salsa2012_x86_xmm5:
-mov %esp,%eax
-and $31,%eax
-add $704,%eax
-sub %eax,%esp
-
-# qhasm: eax_stack = eax
-# asm 1: movl <eax=int32#1,>eax_stack=stack32#1
-# asm 2: movl <eax=%eax,>eax_stack=0(%esp)
-movl %eax,0(%esp)
-
-# qhasm: ebx_stack = ebx
-# asm 1: movl <ebx=int32#4,>ebx_stack=stack32#2
-# asm 2: movl <ebx=%ebx,>ebx_stack=4(%esp)
-movl %ebx,4(%esp)
-
-# qhasm: esi_stack = esi
-# asm 1: movl <esi=int32#5,>esi_stack=stack32#3
-# asm 2: movl <esi=%esi,>esi_stack=8(%esp)
-movl %esi,8(%esp)
-
-# qhasm: edi_stack = edi
-# asm 1: movl <edi=int32#6,>edi_stack=stack32#4
-# asm 2: movl <edi=%edi,>edi_stack=12(%esp)
-movl %edi,12(%esp)
-
-# qhasm: ebp_stack = ebp
-# asm 1: movl <ebp=int32#7,>ebp_stack=stack32#5
-# asm 2: movl <ebp=%ebp,>ebp_stack=16(%esp)
-movl %ebp,16(%esp)
-
-# qhasm: bytes = arg2
-# asm 1: movl <arg2=stack32#-2,>bytes=int32#3
-# asm 2: movl <arg2=8(%esp,%eax),>bytes=%edx
-movl 8(%esp,%eax),%edx
-
-# qhasm: out = arg1
-# asm 1: movl <arg1=stack32#-1,>out=int32#6
-# asm 2: movl <arg1=4(%esp,%eax),>out=%edi
-movl 4(%esp,%eax),%edi
-
-# qhasm: m = out
-# asm 1: mov <out=int32#6,>m=int32#5
-# asm 2: mov <out=%edi,>m=%esi
-mov %edi,%esi
-
-# qhasm: iv = arg4
-# asm 1: movl <arg4=stack32#-4,>iv=int32#4
-# asm 2: movl <arg4=16(%esp,%eax),>iv=%ebx
-movl 16(%esp,%eax),%ebx
-
-# qhasm: k = arg5
-# asm 1: movl <arg5=stack32#-5,>k=int32#7
-# asm 2: movl <arg5=20(%esp,%eax),>k=%ebp
-movl 20(%esp,%eax),%ebp
-
-# qhasm: unsigned>? bytes - 0
-# asm 1: cmp $0,<bytes=int32#3
-# asm 2: cmp $0,<bytes=%edx
-cmp $0,%edx
-# comment:fp stack unchanged by jump
-
-# qhasm: goto done if !unsigned>
-jbe ._done
-
-# qhasm: a = 0
-# asm 1: mov $0,>a=int32#1
-# asm 2: mov $0,>a=%eax
-mov $0,%eax
-
-# qhasm: i = bytes
-# asm 1: mov <bytes=int32#3,>i=int32#2
-# asm 2: mov <bytes=%edx,>i=%ecx
-mov %edx,%ecx
-
-# qhasm: while (i) { *out++ = a; --i }
-rep stosb
-
-# qhasm: out -= bytes
-# asm 1: subl <bytes=int32#3,<out=int32#6
-# asm 2: subl <bytes=%edx,<out=%edi
-subl %edx,%edi
-# comment:fp stack unchanged by jump
-
-# qhasm: goto start
-jmp ._start
-
# qhasm: enter crypto_stream_salsa2012_x86_xmm5_xor
.text
.p2align 5
-.globl _crypto_stream_salsa2012_x86_xmm5_xor
-.globl crypto_stream_salsa2012_x86_xmm5_xor
-_crypto_stream_salsa2012_x86_xmm5_xor:
-crypto_stream_salsa2012_x86_xmm5_xor:
+.globl _fastd_salsa2012_xmm_xor
+.globl fastd_salsa2012_xmm_xor
+_fastd_salsa2012_xmm_xor:
+fastd_salsa2012_xmm_xor:
mov %esp,%eax
and $31,%eax
add $704,%eax
diff --git a/src/crypto/cipher/salsa2012/xmm/salsa2012_xmm.c b/src/crypto/cipher/salsa2012/xmm/salsa2012_xmm.c
index 25f7bb0..1e07d6e 100644
--- a/src/crypto/cipher/salsa2012/xmm/salsa2012_xmm.c
+++ b/src/crypto/cipher/salsa2012/xmm/salsa2012_xmm.c
@@ -42,17 +42,8 @@
#define KEYBYTES 32
-#ifdef __x86_64__
-#define crypto_stream_salsa2012_xor crypto_stream_salsa2012_amd64_xmm6_xor
-#endif
-
-#ifdef __i386__
-#define crypto_stream_salsa2012_xor crypto_stream_salsa2012_x86_xmm5_xor
-#endif
-
-
/** The actual Salsa20/12 assembly implementation */
-int crypto_stream_salsa2012_xor(unsigned char *c, const unsigned char *m, unsigned long long mlen, const unsigned char *n, const unsigned char *k);
+int fastd_salsa2012_xmm_xor(unsigned char *c, const unsigned char *m, unsigned long long mlen, const unsigned char *n, const unsigned char *k);
/** The cipher state */
@@ -76,7 +67,7 @@ static fastd_cipher_state_t * salsa2012_init(const uint8_t *key) {
/** XORs data with the Salsa20/12 cipher stream */
static bool salsa2012_crypt(const fastd_cipher_state_t *state, fastd_block128_t *out, const fastd_block128_t *in, size_t len, const uint8_t *iv) {
- crypto_stream_salsa2012_xor(out->b, in->b, len, iv, state->key);
+ fastd_salsa2012_xmm_xor(out->b, in->b, len, iv, state->key);
return true;
}