Add AES-NI optimized code derived from latest OpenSSL upstream.
Add AES instruction set detection. Add missing license headers to a few files.
This commit is contained in:
parent
532cd2a941
commit
72b23dac1a
10 changed files with 2696 additions and 9 deletions
|
@ -35,8 +35,8 @@ CRYPTO_SRCS = crypto/aes/crypto_aes.c crypto/scrypt/crypto_scrypt-nosse.c \
|
||||||
CRYPTO_HDRS = crypto/crypto_utils.h crypto/scrypt/crypto_scrypt.h \
|
CRYPTO_HDRS = crypto/crypto_utils.h crypto/scrypt/crypto_scrypt.h \
|
||||||
crypto/scrypt/sha256.h crypto/scrypt/crypto_aesctr.h crypto/aes/crypto_aes.h \
|
crypto/scrypt/sha256.h crypto/scrypt/crypto_aesctr.h crypto/aes/crypto_aes.h \
|
||||||
crypto/sha2_utils.h crypto/sha3_utils.h $(MAINHDRS)
|
crypto/sha2_utils.h crypto/sha3_utils.h $(MAINHDRS)
|
||||||
CRYPTO_ASM_SRCS = crypto/aes/vpaes-x86_64.s
|
CRYPTO_ASM_SRCS = crypto/aes/vpaes-x86_64.s crypto/aes/aesni-x86_64.s
|
||||||
CRYPTO_ASM_OBJS = crypto/aes/vpaes-x86_64.o
|
CRYPTO_ASM_OBJS = crypto/aes/vpaes-x86_64.o crypto/aes/aesni-x86_64.o
|
||||||
CRYPTO_ASM_HDRS = crypto/aes/crypto_aes.h
|
CRYPTO_ASM_HDRS = crypto/aes/crypto_aes.h
|
||||||
CRYPTO_COMPAT_SRCS = crypto/old/sha2_utils_old.c crypto/old/sha3_utils_old.c
|
CRYPTO_COMPAT_SRCS = crypto/old/sha2_utils_old.c crypto/old/sha3_utils_old.c
|
||||||
CRYPTO_COMPAT_HDRS = crypto/old/sha2_utils_old.h crypto/old/sha3_utils_old.h
|
CRYPTO_COMPAT_HDRS = crypto/old/sha2_utils_old.h crypto/old/sha3_utils_old.h
|
||||||
|
|
2535
crypto/aes/aesni-x86_64.s
Normal file
2535
crypto/aes/aesni-x86_64.s
Normal file
File diff suppressed because it is too large
Load diff
|
@ -67,6 +67,8 @@
|
||||||
extern uint64_t lzma_crc64(const uint8_t *buf, size_t size, uint64_t crc);
|
extern uint64_t lzma_crc64(const uint8_t *buf, size_t size, uint64_t crc);
|
||||||
extern int vpaes_set_encrypt_key(const unsigned char *userKey, int bits, AES_KEY *key);
|
extern int vpaes_set_encrypt_key(const unsigned char *userKey, int bits, AES_KEY *key);
|
||||||
extern void vpaes_encrypt(const unsigned char *in, unsigned char *out, const AES_KEY *key);
|
extern void vpaes_encrypt(const unsigned char *in, unsigned char *out, const AES_KEY *key);
|
||||||
|
extern int aesni_set_encrypt_key(const unsigned char *userKey, int bits, AES_KEY *key);
|
||||||
|
extern void aesni_encrypt(const unsigned char *in, unsigned char *out, const AES_KEY *key);
|
||||||
|
|
||||||
setkey_func_ptr enc_setkey;
|
setkey_func_ptr enc_setkey;
|
||||||
encrypt_func_ptr enc_encrypt;
|
encrypt_func_ptr enc_encrypt;
|
||||||
|
@ -78,7 +80,11 @@ aes_module_init(processor_info_t *pc)
|
||||||
enc_encrypt = AES_encrypt;
|
enc_encrypt = AES_encrypt;
|
||||||
|
|
||||||
if (pc->proc_type == PROC_X64_INTEL || pc->proc_type == PROC_X64_AMD) {
|
if (pc->proc_type == PROC_X64_INTEL || pc->proc_type == PROC_X64_AMD) {
|
||||||
if (pc->sse_level >= 3 && pc->sse_sub_level >= 1) {
|
if (pc->aes_avail) {
|
||||||
|
enc_setkey = aesni_set_encrypt_key;
|
||||||
|
enc_encrypt = aesni_encrypt;
|
||||||
|
|
||||||
|
} else if (pc->sse_level >= 3 && pc->sse_sub_level >= 1) {
|
||||||
enc_setkey = vpaes_set_encrypt_key;
|
enc_setkey = vpaes_set_encrypt_key;
|
||||||
enc_encrypt = vpaes_encrypt;
|
enc_encrypt = vpaes_encrypt;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,23 @@
|
||||||
|
/*
|
||||||
|
* This file is a part of Pcompress, a chunked parallel multi-
|
||||||
|
* algorithm lossless compression and decompression program.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2012 Moinak Ghosh. All rights reserved.
|
||||||
|
* Use is subject to license terms.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* moinakg@belenix.org, http://moinakg.wordpress.com/
|
||||||
|
*/
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright 2007-2009 Colin Percival
|
* Copyright 2007-2009 Colin Percival
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
|
|
|
@ -1,3 +1,23 @@
|
||||||
|
/*
|
||||||
|
* This file is a part of Pcompress, a chunked parallel multi-
|
||||||
|
* algorithm lossless compression and decompression program.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2012 Moinak Ghosh. All rights reserved.
|
||||||
|
* Use is subject to license terms.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* moinakg@belenix.org, http://moinakg.wordpress.com/
|
||||||
|
*/
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright 2009 Colin Percival
|
* Copyright 2009 Colin Percival
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
|
|
|
@ -1,3 +1,23 @@
|
||||||
|
/*
|
||||||
|
* This file is a part of Pcompress, a chunked parallel multi-
|
||||||
|
* algorithm lossless compression and decompression program.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2012 Moinak Ghosh. All rights reserved.
|
||||||
|
* Use is subject to license terms.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* moinakg@belenix.org, http://moinakg.wordpress.com/
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2008 Veselin Georgiev,
|
* Copyright 2008 Veselin Georgiev,
|
||||||
* anrieffNOSPAM @ mgail_DOT.com (convert to gmail)
|
* anrieffNOSPAM @ mgail_DOT.com (convert to gmail)
|
||||||
|
@ -36,6 +56,7 @@
|
||||||
#define SSSE3_FLAG 0x200
|
#define SSSE3_FLAG 0x200
|
||||||
#define AVX_FLAG 0x10000000
|
#define AVX_FLAG 0x10000000
|
||||||
#define XOP_FLAG 0x800
|
#define XOP_FLAG 0x800
|
||||||
|
#define AES_FLAG 0x2000000
|
||||||
|
|
||||||
void
|
void
|
||||||
exec_cpuid(uint32_t *regs)
|
exec_cpuid(uint32_t *regs)
|
||||||
|
@ -150,6 +171,10 @@ cpuid_basic_identify(processor_info_t *pc)
|
||||||
pc->avx_level = 1;
|
pc->avx_level = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (raw.basic_cpuid[1][2] & AES_FLAG) {
|
||||||
|
pc->aes_avail = 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (raw.ext_cpuid[1][2] & XOP_FLAG) {
|
if (raw.ext_cpuid[1][2] & XOP_FLAG) {
|
||||||
pc->xop_avail = 1;
|
pc->xop_avail = 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,23 @@
|
||||||
|
/*
|
||||||
|
* This file is a part of Pcompress, a chunked parallel multi-
|
||||||
|
* algorithm lossless compression and decompression program.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2012 Moinak Ghosh. All rights reserved.
|
||||||
|
* Use is subject to license terms.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* moinakg@belenix.org, http://moinakg.wordpress.com/
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2008 Veselin Georgiev,
|
* Copyright 2008 Veselin Georgiev,
|
||||||
* anrieffNOSPAM @ mgail_DOT.com (convert to gmail)
|
* anrieffNOSPAM @ mgail_DOT.com (convert to gmail)
|
||||||
|
@ -46,6 +66,7 @@ typedef struct {
|
||||||
int sse_sub_level;
|
int sse_sub_level;
|
||||||
int avx_level;
|
int avx_level;
|
||||||
int xop_avail;
|
int xop_avail;
|
||||||
|
int aes_avail;
|
||||||
proc_type_t proc_type;
|
proc_type_t proc_type;
|
||||||
} processor_info_t;
|
} processor_info_t;
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,23 @@
|
||||||
|
/*
|
||||||
|
* This file is a part of Pcompress, a chunked parallel multi-
|
||||||
|
* algorithm lossless compression and decompression program.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2012 Moinak Ghosh. All rights reserved.
|
||||||
|
* Use is subject to license terms.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* moinakg@belenix.org, http://moinakg.wordpress.com/
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Functions for a rudimentary fast min-heap implementation.
|
* Functions for a rudimentary fast min-heap implementation.
|
||||||
* Derived from Python's _heapqmodule.c by way of drastic simplification
|
* Derived from Python's _heapqmodule.c by way of drastic simplification
|
||||||
|
|
|
@ -1,3 +1,23 @@
|
||||||
|
/*
|
||||||
|
* This file is a part of Pcompress, a chunked parallel multi-
|
||||||
|
* algorithm lossless compression and decompression program.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2012 Moinak Ghosh. All rights reserved.
|
||||||
|
* Use is subject to license terms.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* moinakg@belenix.org, http://moinakg.wordpress.com/
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef __HEAPQ_H_
|
#ifndef __HEAPQ_H_
|
||||||
|
|
||||||
#define __TYPE int64_t
|
#define __TYPE int64_t
|
||||||
|
|
|
@ -1,3 +1,23 @@
|
||||||
|
/*
|
||||||
|
* This file is a part of Pcompress, a chunked parallel multi-
|
||||||
|
* algorithm lossless compression and decompression program.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2012 Moinak Ghosh. All rights reserved.
|
||||||
|
* Use is subject to license terms.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* moinakg@belenix.org, http://moinakg.wordpress.com/
|
||||||
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <utils.h>
|
#include <utils.h>
|
||||||
#include <cpuid.h>
|
#include <cpuid.h>
|
||||||
|
|
Loading…
Reference in a new issue