1 /*
2  * (c) 2014 Harrison Neal. Licensed under GPLv2.
3  * A set of convenience functions that return a function pointer to an
4  * appropriate AES implementation depending on your platform.
5  *
6  * NOTE: These functions are intended to be used by algorithms that
7  * continuously switch out AES keys - with each computation, state is
8  * built, used and torn down.
9  * Consider using straight OpenSSL EVP methods if your algorithm would
10  * do a lot of work with any single key.
11  */
12 
13 #include <stdio.h>
14 #include <string.h>
15 
16 #include "../aes.h"
17 
18 #if HAVE_AES_ENCRYPT || !defined(AC_BUILT)
19 #include "openssl/ossl_aes.h"
get_AES_type_string()20 const char *get_AES_type_string() { if (using_aes_asm()) return "AES-NI"; return "AES-oSSL"; }
21 #else
get_AES_type_string()22 const char *get_AES_type_string() { if (using_aes_asm()) return "AES-NI"; return "AES-JtR"; }
23 #endif
24 
25 
26 #ifdef AESNI_IN_USE
27 	#include "aesni/iaesni.h"
28 	#define FUNC(r,p) aes_fptr_##r get_##p() { return check_for_aes_instructions() ? intel_##p : openssl_##p; }
using_aes_asm()29 	int using_aes_asm() {
30 		if (check_for_aes_instructions())
31 			return 1;
32 		return 0;
33 	}
34 #else
35 	#define FUNC(r,p) aes_fptr_##r get_##p() { return openssl_##p; }
using_aes_asm()36 	int using_aes_asm() {
37 		return 0;
38 	}
39 #endif
40 
41 #include "aes_func.h"
42 
43 #undef FUNC
44