Commit cc015c48 authored by Geoff Thorpe's avatar Geoff Thorpe
Browse files

This adds Atalla support code to the ENGINE framework. If you have an

Atalla card, you should be able to compile with the "hw-atalla" switch
with "./config" or "perl Configure", and then you can use the command-
line switch "-engine atalla" inside speed, s_cient and s_server (after
checking out note (1)).

Notes:
  (1) I've turned on native name translation when loading the shared-
      library, but this means that the Unix shared library needs to be
      libatasi.so rather than atasi.so. I got around this in my testing
      by creating a symbollic link from /usr/lib/libatasi.so to the real
      library, but something better will be needed. It also assumes in
      win32 that the DLL will be called atasi.dll - but as I don't have
      a win32/atalla environment to try I have no idea yet if this is
      the case.
  (2) Currently DSA verifies are not accelerated because I haven't yet
      got a mod_exp-based variant of BN_mod_exp2_mont() that yields
      correct results.
  (3) Currently the "init()" doesn't fail if the shared library can
      load successfully but the card is not operational. In this case,
      the ENGINE_init() call will succeed, but all RSA, DSA, DH, and
      the two BN_*** operations will fail until the ENGINE is switched
      back to something that does work. I expect to correct this next.
  (4) Although the API for the Atalla card just has the one crypto
      function suggesting an RSA private key operation - this is in
      fact just a straight mod_exp function that ignores all the RSA
      key parameters except the (private) exponent and modulus. This is
      why the only accelerator work is taking place inside the mod_exp
      function and there's no optimisation of RSA private key operations
      based on CRT etc.
parent 9a405105
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -23,9 +23,9 @@ APPS=

LIB=$(TOP)/libcrypto.a
LIBSRC= engine_err.c engine_lib.c engine_list.c engine_openssl.c \
	hw_cswift.c hw_ncipher.c
	hw_atalla.c hw_cswift.c hw_ncipher.c
LIBOBJ= engine_err.o engine_lib.o engine_list.o engine_openssl.o \
	hw_cswift.o hw_ncipher.o
	hw_atalla.o hw_cswift.o hw_ncipher.o

SRC= $(LIBSRC)

@@ -117,6 +117,16 @@ engine_openssl.o: ../../include/openssl/opensslconf.h
engine_openssl.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h
engine_openssl.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
engine_openssl.o: ../../include/openssl/stack.h ../cryptlib.h engine_int.h
hw_atalla.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
hw_atalla.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
hw_atalla.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
hw_atalla.o: ../../include/openssl/dso.h ../../include/openssl/e_os.h
hw_atalla.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h
hw_atalla.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
hw_atalla.o: ../../include/openssl/opensslconf.h
hw_atalla.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h
hw_atalla.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
hw_atalla.o: ../../include/openssl/stack.h ../cryptlib.h engine_int.h
hw_cswift.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
hw_cswift.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
hw_cswift.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
+4 −0
Original line number Diff line number Diff line
@@ -252,6 +252,10 @@ void ERR_load_ENGINE_strings(void);
/* Error codes for the ENGINE functions. */

/* Function codes. */
#define ENGINE_F_ATALLA_FINISH				 135
#define ENGINE_F_ATALLA_INIT				 136
#define ENGINE_F_ATALLA_MOD_EXP				 137
#define ENGINE_F_ATALLA_RSA_MOD_EXP			 138
#define ENGINE_F_CSWIFT_DSA_SIGN			 133
#define ENGINE_F_CSWIFT_DSA_VERIFY			 134
#define ENGINE_F_CSWIFT_FINISH				 100
+4 −0
Original line number Diff line number Diff line
@@ -66,6 +66,10 @@
#ifndef NO_ERR
static ERR_STRING_DATA ENGINE_str_functs[]=
	{
{ERR_PACK(0,ENGINE_F_ATALLA_FINISH,0),	"ATALLA_FINISH"},
{ERR_PACK(0,ENGINE_F_ATALLA_INIT,0),	"ATALLA_INIT"},
{ERR_PACK(0,ENGINE_F_ATALLA_MOD_EXP,0),	"ATALLA_MOD_EXP"},
{ERR_PACK(0,ENGINE_F_ATALLA_RSA_MOD_EXP,0),	"ATALLA_RSA_MOD_EXP"},
{ERR_PACK(0,ENGINE_F_CSWIFT_DSA_SIGN,0),	"CSWIFT_DSA_SIGN"},
{ERR_PACK(0,ENGINE_F_CSWIFT_DSA_VERIFY,0),	"CSWIFT_DSA_VERIFY"},
{ERR_PACK(0,ENGINE_F_CSWIFT_FINISH,0),	"CSWIFT_FINISH"},
+5 −0
Original line number Diff line number Diff line
@@ -133,6 +133,11 @@ ENGINE *ENGINE_cswift();
ENGINE *ENGINE_hwcrhk();
#endif /* HW_NCIPHER */

#ifdef HW_ATALLA
/* Returns a structure of atalla methods. */
ENGINE *ENGINE_atalla();
#endif /* HW_ATALLA */

#ifdef  __cplusplus
}
#endif
+4 −0
Original line number Diff line number Diff line
@@ -192,6 +192,10 @@ static int engine_internal_check(void)
#ifdef HW_NCIPHER
	if(!engine_list_add(ENGINE_hwcrhk()))
		return 0;
#endif /* HW_CSWIFT */
#ifdef HW_ATALLA
	if(!engine_list_add(ENGINE_atalla()))
		return 0;
#endif /* HW_CSWIFT */
	engine_list_flag = 1;
	return 1;
Loading