components/openssl/openssl-1.0.1/engines/t4/eng_t4_des.c
branchs11-update
changeset 2593 b92e6df5eaf0
parent 603 1b966e9a6b03
equal deleted inserted replaced
2592:a7d8d41eeab2 2593:b92e6df5eaf0
       
     1 /*
       
     2  * This product includes cryptographic software developed by the OpenSSL
       
     3  * Project for use in the OpenSSL Toolkit (http://www.openssl.org/).
       
     4  */
       
     5 
       
     6 /*
       
     7  * ====================================================================
       
     8  * Copyright (c) 1998-2011 The OpenSSL Project.  All rights reserved.
       
     9  *
       
    10  * Redistribution and use in source and binary forms, with or without
       
    11  * modification, are permitted provided that the following conditions
       
    12  * are met:
       
    13  *
       
    14  * 1. Redistributions of source code must retain the above copyright
       
    15  *    notice, this list of conditions and the following disclaimer.
       
    16  *
       
    17  * 2. Redistributions in binary form must reproduce the above copyright
       
    18  *    notice, this list of conditions and the following disclaimer in
       
    19  *    the documentation and/or other materials provided with the
       
    20  *    distribution.
       
    21  *
       
    22  * 3. All advertising materials mentioning features or use of this
       
    23  *    software must display the following acknowledgment:
       
    24  *    "This product includes software developed by the OpenSSL Project
       
    25  *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
       
    26  *
       
    27  * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
       
    28  *    endorse or promote products derived from this software without
       
    29  *    prior written permission. For written permission, please contact
       
    30  *    [email protected].
       
    31  *
       
    32  * 5. Products derived from this software may not be called "OpenSSL"
       
    33  *    nor may "OpenSSL" appear in their names without prior written
       
    34  *    permission of the OpenSSL Project.
       
    35  *
       
    36  * 6. Redistributions of any form whatsoever must retain the following
       
    37  *    acknowledgment:
       
    38  *    "This product includes software developed by the OpenSSL Project
       
    39  *    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
       
    40  *
       
    41  * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
       
    42  * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
       
    43  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
       
    44  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
       
    45  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
       
    46  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
       
    47  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
       
    48  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
       
    49  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
       
    50  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
       
    51  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
       
    52  * OF THE POSSIBILITY OF SUCH DAMAGE.
       
    53  * ====================================================================
       
    54  */
       
    55 
       
    56 /*
       
    57  * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
       
    58  */
       
    59 
       
    60 /*
       
    61  * This engine supports SPARC microprocessors that provide DES and other
       
    62  * cipher and hash instructions, such as the T4 microprocessor.
       
    63  *
       
    64  * This file implements the DES and DES3 cipher operations.
       
    65  */
       
    66 
       
    67 #include <openssl/opensslconf.h>
       
    68 
       
    69 #if !defined(OPENSSL_NO_HW) && !defined(OPENSSL_NO_HW_DES_T4) && \
       
    70 	!defined(OPENSSL_NO_DES)
       
    71 #include <sys/types.h>
       
    72 #include <stdlib.h>
       
    73 #include <string.h>
       
    74 #include <errno.h>
       
    75 #include <openssl/engine.h>
       
    76 #include "eng_t4_des_asm.h"
       
    77 
       
    78 #include "eng_t4_err.c"
       
    79 
       
    80 /* Index for the supported DES ciphers */
       
    81 typedef enum {
       
    82 	T4_DES_CBC,
       
    83 	T4_DES3_CBC,
       
    84 	T4_DES_ECB,
       
    85 	T4_DES3_ECB,
       
    86 	T4_DES_MAX
       
    87 } t4_des_cipher_id;
       
    88 
       
    89 /* From Solaris file usr/src/common/crypto/des/des_impl.c */
       
    90 typedef struct {
       
    91 	uint64_t ksch_encrypt[16];
       
    92 	uint64_t ksch_decrypt[16];
       
    93 } t4_keysched_t;
       
    94 
       
    95 typedef struct {
       
    96 	uint64_t ksch_encrypt[16 * 3];
       
    97 	uint64_t ksch_decrypt[16 * 3];
       
    98 } t4_keysched3_t;
       
    99 
       
   100 /* T4 cipher context; must be 8-byte aligned (last field must be uint64_t)  */
       
   101 typedef struct t4_des_cipher_ctx {
       
   102 	t4_des_cipher_id	index;
       
   103 	uint64_t		*iv;
       
   104 	uint64_t		aligned_iv_buffer; /* use if IV unaligned */
       
   105 	union {
       
   106 		t4_keysched_t	des;
       
   107 		t4_keysched3_t	des3;
       
   108 	} ks;
       
   109 } t4_des_cipher_ctx_t;
       
   110 
       
   111 typedef struct t4_cipher {
       
   112 	t4_des_cipher_id	id;
       
   113 	int			nid;
       
   114 	int			iv_len;
       
   115 	int			min_key_len;
       
   116 	int			max_key_len;
       
   117 } t4_des_cipher_t;
       
   118 
       
   119 
       
   120 #if (defined(sun4v) || defined(__sparcv9) || defined(__sparcv8plus) || \
       
   121 	defined(__sparcv8)) && !defined(OPENSSL_NO_ASM)
       
   122 #define	COMPILE_HW_T4
       
   123 #endif
       
   124 
       
   125 #ifdef	COMPILE_HW_T4
       
   126 static t4_des_cipher_id get_des_cipher_index_by_nid(int nid);
       
   127 #pragma inline(get_des_cipher_index_by_nid)
       
   128 
       
   129 
       
   130 /*
       
   131  * Cipher Table for all supported symmetric ciphers.
       
   132  * Must be in same order as t4_des_cipher_id.
       
   133  */
       
   134 static t4_des_cipher_t t4_des_cipher_table[] = {
       
   135 	/* ID			NID		IV	min-key	max-key */
       
   136 	{T4_DES_CBC,	NID_des_cbc,		8,	8,	8},
       
   137 	{T4_DES3_CBC,	NID_des_ede3_cbc,	8,	24,	24},
       
   138 	{T4_DES_ECB,	NID_des_ecb,		0,	8,	8},
       
   139 	{T4_DES3_ECB,	NID_des_ede3_ecb,	0,	24,	24},
       
   140 };
       
   141 
       
   142 
       
   143 /* Formal declaration for functions in EVP_CIPHER structure */
       
   144 static int t4_cipher_init_des(EVP_CIPHER_CTX *ctx, const unsigned char *key,
       
   145     const unsigned char *iv, int enc);
       
   146 
       
   147 static int t4_cipher_do_des_cbc(EVP_CIPHER_CTX *ctx, unsigned char *out,
       
   148     const unsigned char *in, size_t inl);
       
   149 static int t4_cipher_do_des3_cbc(EVP_CIPHER_CTX *ctx, unsigned char *out,
       
   150     const unsigned char *in, size_t inl);
       
   151 static int t4_cipher_do_des_ecb(EVP_CIPHER_CTX *ctx, unsigned char *out,
       
   152     const unsigned char *in, size_t inl);
       
   153 static int t4_cipher_do_des3_ecb(EVP_CIPHER_CTX *ctx, unsigned char *out,
       
   154     const unsigned char *in, size_t inl);
       
   155 
       
   156 
       
   157 /*
       
   158  * Cipher Algorithms
       
   159  *
       
   160  * OpenSSL's libcrypto EVP stuff. This is how this engine gets wired to EVP.
       
   161  * EVP_CIPHER is defined in evp.h.  To maintain binary compatibility the
       
   162  * definition cannot be modified.
       
   163  * Stuff specific to the t4 engine is kept in t4_des_cipher_ctx_t, which is
       
   164  * pointed to by cipher_data or md_data
       
   165  *
       
   166  * Fields: nid, block_size, key_len, iv_len, flags,
       
   167  *	init(), do_cipher(), cleanup(),
       
   168  *	ctx_size,
       
   169  *	set_asn1_parameters(), get_asn1_parameters(), ctrl(), app_data
       
   170  */
       
   171 
       
   172 const EVP_CIPHER t4_des_cbc = {
       
   173 	NID_des_cbc,
       
   174 	8, 8, 8,
       
   175 	EVP_CIPH_CBC_MODE,
       
   176 	t4_cipher_init_des, t4_cipher_do_des_cbc, NULL,
       
   177 	sizeof (t4_des_cipher_ctx_t),
       
   178 	EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv,
       
   179 	NULL, NULL
       
   180 };
       
   181 const EVP_CIPHER t4_des3_cbc = {
       
   182 	NID_des_ede3_cbc,
       
   183 	8, 24, 8,
       
   184 	EVP_CIPH_CBC_MODE,
       
   185 	t4_cipher_init_des, t4_cipher_do_des3_cbc, NULL,
       
   186 	sizeof (t4_des_cipher_ctx_t),
       
   187 	EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv,
       
   188 	NULL, NULL
       
   189 };
       
   190 
       
   191 /*
       
   192  * ECB modes don't use an Initial Vector, so that's why set_asn1_parameters,
       
   193  * get_asn1_parameters, and cleanup fields are set to NULL.
       
   194  */
       
   195 const EVP_CIPHER t4_des_ecb = {
       
   196 	NID_des_ecb,
       
   197 	8, 8, 8,
       
   198 	EVP_CIPH_ECB_MODE,
       
   199 	t4_cipher_init_des, t4_cipher_do_des_ecb, NULL,
       
   200 	sizeof (t4_des_cipher_ctx_t),
       
   201 	NULL, NULL, NULL, NULL
       
   202 };
       
   203 const EVP_CIPHER t4_des3_ecb = {
       
   204 	NID_des_ede3_ecb,
       
   205 	8, 24, 8,
       
   206 	EVP_CIPH_ECB_MODE,
       
   207 	t4_cipher_init_des, t4_cipher_do_des3_ecb, NULL,
       
   208 	sizeof (t4_des_cipher_ctx_t),
       
   209 	NULL, NULL, NULL, NULL
       
   210 };
       
   211 
       
   212 
       
   213 /*
       
   214  * DES Cipher functions
       
   215  */
       
   216 
       
   217 /* Called by t4_cipher_init_des() */
       
   218 static t4_des_cipher_id
       
   219 get_des_cipher_index_by_nid(int nid)
       
   220 {
       
   221 	t4_des_cipher_id i;
       
   222 
       
   223 	for (i = (t4_des_cipher_id)0; i < T4_DES_MAX; ++i)
       
   224 		if (t4_des_cipher_table[i].nid == nid)
       
   225 			return (i);
       
   226 	return (T4_DES_MAX);
       
   227 }
       
   228 
       
   229 
       
   230 /*
       
   231  * Initialize encryption and decryption key schedules for DES or DES3.
       
   232  * Called by t4_cipher_init_des().
       
   233  *
       
   234  * Modified from Solaris DES function des_init_keysched().
       
   235  */
       
   236 static int
       
   237 t4_des_init_keysched(const unsigned char *cipherKey,
       
   238     unsigned int keysize, void *ks)
       
   239 {
       
   240 	uint64_t *encryption_ks, *decryption_ks;
       
   241 	uint64_t keysched[16 * 3];	/* 128 or 384 bytes for DES or DES3 */
       
   242 	uint64_t key_uint64[3];		/* 8 or 24 bytes for DES or DES3 */
       
   243 	uint64_t *aligned_key;
       
   244 	uint64_t tmp;
       
   245 	uint_t	i, j;
       
   246 
       
   247 	switch (keysize) {
       
   248 	case 8: /* DES */
       
   249 		encryption_ks = ((t4_keysched_t *)ks)->ksch_encrypt;
       
   250 		decryption_ks = ((t4_keysched_t *)ks)->ksch_decrypt;
       
   251 		break;
       
   252 	case 24: /* DES3 */
       
   253 		encryption_ks = ((t4_keysched3_t *)ks)->ksch_encrypt;
       
   254 		decryption_ks = ((t4_keysched3_t *)ks)->ksch_decrypt;
       
   255 		break;
       
   256 	default:
       
   257 		T4err(T4_F_CIPHER_INIT_DES, T4_R_CIPHER_KEY);
       
   258 		return (0);
       
   259 	}
       
   260 
       
   261 	/* Align key, if needed */
       
   262 	if (((unsigned long)cipherKey & 0x7) == 0) { /* aligned */
       
   263 		/* LINTED: pointer alignment */
       
   264 		aligned_key = (uint64_t *)cipherKey;
       
   265 	} else { /* unaligned--copy byte-by-byte */
       
   266 		for (i = 0, j = 0; j < keysize; ++i, j += 8) {
       
   267 			key_uint64[i] = (((uint64_t)cipherKey[j] << 56) |
       
   268 			    ((uint64_t)cipherKey[j + 1] << 48) |
       
   269 			    ((uint64_t)cipherKey[j + 2] << 40) |
       
   270 			    ((uint64_t)cipherKey[j + 3] << 32) |
       
   271 			    ((uint64_t)cipherKey[j + 4] << 24) |
       
   272 			    ((uint64_t)cipherKey[j + 5] << 16) |
       
   273 			    ((uint64_t)cipherKey[j + 6] << 8) |
       
   274 			    (uint64_t)cipherKey[j + 7]);
       
   275 		}
       
   276 		aligned_key = key_uint64;
       
   277 	}
       
   278 
       
   279 	/* Expand key schedule */
       
   280 	switch (keysize) {
       
   281 	case 8: /* DES */
       
   282 		t4_des_expand(keysched, (const uint32_t *)aligned_key);
       
   283 		break;
       
   284 
       
   285 	case 24: /* DES3 */
       
   286 		t4_des_expand(keysched, (const uint32_t *)aligned_key);
       
   287 		t4_des_expand(keysched + 16,
       
   288 		    (const uint32_t *)&aligned_key[1]);
       
   289 		for (i = 0; i < 8; ++i) {
       
   290 			tmp = keysched[16 + i];
       
   291 			keysched[16 + i] = keysched[31 - i];
       
   292 			keysched[31 - i] = tmp;
       
   293 		}
       
   294 		t4_des_expand(keysched + 32,
       
   295 		    (const uint32_t *)&aligned_key[2]);
       
   296 		break;
       
   297 
       
   298 	default:
       
   299 		T4err(T4_F_CIPHER_INIT_DES, T4_R_CIPHER_KEY);
       
   300 		return (0);
       
   301 	}
       
   302 
       
   303 	/* Save encryption key schedule */
       
   304 	memcpy(encryption_ks, keysched, keysize * 16);
       
   305 
       
   306 	/* Reverse key schedule */
       
   307 	for (i = 0; i < keysize; ++i) {
       
   308 		tmp = keysched[i];
       
   309 		keysched[i] = keysched[2 * keysize - 1 - i];
       
   310 		keysched[2 * keysize -1 -i] = tmp;
       
   311 	}
       
   312 
       
   313 	/* Save decryption key schedule */
       
   314 	memcpy(decryption_ks, keysched, keysize * 16);
       
   315 
       
   316 	return (1);
       
   317 }
       
   318 
       
   319 
       
   320 /* ARGSUSED2 */
       
   321 static int
       
   322 t4_cipher_init_des(EVP_CIPHER_CTX *ctx, const unsigned char *key,
       
   323     const unsigned char *iv, int enc)
       
   324 {
       
   325 	t4_des_cipher_ctx_t	*tctx = ctx->cipher_data;
       
   326 	uint64_t		*encryption_ks, *decryption_ks;
       
   327 	t4_des_cipher_t		*t4_cipher;
       
   328 	t4_des_cipher_id	index;
       
   329 	unsigned int		key_len = ctx->key_len;
       
   330 	uint64_t		aligned_key_buffer[3]; /* 8 or 24 bytes long */
       
   331 	uint64_t		*aligned_key;
       
   332 
       
   333 	if (key == NULL) {
       
   334 		T4err(T4_F_CIPHER_INIT_DES, T4_R_CIPHER_KEY);
       
   335 		return (0);
       
   336 	}
       
   337 
       
   338 	/* Get the cipher entry index in t4_des_cipher_table from nid */
       
   339 	index = get_des_cipher_index_by_nid(ctx->cipher->nid);
       
   340 	if (index >= T4_DES_MAX) {
       
   341 		T4err(T4_F_CIPHER_INIT_DES, T4_R_CIPHER_NID);
       
   342 		return (0); /* Error */
       
   343 	}
       
   344 	t4_cipher = &t4_des_cipher_table[index];
       
   345 
       
   346 	/* Check key size and iv size */
       
   347 	if (ctx->cipher->iv_len < t4_cipher->iv_len) {
       
   348 		T4err(T4_F_CIPHER_INIT_DES, T4_R_IV_LEN_INCORRECT);
       
   349 		return (0); /* Error */
       
   350 	}
       
   351 	if ((key_len < t4_cipher->min_key_len) ||
       
   352 	    (key_len > t4_cipher->max_key_len)) {
       
   353 		T4err(T4_F_CIPHER_INIT_DES, T4_R_KEY_LEN_INCORRECT);
       
   354 		return (0); /* Error */
       
   355 	}
       
   356 
       
   357 	/* Expand key schedule */
       
   358 	if (t4_des_init_keysched(key, key_len, &tctx->ks) == 0)
       
   359 		return (0); /* Error */
       
   360 
       
   361 	/* Save index to cipher */
       
   362 	tctx->index = index;
       
   363 
       
   364 	/* Align IV, if needed */
       
   365 	if (t4_cipher->iv_len <= 0) { /* no IV (such as with ECB mode) */
       
   366 		tctx->iv = NULL;
       
   367 	} else if (((unsigned long)ctx->iv & 0x7) == 0) { /* already aligned */
       
   368 		tctx->iv = (uint64_t *)ctx->iv;
       
   369 	} else {
       
   370 		/* IV is not 8 byte aligned */
       
   371 		(void) memcpy(&tctx->aligned_iv_buffer, ctx->iv,
       
   372 		    ctx->cipher->iv_len);
       
   373 		tctx->iv = &tctx->aligned_iv_buffer;
       
   374 #ifdef	DEBUG_T4
       
   375 		(void) fprintf(stderr,
       
   376 		    "t4_cipher_init_des: IV is not 8 byte aligned\n");
       
   377 		(void) fprintf(stderr,
       
   378 		    "t4_cipher_init_des: ctx->cipher->iv_len =%d\n",
       
   379 		    ctx->cipher->iv_len);
       
   380 		(void) fprintf(stderr, "t4_cipher_init_des: after "
       
   381 		    "re-alignment, tctx->iv = %p\n", (void *)tctx->iv);
       
   382 #endif	/* DEBUG_T4 */
       
   383 	}
       
   384 
       
   385 	return (1);
       
   386 }
       
   387 
       
   388 
       
   389 /*
       
   390  * ENCRYPT_UPDATE or DECRYPT_UPDATE
       
   391  */
       
   392 #define	T4_CIPHER_DO_DES(t4_cipher_do_des, t4_des_load_keys,		\
       
   393     t4_des_encrypt, t4_des_decrypt, ksched_encrypt, ksched_decrypt, iv)	\
       
   394 static int								\
       
   395 t4_cipher_do_des(EVP_CIPHER_CTX *ctx, unsigned char *out,		\
       
   396     const unsigned char *in, size_t inl)				\
       
   397 {									\
       
   398 	t4_des_cipher_ctx_t	*tctx = ctx->cipher_data;		\
       
   399 	unsigned long	outl = inl;					\
       
   400 	unsigned char	*bufin_alloc = NULL, *bufout_alloc = NULL;	\
       
   401 	unsigned char	*bufin, *bufout;				\
       
   402 									\
       
   403 	/* "in" and "out" must be 8 byte aligned */			\
       
   404 	if (((unsigned long)in & 0x7) == 0) { /* already aligned */	\
       
   405 		bufin = (unsigned char *)in;				\
       
   406 	} else { /* "in" is not 8 byte aligned */			\
       
   407 		if (((unsigned long)out & 0x7) == 0) { /* aligned */	\
       
   408 			/* use output buffer for input */		\
       
   409 			bufin = out;					\
       
   410 		} else {						\
       
   411 			bufin = bufin_alloc = OPENSSL_malloc(inl);	\
       
   412 			if (bufin_alloc == NULL)			\
       
   413 				return (0); /* error */			\
       
   414 		}							\
       
   415 		(void) memcpy(bufin, in, inl);				\
       
   416 	}								\
       
   417 									\
       
   418 	/* Data length must be an even multiple of block size. */	\
       
   419 	if ((inl & 0x7) != 0) {						\
       
   420 		OPENSSL_free(bufout_alloc);				\
       
   421 		OPENSSL_free(bufin_alloc);				\
       
   422 		T4err(T4_F_CIPHER_DO_DES, T4_R_NOT_BLOCKSIZE_LENGTH);	\
       
   423 		return (0);						\
       
   424 	}								\
       
   425 									\
       
   426 	if (((unsigned long)out & 0x7) == 0) { /* already aligned */	\
       
   427 		bufout = out;						\
       
   428 	} else { /* "out" is not 8 byte aligned */			\
       
   429 		if (bufin_alloc != NULL) {				\
       
   430 			/* use allocated input buffer for output */	\
       
   431 			bufout = bufin_alloc;				\
       
   432 		} else {						\
       
   433 			bufout = bufout_alloc = OPENSSL_malloc(outl);	\
       
   434 			if (bufout_alloc == NULL) {			\
       
   435 				OPENSSL_free(bufin_alloc);		\
       
   436 				return (0); /* error */			\
       
   437 			}						\
       
   438 		}							\
       
   439 	}								\
       
   440 									\
       
   441 	if (ctx->encrypt) {						\
       
   442 		uint64_t	*ksch_encrypt = ksched_encrypt;		\
       
   443 		t4_des_load_keys(ksch_encrypt);				\
       
   444 		t4_des_encrypt(ksch_encrypt, (uint64_t *)bufin,		\
       
   445 		    (uint64_t *)bufout, (size_t)inl, iv);		\
       
   446 	} else { /* decrypt */						\
       
   447 		uint64_t	*ksch_decrypt = ksched_decrypt;		\
       
   448 		t4_des_load_keys(ksch_decrypt);				\
       
   449 		t4_des_decrypt(ksch_decrypt, (uint64_t *)bufin,		\
       
   450 		    (uint64_t *)bufout, (size_t)inl, iv);		\
       
   451 	}								\
       
   452 									\
       
   453 	/* Cleanup */							\
       
   454 	if (bufin_alloc != NULL) {					\
       
   455 		if (bufout == bufin_alloc)				\
       
   456 			(void) memcpy(out, bufout, outl);		\
       
   457 		OPENSSL_free(bufin_alloc);				\
       
   458 	}								\
       
   459 	if (bufout_alloc != NULL) {					\
       
   460 		(void) memcpy(out, bufout_alloc, outl);			\
       
   461 		OPENSSL_free(bufout_alloc);				\
       
   462 	}								\
       
   463 									\
       
   464 	return (1);							\
       
   465 }
       
   466 
       
   467 
       
   468 /* DES CBC mode. */
       
   469 T4_CIPHER_DO_DES(t4_cipher_do_des_cbc, t4_des_load_keys,
       
   470 	t4_des_cbc_encrypt, t4_des_cbc_decrypt,
       
   471 	tctx->ks.des.ksch_encrypt, tctx->ks.des.ksch_decrypt, tctx->iv)
       
   472 T4_CIPHER_DO_DES(t4_cipher_do_des3_cbc, t4_des3_load_keys,
       
   473 	t4_des3_cbc_encrypt, t4_des3_cbc_decrypt,
       
   474 	tctx->ks.des3.ksch_encrypt, tctx->ks.des3.ksch_decrypt, tctx->iv)
       
   475 
       
   476 /* DES ECB mode. */
       
   477 T4_CIPHER_DO_DES(t4_cipher_do_des_ecb, t4_des_load_keys,
       
   478 	t4_des_ecb_crypt, t4_des_ecb_crypt,
       
   479 	tctx->ks.des.ksch_encrypt, tctx->ks.des.ksch_decrypt, NULL)
       
   480 T4_CIPHER_DO_DES(t4_cipher_do_des3_ecb, t4_des3_load_keys,
       
   481 	t4_des3_ecb_crypt, t4_des3_ecb_crypt,
       
   482 	tctx->ks.des3.ksch_encrypt, tctx->ks.des3.ksch_decrypt, NULL)
       
   483 
       
   484 
       
   485 #endif	/* COMPILE_HW_T4 */
       
   486 #endif	/* !OPENSSL_NO_HW && !OPENSSL_NO_HW_DES_T4 && !OPENSSL_NO_DES */