* Version 2.99.1 (unreleased)
+** libgnutls: Added support for AES-NI if detected. Uses
+Intel AES-NI code.
+
** libgnutls-extra: Dropped support of LZO compression via liblzo.
** libgnutls: gnutls_transport_set_global_errno() was removed. This
-I$(srcdir)/../
if ENABLE_MINITASN1
-AM_CPPFLAGS += -I$(srcdir)/../minitasn1
+AM_CPPFLAGS += -I$(srcdir)/../../minitasn1
endif
-EXTRA_DIST = aes-x86.h README license.txt
+EXTRA_DIST = aes-x86.h README license.txt iaes_asm_interface.h iaesni.h \
+ asm/x64_iaesx64.s asm/x86_iaesx86.s
+
noinst_LTLIBRARIES = libintel.la
libintel_la_SOURCES = aes-x86.c
YASM_OPTS = -D__linux__
-x64_do_rdtsc.o: asm/x64_do_rdtsc.s
- $(YASM) $(YASM_OPTS) -f elf64 $^ -o $@
-
x64_iaesx64.o: asm/x64_iaesx64.s
$(YASM) $(YASM_OPTS) -f elf64 $^ -o $@
-x86_do_rdtsc.o: asm/x86_do_rdtsc.s
- $(YASM) $(YASM_OPTS) -f elf32 $^ -o $@
-
x86_iaesx86.o: asm/x86_iaesx86.s
$(YASM) $(YASM_OPTS) -f elf32 $^ -o $@
if ASM_X86_64
-libintel_la_LIBADD += x64_do_rdtsc.o x64_iaesx64.o
+libintel_la_LIBADD += x64_iaesx64.o
else
-libintel_la_LIBADD += x86_do_rdtsc.o x86_iaesx86.o
+libintel_la_LIBADD += x86_iaesx86.o
endif
#include <gnutls_errors.h>
#include <aes-x86.h>
#include <x86.h>
-#include "iaesni.h"
#include "iaes_asm_interface.h"
#ifdef __GNUC__
typedef void (*enc_func)(sAesData*);
struct aes_ctx {
- uint8_t iv[16];
uint8_t ALIGN16 expanded_key[16*16];
uint8_t ALIGN16 expanded_key_dec[16*16];
+ uint8_t iv[16];
enc_func enc;
enc_func dec;
size_t keysize;
ctx->enc = iEnc256_CBC;
ctx->dec = iDec256_CBC;
}
+ else
+ return gnutls_assert_val(GNUTLS_E_INVALID_REQUEST);
ctx->keysize = keysize;
struct aes_ctx *ctx = _ctx;
memcpy (ctx->iv, iv, 16);
-
return 0;
}
{
struct aes_ctx *ctx = _ctx;
sAesData aesData;
-
+
+ aesData.iv = ctx->iv;
aesData.in_block = (void*)plain;
aesData.out_block = encr;
aesData.expanded_key = ctx->expanded_key;
- aesData.num_blocks = length % 16;
+ aesData.num_blocks = (plainsize + 1) / 16;
ctx->enc(&aesData);
struct aes_ctx *ctx = _ctx;
sAesData aesData;
+ aesData.iv = ctx->iv;
aesData.in_block = (void*)encr;
aesData.out_block = plain;
- aesData.expanded_key = ctx->expanded_key;
- aesData.num_blocks = length % 16;
+ aesData.expanded_key = ctx->expanded_key_dec;
+ aesData.num_blocks = (encrsize + 1) / 16;
ctx->dec(&aesData);
+++ /dev/null
-[bits 64]\r
-[CPU intelnop]\r
-\r
-; Copyright (c) 2010, Intel Corporation\r
-; All rights reserved.\r
-; \r
-; Redistribution and use in source and binary forms, with or without \r
-; modification, are permitted provided that the following conditions are met:\r
-; \r
-; * Redistributions of source code must retain the above copyright notice, \r
-; this list of conditions and the following disclaimer.\r
-; * Redistributions in binary form must reproduce the above copyright notice, \r
-; this list of conditions and the following disclaimer in the documentation \r
-; and/or other materials provided with the distribution.\r
-; * Neither the name of Intel Corporation nor the names of its contributors \r
-; may be used to endorse or promote products derived from this software \r
-; without specific prior written permission.\r
-; \r
-; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND \r
-; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED \r
-; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. \r
-; IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, \r
-; INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, \r
-; BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, \r
-; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF \r
-; LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE \r
-; OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF \r
-; ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
-\r
-align 16\r
-global do_rdtsc\r
-do_rdtsc:\r
-\r
- rdtsc\r
- shl rdx, 32\r
- or rax, rdx\r
- ret 0\r
+++ /dev/null
-[bits 32]\r
-[CPU intelnop]\r
-\r
-; Copyright (c) 2010, Intel Corporation\r
-; All rights reserved.\r
-; \r
-; Redistribution and use in source and binary forms, with or without \r
-; modification, are permitted provided that the following conditions are met:\r
-; \r
-; * Redistributions of source code must retain the above copyright notice, \r
-; this list of conditions and the following disclaimer.\r
-; * Redistributions in binary form must reproduce the above copyright notice, \r
-; this list of conditions and the following disclaimer in the documentation \r
-; and/or other materials provided with the distribution.\r
-; * Neither the name of Intel Corporation nor the names of its contributors \r
-; may be used to endorse or promote products derived from this software \r
-; without specific prior written permission.\r
-; \r
-; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND \r
-; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED \r
-; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. \r
-; IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, \r
-; INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, \r
-; BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, \r
-; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF \r
-; LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE \r
-; OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF \r
-; ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
-\r
-align 16\r
-global _do_rdtsc\r
-_do_rdtsc:\r
-\r
- rdtsc\r
- ret\r
fprintf(stdout, "Tests on AES Encryption: ");
for (i = 0; i < sizeof(aes_vectors) / sizeof(aes_vectors[0]); i++) {
memset(_iv, 0, sizeof(_iv));
+ memset(tmp, 0, sizeof(tmp));
key.data = (void*)aes_vectors[i].key;
key.size = 16;
for (i = 0; i < sizeof(aes_vectors) / sizeof(aes_vectors[0]); i++) {
memset(_iv, 0, sizeof(_iv));
+ memset(tmp, 0x33, sizeof(tmp));
key.data = (void*)aes_vectors[i].key;
key.size = 16;
int main(int argc, char** argv)
{
+ gnutls_global_init();
+
if (test_aes())
return 1;
if (test_hash())
return 1;
+ gnutls_global_deinit();
return 0;
}