Skip to content

Commit

Permalink
Merge pull request #8 from corsix/dynasm-aes-gcm
Browse files Browse the repository at this point in the history
DynASM implementation of AES-GCM encryption
  • Loading branch information
eugeneia committed Jan 7, 2016
2 parents 6651f01 + 0b10bcd commit ddcb6eb
Show file tree
Hide file tree
Showing 7 changed files with 503 additions and 64 deletions.
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

3 changes: 0 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ all: $(LUAJIT) $(SYSCALL) $(PFLUA)
@cp -p lib/ljsyscall/syscall/linux/*.lua src/syscall/linux/
@cp -pr lib/ljsyscall/syscall/linux/x64 src/syscall/linux/
@cp -pr lib/ljsyscall/syscall/shared src/syscall/
# Intel IPsec
@(cd lib/intel-ipsec/code && \
$(MAKE) YASM=yasm obj/gcm_avx_gen4.o obj/aes_keyexp_128.o)
cd src && $(MAKE)

install: all
Expand Down
1 change: 0 additions & 1 deletion lib/intel-ipsec
Submodule intel-ipsec deleted from 4d7b9e
2 changes: 0 additions & 2 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ snabb: $(LUAOBJ) $(PFLUAOBJ) $(HOBJ) $(COBJ) $(ARCHOBJ) $(ASMOBJ) $(INCOBJ) $(LU
$(E) "LINK $@"
$(Q) gcc $(DEBUG) -Wl,--no-as-needed -Wl,-E -Werror -Wall -o $@ $^ \
../lib/luajit/src/libluajit.a \
../lib/intel-ipsec/code/obj/gcm_avx_gen4.o \
../lib/intel-ipsec/code/obj/aes_keyexp_128.o \
-lrt -lc -ldl -lm -lpthread
@echo -n "BINARY "
@ln -fs snabb snabbswitch
Expand Down
50 changes: 0 additions & 50 deletions src/apps/ipsec/aes_128_gcm.h

This file was deleted.

10 changes: 5 additions & 5 deletions src/apps/ipsec/aes_128_gcm.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module(..., package.seeall)
local ffi = require("ffi")
local C = ffi.C
local ASM = require("apps.ipsec.aes_128_gcm_avx")
local header = require("lib.protocol.header")
local lib = require("core.lib")
require("apps.ipsec.aes_128_gcm_h")
local ntohl, htonl, htonll = lib.ntohl, lib.htonl, lib.htonll


Expand Down Expand Up @@ -71,8 +71,8 @@ function aes_128_gcm:new (conf)
-- Compute subkey (H)
o.hash_subkey = ffi.new("uint8_t[?] __attribute__((aligned(16)))", 128)
o.gcm_data = ffi.new("gcm_data[1] __attribute__((aligned(16)))")
C.aes_keyexp_128_enc_avx(o.keymat, o.gcm_data[0].expanded_keys)
C.aesni_gcm_precomp_avx_gen4(o.gcm_data, o.hash_subkey)
ASM.aes_keyexp_128_enc_avx(o.keymat, o.gcm_data[0].expanded_keys)
ASM.aesni_gcm_precomp_avx_gen4(o.gcm_data, o.hash_subkey)
o.blocksize = 128
o.auth_size = 16
o.auth_buf = ffi.new("uint8_t[?]", o.auth_size)
Expand All @@ -82,7 +82,7 @@ end

function aes_128_gcm:encrypt (out_ptr, payload, length, esp)
self.iv:iv(esp:seq_no())
C.aesni_gcm_enc_avx_gen4(self.gcm_data,
ASM.aesni_gcm_enc_avx_gen4(self.gcm_data,
out_ptr,
payload, length,
u8_ptr(self.iv:header_ptr()),
Expand All @@ -92,7 +92,7 @@ end

function aes_128_gcm:decrypt (out_ptr, ciphertext, length, esp)
self.iv:iv(esp:seq_no())
C.aesni_gcm_dec_avx_gen4(self.gcm_data,
ASM.aesni_gcm_dec_avx_gen4(self.gcm_data,
out_ptr,
ciphertext, length,
u8_ptr(self.iv:header_ptr()),
Expand Down
Loading

0 comments on commit ddcb6eb

Please sign in to comment.