Index: hw_cryptodev.c =================================================================== RCS file: /usr/repo/src/crypto/openssl/crypto/engine/hw_cryptodev.c,v retrieving revision 1.1.1.4 diff -u -p -r1.1.1.4 hw_cryptodev.c --- hw_cryptodev.c 25 Feb 2005 05:34:58 -0000 1.1.1.4 +++ hw_cryptodev.c 17 Aug 2005 09:37:03 -0000 @@ -131,11 +131,14 @@ static struct { { CRYPTO_DES_CBC, NID_des_cbc, 8, 8, }, { CRYPTO_3DES_CBC, NID_des_ede3_cbc, 8, 24, }, { CRYPTO_AES_CBC, NID_aes_128_cbc, 16, 16, }, + { CRYPTO_AES_CBC, NID_aes_192_cbc, 16, 24, }, + { CRYPTO_AES_CBC, NID_aes_256_cbc, 16, 32, }, { CRYPTO_BLF_CBC, NID_bf_cbc, 8, 16, }, { CRYPTO_CAST_CBC, NID_cast5_cbc, 8, 16, }, { CRYPTO_SKIPJACK_CBC, NID_undef, 0, 0, }, { 0, NID_undef, 0, 0, }, }; +#define NCIPHERS (sizeof(ciphers) / sizeof(ciphers[0])) #if 0 /* UNUSED */ static struct { @@ -229,8 +232,8 @@ cryptodev_key_length_valid(int cipher, i int i; for (i = 0; ciphers[i].id; i++) - if (ciphers[i].id == cipher) - return (ciphers[i].keylen == len); + if (ciphers[i].id == cipher && ciphers[i].keylen == len) + return (1); return (0); } @@ -255,7 +258,7 @@ cipher_nid_to_cryptodev(int nid) static int get_cryptodev_ciphers(const int **cnids) { - static int nids[CRYPTO_ALGORITHM_MAX]; + static int nids[NCIPHERS]; struct session_op sess; int fd, i, count = 0; @@ -266,7 +269,7 @@ get_cryptodev_ciphers(const int **cnids) memset(&sess, 0, sizeof(sess)); sess.key = (caddr_t)"123456781234567812345678"; - for (i = 0; ciphers[i].id && count < CRYPTO_ALGORITHM_MAX; i++) { + for (i = 0; ciphers[i].id && count < NCIPHERS; i++) { if (ciphers[i].nid == NID_undef) continue; sess.cipher = ciphers[i].id; @@ -552,7 +555,7 @@ const EVP_CIPHER cryptodev_cast_cbc = { NULL }; -const EVP_CIPHER cryptodev_aes_cbc = { +const EVP_CIPHER cryptodev_aes128_cbc = { NID_aes_128_cbc, 16, 16, 16, EVP_CIPH_CBC_MODE, @@ -565,6 +568,32 @@ const EVP_CIPHER cryptodev_aes_cbc = { NULL }; +const EVP_CIPHER cryptodev_aes192_cbc = { + NID_aes_192_cbc, + 16, 24, 16, + EVP_CIPH_CBC_MODE, + cryptodev_init_key, + cryptodev_cipher, + cryptodev_cleanup, + sizeof(struct dev_crypto_state), + EVP_CIPHER_set_asn1_iv, + EVP_CIPHER_get_asn1_iv, + NULL +}; + +const EVP_CIPHER cryptodev_aes256_cbc = { + NID_aes_256_cbc, + 16, 32, 16, + EVP_CIPH_CBC_MODE, + cryptodev_init_key, + cryptodev_cipher, + cryptodev_cleanup, + sizeof(struct dev_crypto_state), + EVP_CIPHER_set_asn1_iv, + EVP_CIPHER_get_asn1_iv, + NULL +}; + /* * Registered by the ENGINE when used to find out how to deal with * a particular NID in the ENGINE. this says what we'll do at the @@ -591,7 +620,13 @@ cryptodev_engine_ciphers(ENGINE *e, cons *cipher = &cryptodev_cast_cbc; break; case NID_aes_128_cbc: - *cipher = &cryptodev_aes_cbc; + *cipher = &cryptodev_aes128_cbc; + break; + case NID_aes_192_cbc: + *cipher = &cryptodev_aes192_cbc; + break; + case NID_aes_256_cbc: + *cipher = &cryptodev_aes256_cbc; break; default: *cipher = NULL;