crypto: switch to crypto API for ESSIV generation
Subsystems (6)
v4 cover crypto: switch to crypto API for ESSIV generation
From: Ard Biesheuvel <[email protected]>
This series creates an ESSIV template that produces a skcipher or AEAD transform based on a tuple of the form '<skcipher>,<cipher>,<shash>' (or '<aead>,<cipher>,<shash>' for the AEAD case). It exposes the encapsulated sync or async skcipher/aead by passing through all operations, while using the cipher/shash pair to transform the input IV into an ESSIV output IV.
This matches what both users of ESSIV in the kernel do, and so it is proposed as a replacement for those, in patches #2 and #4.
This code has been tested using the fscrypt test suggested by Eric (generic/549), as well as the mode-test script suggested by Milan for the dm-crypt case. I also tested the aead case in a virtual machine, but it definitely needs some wider testing from the dm-crypt experts.
Open issues (more discussion needed):
- given that hardware already exists that can perform en/decryption including ESSIV generation of a range of blocks, it would be useful to encapsulate this in the ESSIV template, and teach at least dm-crypt how to use it (given that it often processes 8 512-byte sectors at a time)
- given the above, it may or may not make sense to keep the accelerated implementation in patch #6 (and teach it to increment the LE counter after each sector)
Changes since v3:
- address various review comments from Eric on patch #1
- use Kconfig's 'imply' instead of 'select' to permit CRYPTO_ESSIV to be enabled as a module or disabled entirely even if fscrypt is compiled in (#2)
- fix an issue in the AEAD encrypt path caused by the IV being clobbered by the inner skcipher before the hmac was being calculated
Changes since v2:
- fixed a couple of bugs that snuck in after I'd done the bulk of my testing
- some cosmetic tweaks to the ESSIV template skcipher setkey function to align it with the aead one
- add a test case for essiv(cbc(aes),aes,sha256)
- add an accelerated implementation for arm64 that combines the IV derivation and the actual en/decryption in a single asm routine
Scroll down for tcrypt speed test result comparing the essiv template with the asm implementation. Bare cbc(aes) tests included for reference as well. Taken on a 2GHz Cortex-A57 (AMD Seattle)
Code can be found here
https://git.kernel.org/pub/scm/linux/kernel/git/ardb/linux.git/log/?h=essiv-v4
Ard Biesheuvel (6):
crypto: essiv - create wrapper template for ESSIV generation
fs: crypto: invoke crypto API for ESSIV handling
md: dm-crypt: infer ESSIV block cipher from cipher string directly
md: dm-crypt: switch to ESSIV crypto API template
crypto: essiv - add test vector for essiv(cbc(aes),aes,sha256)
crypto: arm64/aes - implement accelerated ESSIV/CBC mode
arch/arm64/crypto/aes-glue.c | 129 ++++ arch/arm64/crypto/aes-modes.S | 99 +++ crypto/Kconfig | 4 + crypto/Makefile | 1 + crypto/essiv.c | 639 ++++++++++++++++++++ crypto/tcrypt.c | 9 + crypto/testmgr.c | 6 + crypto/testmgr.h | 208 +++++++ drivers/md/Kconfig | 1 + drivers/md/dm-crypt.c | 237 ++------ fs/crypto/Kconfig | 1 + fs/crypto/crypto.c | 5 - fs/crypto/fscrypt_private.h | 9 - fs/crypto/keyinfo.c | 88 +-- 14 files changed, 1141 insertions(+), 295 deletions(-) create mode 100644 crypto/essiv.c
Signature · 122 lines
2.17.1 testing speed of async essiv(cbc(aes),aes,sha256) (essiv(cbc-aes-ce,aes-ce,sha256-ce)) encryption tcrypt: test 0 (128 bit key, 16 byte blocks): 3140785 ops/s ( 50252560 bytes) tcrypt: test 1 (128 bit key, 64 byte blocks): 2672908 ops/s (171066112 bytes) tcrypt: test 2 (128 bit key, 256 byte blocks): 1632811 ops/s (417999616 bytes) tcrypt: test 3 (128 bit key, 1024 byte blocks): 665980 ops/s (681963520 bytes) tcrypt: test 4 (128 bit key, 1472 byte blocks): 495180 ops/s (728904960 bytes) tcrypt: test 5 (128 bit key, 8192 byte blocks): 99329 ops/s (813703168 bytes) tcrypt: test 6 (192 bit key, 16 byte blocks): 3106888 ops/s ( 49710208 bytes) tcrypt: test 7 (192 bit key, 64 byte blocks): 2582682 ops/s (165291648 bytes) tcrypt: test 8 (192 bit key, 256 byte blocks): 1511160 ops/s (386856960 bytes) tcrypt: test 9 (192 bit key, 1024 byte blocks): 589841 ops/s (603997184 bytes) tcrypt: test 10 (192 bit key, 1472 byte blocks): 435094 ops/s (640458368 bytes) tcrypt: test 11 (192 bit key, 8192 byte blocks): 82997 ops/s (679911424 bytes) tcrypt: test 12 (256 bit key, 16 byte blocks): 3058592 ops/s ( 48937472 bytes) tcrypt: test 13 (256 bit key, 64 byte blocks): 2496988 ops/s (159807232 bytes) tcrypt: test 14 (256 bit key, 256 byte blocks): 1438355 ops/s (368218880 bytes) tcrypt: test 15 (256 bit key, 1024 byte blocks): 528902 ops/s (541595648 bytes) tcrypt: test 16 (256 bit key, 1472 byte blocks): 387861 ops/s (570931392 bytes) tcrypt: test 17 (256 bit key, 8192 byte blocks): 75444 ops/s (618037248 bytes) testing speed of async essiv(cbc(aes),aes,sha256) (essiv(cbc-aes-ce,aes-ce,sha256-ce)) decryption tcrypt: test 0 (128 bit key, 16 byte blocks): 3164752 ops/s ( 50636032 bytes) tcrypt: test 1 (128 bit key, 64 byte blocks): 2975874 ops/s ( 190455936 bytes) tcrypt: test 2 (128 bit key, 256 byte blocks): 2393123 ops/s ( 612639488 bytes) tcrypt: test 3 (128 bit key, 1024 byte blocks): 1314745 ops/s (1346298880 bytes) tcrypt: test 4 (128 bit key, 1472 byte blocks): 1050717 ops/s (1546655424 bytes) tcrypt: test 5 (128 bit key, 8192 byte blocks): 246457 ops/s (2018975744 bytes) tcrypt: test 6 (192 bit key, 16 byte blocks): 3117489 ops/s ( 49879824 bytes) tcrypt: test 7 (192 bit key, 64 byte blocks): 2922089 ops/s ( 187013696 bytes) tcrypt: test 8 (192 bit key, 256 byte blocks): 2292023 ops/s ( 586757888 bytes) tcrypt: test 9 (192 bit key, 1024 byte blocks): 1207942 ops/s (1236932608 bytes) tcrypt: test 10 (192 bit key, 1472 byte blocks): 955598 ops/s (1406640256 bytes) tcrypt: test 11 (192 bit key, 8192 byte blocks): 195198 ops/s (1599062016 bytes) tcrypt: test 12 (256 bit key, 16 byte blocks): 3081935 ops/s ( 49310960 bytes) tcrypt: test 13 (256 bit key, 64 byte blocks): 2883181 ops/s ( 184523584 bytes) tcrypt: test 14 (256 bit key, 256 byte blocks): 2205147 ops/s ( 564517632 bytes) tcrypt: test 15 (256 bit key, 1024 byte blocks): 1119468 ops/s (1146335232 bytes) tcrypt: test 16 (256 bit key, 1472 byte blocks): 877017 ops/s (1290969024 bytes) tcrypt: test 17 (256 bit key, 8192 byte blocks): 195255 ops/s (1599528960 bytes) testing speed of async essiv(cbc(aes),aes,sha256) (essiv-cbc-aes-sha256-ce) encryption tcrypt: test 0 (128 bit key, 16 byte blocks): 5037539 ops/s ( 80600624 bytes) tcrypt: test 1 (128 bit key, 64 byte blocks): 3884302 ops/s (248595328 bytes) tcrypt: test 2 (128 bit key, 256 byte blocks): 2014999 ops/s (515839744 bytes) tcrypt: test 3 (128 bit key, 1024 byte blocks): 721147 ops/s (738454528 bytes) tcrypt: test 4 (128 bit key, 1472 byte blocks): 525262 ops/s (773185664 bytes) tcrypt: test 5 (128 bit key, 8192 byte blocks): 100453 ops/s (822910976 bytes) tcrypt: test 6 (192 bit key, 16 byte blocks): 4972667 ops/s ( 79562672 bytes) tcrypt: test 7 (192 bit key, 64 byte blocks): 3721788 ops/s (238194432 bytes) tcrypt: test 8 (192 bit key, 256 byte blocks): 1835967 ops/s (470007552 bytes) tcrypt: test 9 (192 bit key, 1024 byte blocks): 633524 ops/s (648728576 bytes) tcrypt: test 10 (192 bit key, 1472 byte blocks): 458306 ops/s (674626432 bytes) tcrypt: test 11 (192 bit key, 8192 byte blocks): 83595 ops/s (684810240 bytes) tcrypt: test 12 (256 bit key, 16 byte blocks): 4975101 ops/s ( 79601616 bytes) tcrypt: test 13 (256 bit key, 64 byte blocks): 3581137 ops/s (229192768 bytes) tcrypt: test 14 (256 bit key, 256 byte blocks): 1741799 ops/s (445900544 bytes) tcrypt: test 15 (256 bit key, 1024 byte blocks): 565340 ops/s (578908160 bytes) tcrypt: test 16 (256 bit key, 1472 byte blocks): 407040 ops/s (599162880 bytes) tcrypt: test 17 (256 bit key, 8192 byte blocks): 76092 ops/s (623345664 bytes) testing speed of async essiv(cbc(aes),aes,sha256) (essiv-cbc-aes-sha256-ce) decryption tcrypt: test 0 (128 bit key, 16 byte blocks): 5122947 ops/s ( 81967152 bytes) tcrypt: test 1 (128 bit key, 64 byte blocks): 4546576 ops/s ( 290980864 bytes) tcrypt: test 2 (128 bit key, 256 byte blocks): 3314744 ops/s ( 848574464 bytes) tcrypt: test 3 (128 bit key, 1024 byte blocks): 1550823 ops/s (1588042752 bytes) tcrypt: test 4 (128 bit key, 1472 byte blocks): 1197388 ops/s (1762555136 bytes) tcrypt: test 5 (128 bit key, 8192 byte blocks): 253661 ops/s (2077990912 bytes) tcrypt: test 6 (192 bit key, 16 byte blocks): 5040644 ops/s ( 80650304 bytes) tcrypt: test 7 (192 bit key, 64 byte blocks): 4442490 ops/s ( 284319360 bytes) tcrypt: test 8 (192 bit key, 256 byte blocks): 3138199 ops/s ( 803378944 bytes) tcrypt: test 9 (192 bit key, 1024 byte blocks): 1406038 ops/s (1439782912 bytes) tcrypt: test 10 (192 bit key, 1472 byte blocks): 1075658 ops/s (1583368576 bytes) tcrypt: test 11 (192 bit key, 8192 byte blocks): 199652 ops/s (1635549184 bytes) tcrypt: test 12 (256 bit key, 16 byte blocks): 4979432 ops/s ( 79670912 bytes) tcrypt: test 13 (256 bit key, 64 byte blocks): 4394406 ops/s ( 281241984 bytes) tcrypt: test 14 (256 bit key, 256 byte blocks): 2999511 ops/s ( 767874816 bytes) tcrypt: test 15 (256 bit key, 1024 byte blocks): 1294498 ops/s (1325565952 bytes) tcrypt: test 16 (256 bit key, 1472 byte blocks): 981009 ops/s (1444045248 bytes) tcrypt: test 17 (256 bit key, 8192 byte blocks): 200463 ops/s (1642192896 bytes) testing speed of async cbc(aes) (cbc-aes-ce) encryption tcrypt: test 0 (128 bit key, 16 byte blocks): 5895884 ops/s ( 94334144 bytes) tcrypt: test 1 (128 bit key, 64 byte blocks): 4347437 ops/s (278235968 bytes) tcrypt: test 2 (128 bit key, 256 byte blocks): 2135454 ops/s (546676224 bytes) tcrypt: test 3 (128 bit key, 1024 byte blocks): 736839 ops/s (754523136 bytes) tcrypt: test 4 (128 bit key, 1472 byte blocks): 533261 ops/s (784960192 bytes) tcrypt: test 5 (128 bit key, 8192 byte blocks): 100850 ops/s (826163200 bytes) tcrypt: test 6 (192 bit key, 16 byte blocks): 5745691 ops/s ( 91931056 bytes) tcrypt: test 7 (192 bit key, 64 byte blocks): 4113271 ops/s (263249344 bytes) tcrypt: test 8 (192 bit key, 256 byte blocks): 1932208 ops/s (494645248 bytes) tcrypt: test 9 (192 bit key, 1024 byte blocks): 644555 ops/s (660024320 bytes) tcrypt: test 10 (192 bit key, 1472 byte blocks): 464237 ops/s (683356864 bytes) tcrypt: test 11 (192 bit key, 8192 byte blocks): 84019 ops/s (688283648 bytes) tcrypt: test 12 (256 bit key, 16 byte blocks): 5620065 ops/s ( 89921040 bytes) tcrypt: test 13 (256 bit key, 64 byte blocks): 3982991 ops/s (254911424 bytes) tcrypt: test 14 (256 bit key, 256 byte blocks): 1830587 ops/s (468630272 bytes) tcrypt: test 15 (256 bit key, 1024 byte blocks): 576151 ops/s (589978624 bytes) tcrypt: test 16 (256 bit key, 1472 byte blocks): 412487 ops/s (607180864 bytes) tcrypt: test 17 (256 bit key, 8192 byte blocks): 76378 ops/s (625688576 bytes) testing speed of async cbc(aes) (cbc-aes-ce) decryption tcrypt: test 0 (128 bit key, 16 byte blocks): 5821314 ops/s ( 93141024 bytes) tcrypt: test 1 (128 bit key, 64 byte blocks): 5248040 ops/s ( 335874560 bytes) tcrypt: test 2 (128 bit key, 256 byte blocks): 3677701 ops/s ( 941491456 bytes) tcrypt: test 3 (128 bit key, 1024 byte blocks): 1650808 ops/s (1690427392 bytes) tcrypt: test 4 (128 bit key, 1472 byte blocks): 1256545 ops/s (1849634240 bytes) tcrypt: test 5 (128 bit key, 8192 byte blocks): 257922 ops/s (2112897024 bytes) tcrypt: test 6 (192 bit key, 16 byte blocks): 5690108 ops/s ( 91041728 bytes) tcrypt: test 7 (192 bit key, 64 byte blocks): 5086441 ops/s ( 325532224 bytes) tcrypt: test 8 (192 bit key, 256 byte blocks): 3447562 ops/s ( 882575872 bytes) tcrypt: test 9 (192 bit key, 1024 byte blocks): 1490136 ops/s (1525899264 bytes) tcrypt: test 10 (192 bit key, 1472 byte blocks): 1124620 ops/s (1655440640 bytes) tcrypt: test 11 (192 bit key, 8192 byte blocks): 201222 ops/s (1648410624 bytes) tcrypt: test 12 (256 bit key, 16 byte blocks): 5567247 ops/s ( 89075952 bytes) tcrypt: test 13 (256 bit key, 64 byte blocks): 5050010 ops/s ( 323200640 bytes) tcrypt: test 14 (256 bit key, 256 byte blocks): 3290422 ops/s ( 842348032 bytes) tcrypt: test 15 (256 bit key, 1024 byte blocks): 1359439 ops/s (1392065536 bytes) tcrypt: test 16 (256 bit key, 1472 byte blocks): 1017751 ops/s (1498129472 bytes) tcrypt: test 17 (256 bit key, 8192 byte blocks): 201492 ops/s (1650622464 bytes)
PATCH v4 1/6 crypto: essiv - create wrapper template for ESSIV generation
From: Ard Biesheuvel <[email protected]>
Implement a template that wraps a (skcipher,cipher,shash) or (aead,cipher,shash) tuple so that we can consolidate the ESSIV handling in fscrypt and dm-crypt and move it into the crypto API. This will result in better test coverage, and will allow future changes to make the bare cipher interface internal to the crypto subsystem, in order to increase robustness of the API against misuse.
--- crypto/Kconfig | 4 + crypto/Makefile | 1 + crypto/essiv.c | 639 ++++++++++++++++++++ 3 files changed, 644 insertions(+)
crypto/Kconfig +4 -0
@@ -1917,6 +1917,10 @@ config CRYPTO_STATS config CRYPTO_HASH_INFO bool +config CRYPTO_ESSIV + tristate + select CRYPTO_AUTHENC + source "drivers/crypto/Kconfig" source "crypto/asymmetric_keys/Kconfig" source "certs/Kconfig"
crypto/Makefile +1 -0
@@ -148,6 +148,7 @@ obj-$(CONFIG_CRYPTO_USER_API_AEAD) += algif_aead.o obj-$(CONFIG_CRYPTO_ZSTD) += zstd.o obj-$(CONFIG_CRYPTO_OFB) += ofb.o obj-$(CONFIG_CRYPTO_ECC) += ecc.o +obj-$(CONFIG_CRYPTO_ESSIV) += essiv.o ecdh_generic-y += ecdh.o ecdh_generic-y += ecdh_helper.o
crypto/essiv.c new file +639 -0
639 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v4 2/6 fs: crypto: invoke crypto API for ESSIV handling
In reply to Ard BiesheuvelFrom: Ard Biesheuvel <[email protected]>
Instead of open coding the calculations for ESSIV handling, use a ESSIV skcipher which does all of this under the hood.
--- fs/crypto/Kconfig | 1 + fs/crypto/crypto.c | 5 -- fs/crypto/fscrypt_private.h | 9 -- fs/crypto/keyinfo.c | 88 +------------------- 4 files changed, 3 insertions(+), 100 deletions(-)
fs/crypto/Kconfig +1 -0
@@ -5,6 +5,7 @@ config FS_ENCRYPTION select CRYPTO_AES select CRYPTO_CBC select CRYPTO_ECB + imply CRYPTO_ESSIV select CRYPTO_XTS select CRYPTO_CTS select CRYPTO_SHA256
fs/crypto/crypto.c +0 -5
@@ -136,9 +136,6 @@ void fscrypt_generate_iv(union fscrypt_iv *iv, u64 lblk_num,if (ci->ci_flags &FS_POLICY_FLAG_DIRECT_KEY )memcpy (iv->nonce, ci->ci_nonce,FS_KEY_DERIVATION_NONCE_SIZE ); - -if (ci->ci_essiv_tfm !=NULL ) -crypto_cipher_encrypt_one (ci->ci_essiv_tfm, iv->raw, iv->raw); } int fscrypt_do_page_crypto(const struct inode *inode, fscrypt_direction_t rw,
@@ -492,8 +489,6 @@ static void __exit fscrypt_exit(void)destroy_workqueue (fscrypt_read_workqueue);kmem_cache_destroy (fscrypt_ctx_cachep);kmem_cache_destroy (fscrypt_info_cachep); - -fscrypt_essiv_cleanup (); }module_exit (fscrypt_exit);
fs/crypto/fscrypt_private.h +0 -9
@@ -61,12 +61,6 @@ struct fscrypt_info {/* The actual crypto transform used for encryption and decryption */ struct crypto_skcipher *ci_ctfm; -/* -* Cipher for ESSIV IV generation. Only set for CBC contents -* encryption, otherwise is NULL. -*/ -struct crypto_cipher *ci_essiv_tfm; -/* * Encryption mode used for this inode. It corresponds to either * ci_data_mode or ci_filename_mode, depending on the inode type.
@@ -166,9 +160,6 @@ struct fscrypt_mode {int keysize;int ivsize; bool logged_impl_name; -bool needs_essiv; }; -extern void __exit fscrypt_essiv_cleanup(void); -#endif /* _FSCRYPT_PRIVATE_H */
fs/crypto/keyinfo.c +2 -86
125 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v4 3/6 md: dm-crypt: infer ESSIV block cipher from cipher string directly
In reply to Ard BiesheuvelFrom: Ard Biesheuvel <[email protected]>
Instead of allocating a crypto skcipher tfm 'foo' and attempting to infer the encapsulated block cipher from the driver's 'name' field, directly parse the string that we used to allocated the tfm. These are always identical (unless the allocation failed, in which case we bail anyway), but using the string allows us to use it in the allocation, which is something we will need when switching to the 'essiv' crypto API template.
--- drivers/md/dm-crypt.c | 35 +++++++++----------- 1 file changed, 15 insertions(+), 20 deletions(-)
drivers/md/dm-crypt.c +15 -20
@@ -2321,25 +2321,17 @@ static int crypt_ctr_ivmode(struct dm_target *ti, const char *ivmode)* The cc->cipher is currently used only in ESSIV. * This should be probably done by crypto-api calls (once available...) */ -static int crypt_ctr_blkdev_cipher (struct crypt_config *cc) +static int crypt_ctr_blkdev_cipher (struct crypt_config *cc,char *alg_name) { -const char *alg_name =NULL ;char *start, *end;if (crypt_integrity_aead (cc)) { - alg_name =crypto_tfm_alg_name (crypto_aead_tfm (any_tfm_aead (cc))); -if (!alg_name) -return -EINVAL ;if (crypt_integrity_hmac (cc)) { alg_name =strchr (alg_name,',' );if (!alg_name)return -EINVAL ; } alg_name++; - }else { - alg_name =crypto_tfm_alg_name (crypto_skcipher_tfm (any_tfm (cc))); -if (!alg_name) -return -EINVAL ; } start =strchr (alg_name,'(' );
@@ -2434,6 +2426,20 @@ static int crypt_ctr_cipher_new(struct dm_target *ti, char *cipher_in, char *keyif (*ivmode && !strcmp (*ivmode,"lmk" )) cc->tfms_count =64 ; +if (crypt_integrity_aead (cc)) { + ret =crypt_ctr_auth_cipher (cc, cipher_api); +if (ret <0 ) { + ti->error ="Invalid AEAD cipher spec" ; +return -ENOMEM ; + } + } + + ret =crypt_ctr_blkdev_cipher (cc, cipher_api); +if (ret <0 ) { + ti->error ="Cannot allocate cipher string" ; +return -ENOMEM ; + } + cc->key_parts = cc->tfms_count;/* Allocate cipher */
@@ -2445,21 +2451,10 @@ static int crypt_ctr_cipher_new(struct dm_target *ti, char *cipher_in, char *key/* Alloc AEAD, can be used only in new format. */ if (crypt_integrity_aead (cc)) { - ret =crypt_ctr_auth_cipher (cc, cipher_api); -if (ret <0 ) { - ti->error ="Invalid AEAD cipher spec" ; -return -ENOMEM ; - } cc->iv_size =crypto_aead_ivsize (any_tfm_aead (cc)); }else cc->iv_size =crypto_skcipher_ivsize (any_tfm (cc)); - ret =crypt_ctr_blkdev_cipher (cc); -if (ret <0 ) { - ti->error ="Cannot allocate cipher string" ; -return -ENOMEM ; - } -return 0 ; }
Signature · 1 line
2.17.1
PATCH v4 4/6 md: dm-crypt: switch to ESSIV crypto API template
In reply to Ard BiesheuvelFrom: Ard Biesheuvel <[email protected]>
Replace the explicit ESSIV handling in the dm-crypt driver with calls into the crypto API, which now possesses the capability to perform this processing within the crypto subsystem.
--- drivers/md/Kconfig | 1 + drivers/md/dm-crypt.c | 208 +++----------------- 2 files changed, 31 insertions(+), 178 deletions(-)
drivers/md/Kconfig +1 -0
@@ -271,6 +271,7 @@ config DM_CRYPT depends on BLK_DEV_DM select CRYPTO select CRYPTO_CBC + select CRYPTO_ESSIV ---help--- This device-mapper target allows you to create a device that transparently encrypts the data on it. You'll need to activate
drivers/md/dm-crypt.c +30 -178
268 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [PATCH v4 4/6] md: dm-crypt: switch to ESSIV crypto API template
Quoted 5 lines · Ard Biesheuvel
From: Ard Biesheuvel <[email protected]>
Replace the explicit ESSIV handling in the dm-crypt driver with calls into the crypto API, which now possesses the capability to perform this processing within the crypto subsystem.
I tried a few crazy dm-crypt configurations and was not able to crash it this time :-)
So, it definitely need some more testing, but for now, I think it works.
Few comments below for this part:
drivers/md/dm-crypt.c static int crypt_ctr_ivmode(struct dm_target *ti, const char *ivmode) · line 2115
Quoted 12 lines
drivers/md/dm-crypt.c +1
-1static const struct crypt_iv_operations crypt_iv_benbi_ops = { .ctr = crypt_iv_benbi_ctr, .dtr = crypt_iv_benbi_dtr,@@ -2283,7 +2112,7 @@ static int crypt_ctr_ivmode(struct dm_target *ti, const char *ivmode)else if (strcmp (ivmode,"plain64be" ) ==0 ) cc->iv_gen_ops = &crypt_iv_plain64be_ops;else if (strcmp (ivmode,"essiv" ) ==0 ) - cc->iv_gen_ops = &crypt_iv_essiv_ops; + cc->iv_gen_ops = &crypt_iv_plain64_ops;
This is quite misleading - it looks like you are switching to plain64 here. The reality is that it uses plain64 to feed the ESSIV wrapper.
So either it need some comment to explain it here, or just keep simple essiv_iv_ops and duplicate that plain64 generator (it is 2 lines of code).
For the clarity, I would prefer the second variant (duplicate ops) here.
Quoted 4 lines
drivers/md/dm-crypt.c +0
-0@@ -2515,8 +2357,18 @@ static int crypt_ctr_cipher_old(struct dm_target *ti, char *cipher_in, char *keyif (!cipher_api) goto bad_mem;
drivers/md/dm-crypt.c static int crypt_ctr_cipher_old(struct dm_target *ti, char *cipher_in, char *key · line 2367
Quoted 10 lines
drivers/md/dm-crypt.c +8
-2- ret =snprintf (cipher_api,CRYPTO_MAX_ALG_NAME , -"%s(%s)" , chainmode, cipher); +if (*ivmode && !strcmp (*ivmode,"essiv" )) { +if (!*ivopts) { + ti->error ="Digest algorithm missing for ESSIV mode" ; +return -EINVAL ; + } + ret =snprintf (cipher_api,CRYPTO_MAX_ALG_NAME , +"essiv(%s(%s),%s,%s)" , chainmode, cipher, + cipher, *ivopts);
This becomes quite long string already (limit is now 128 bytes), we should probably check also for too long string. It will perhaps fail later, but I would better add
if (ret < 0 || ret >= CRYPTO_MAX_ALG_NAME) {
...drivers/md/dm-crypt.c static int crypt_ctr_cipher_old(struct dm_target *ti, char *cipher_in, char *key · line 2374
Quoted 8 lines
drivers/md/dm-crypt.c +4
-0+ }else { + ret =snprintf (cipher_api,CRYPTO_MAX_ALG_NAME , +"%s(%s)" , chainmode, cipher); + }if (ret <0 ) {kfree (cipher_api); goto bad_mem;
Thanks,
Milan
Re: [PATCH v4 4/6] md: dm-crypt: switch to ESSIV crypto API template
2562-06-24 14:05 GMT+07:00, Milan Broz <[email protected]>:
Quoted 78 lines · Ard Biesheuvel
Quoted 5 lines
From: Ard Biesheuvel <[email protected]>
Replace the explicit ESSIV handling in the dm-crypt driver with calls into the crypto API, which now possesses the capability to perform this processing within the crypto subsystem.
I tried a few crazy dm-crypt configurations and was not able to crash it this time :-)
So, it definitely need some more testing, but for now, I think it works.
Few comments below for this part:
drivers/md/dm-crypt.c static int crypt_ctr_ivmode(struct dm_target *ti, · line 2116
Quoted 13 lines
drivers/md/dm-crypt.c +1
-1static const struct crypt_iv_operations crypt_iv_benbi_ops = { .ctr = crypt_iv_benbi_ctr, .dtr = crypt_iv_benbi_dtr,@@ -2283,7 +2112,7 @@ static int crypt_ctr_ivmode(struct dm_target *ti, const char *ivmode) else if (strcmp(ivmode, "plain64be") == 0) cc->iv_gen_ops = &crypt_iv_plain64be_ops; else if (strcmp(ivmode, "essiv") == 0) - cc->iv_gen_ops = &crypt_iv_essiv_ops; + cc->iv_gen_ops = &crypt_iv_plain64_ops;This is quite misleading - it looks like you are switching to plain64 here. The reality is that it uses plain64 to feed the ESSIV wrapper.
So either it need some comment to explain it here, or just keep simple
essiv_iv_ops
and duplicate that plain64 generator (it is 2 lines of code).For the clarity, I would prefer the second variant (duplicate ops) here.
Quoted 5 lines
drivers/md/dm-crypt.c +0
-0@@ -2515,8 +2357,18 @@ static int crypt_ctr_cipher_old(struct dm_target *ti, char *cipher_in, char *keyif (!cipher_api) goto bad_mem;drivers/md/dm-crypt.c static int crypt_ctr_cipher_old(struct dm_target · line 2368
Quoted 10 lines
drivers/md/dm-crypt.c +8
-2- ret =snprintf (cipher_api,CRYPTO_MAX_ALG_NAME , -"%s(%s)" , chainmode, cipher); +if (*ivmode && !strcmp (*ivmode,"essiv" )) { +if (!*ivopts) { + ti->error ="Digest algorithm missing for ESSIV mode" ; +return -EINVAL ; + } + ret =snprintf (cipher_api,CRYPTO_MAX_ALG_NAME , +"essiv(%s(%s),%s,%s)" , chainmode, cipher, + cipher, *ivopts);This becomes quite long string already (limit is now 128 bytes), we should probably
check also for too long string. It will perhaps fail later, but I would better addif (ret < 0 || ret >= CRYPTO_MAX_ALG_NAME) { ...Quoted 8 lines
drivers/md/dm-crypt.c +4
-0+ }else { + ret =snprintf (cipher_api,CRYPTO_MAX_ALG_NAME , +"%s(%s)" , chainmode, cipher); + }if (ret <0 ) {kfree (cipher_api);goto
bad_mem;Thanks,
Milan--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel
PATCH v4 5/6 crypto: essiv - add test vector for essiv(cbc(aes), aes, sha256)
In reply to Ard BiesheuvelFrom: Ard Biesheuvel <[email protected]>
Add a test vector for the ESSIV mode that is the most widely used, i.e., using cbc(aes) and sha256.
--- crypto/tcrypt.c | 9 + crypto/testmgr.c | 6 + crypto/testmgr.h | 208 ++++++++++++++++++++ 3 files changed, 223 insertions(+)
crypto/tcrypt.c +9 -0
@@ -2327,6 +2327,15 @@ static int do_test(const char *alg, u32 type, u32 mask, int m, u32 num_mb) 0, speed_template_32);break ; +case 220 : +test_acipher_speed ("essiv(cbc(aes),aes,sha256)" , +ENCRYPT , sec,NULL ,0 , + speed_template_16_24_32); +test_acipher_speed ("essiv(cbc(aes),aes,sha256)" , +DECRYPT , sec,NULL ,0 , + speed_template_16_24_32); +break ; +case 300 :if (alg) {test_hash_speed (alg, sec, generic_hash_speed_template);
crypto/testmgr.c +6 -0
@@ -4253,6 +4253,12 @@ static const struct alg_test_desc alg_test_descs[] = { .suite = { .akcipher = __VECS(ecrdsa_tv_template) } + }, { + .alg = "essiv(cbc(aes),aes,sha256)", + .test = alg_test_skcipher, + .suite = { + .cipher = __VECS(essiv_aes_cbc_tv_template) + } }, { .alg = "gcm(aes)", .generic_driver = "gcm_base(ctr(aes-generic),ghash-generic)",
crypto/testmgr.h +208 -0
212 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v4 6/6 crypto: arm64/aes - implement accelerated ESSIV/CBC mode
In reply to Ard BiesheuvelFrom: Ard Biesheuvel <[email protected]>
Add an accelerated version of the 'essiv(cbc(aes),aes,sha256' skcipher, which is used by fscrypt, and in some cases, by dm-crypt. This avoids a separate call into the AES cipher for every invocation.
--- arch/arm64/crypto/aes-glue.c | 129 ++++++++++++++++++++ arch/arm64/crypto/aes-modes.S | 99 +++++++++++++++ 2 files changed, 228 insertions(+)
arch/arm64/crypto/aes-glue.c +129 -0
@@ -12,6 +12,7 @@#include <asm/hwcap.h> #include <asm/simd.h> #include <crypto/aes.h> +#include <crypto/sha.h> #include <crypto/internal/hash.h> #include <crypto/internal/simd.h> #include <crypto/internal/skcipher.h>
@@ -34,6 +35,8 @@#define aes_cbc_decrypt ce_aes_cbc_decrypt#define aes_cbc_cts_encrypt ce_aes_cbc_cts_encrypt#define aes_cbc_cts_decrypt ce_aes_cbc_cts_decrypt +#define aes_essiv_cbc_encrypt ce_aes_essiv_cbc_encrypt +#define aes_essiv_cbc_decrypt ce_aes_essiv_cbc_decrypt#define aes_ctr_encrypt ce_aes_ctr_encrypt#define aes_xts_encrypt ce_aes_xts_encrypt#define aes_xts_decrypt ce_aes_xts_decrypt
@@ -50,6 +53,8 @@ MODULE_DESCRIPTION("AES-ECB/CBC/CTR/XTS using ARMv8 Crypto Extensions");#define aes_cbc_decrypt neon_aes_cbc_decrypt#define aes_cbc_cts_encrypt neon_aes_cbc_cts_encrypt#define aes_cbc_cts_decrypt neon_aes_cbc_cts_decrypt +#define aes_essiv_cbc_encrypt neon_aes_essiv_cbc_encrypt +#define aes_essiv_cbc_decrypt neon_aes_essiv_cbc_decrypt#define aes_ctr_encrypt neon_aes_ctr_encrypt#define aes_xts_encrypt neon_aes_xts_encrypt#define aes_xts_decrypt neon_aes_xts_decrypt
@@ -93,6 +98,13 @@ asmlinkage void aes_xts_decrypt(u8 out[], u8 const in[], u32 const rk1[], int rounds, int blocks, u32 const rk2[], u8 iv[], int first); +asmlinkage void aes_essiv_cbc_encrypt(u8 out[], u8 const in[], u32 const rk1[], +int rounds,int blocks,u32 const rk2[], +u8 iv[],int first); +asmlinkage void aes_essiv_cbc_decrypt(u8 out[], u8 const in[], u32 const rk1[], +int rounds,int blocks,u32 const rk2[], +u8 iv[],int first); + asmlinkage void aes_mac_update(u8 const in[], u32 const rk[], int rounds,int blocks,u8 dg[],int enc_before,int enc_after);
@@ -108,6 +120,12 @@ struct crypto_aes_xts_ctx {struct crypto_aes_ctx __aligned(8) key2; }; +struct crypto_aes_essiv_cbc_ctx { +struct crypto_aes_ctx key1; +struct crypto_aes_ctx __aligned(8) key2; +struct crypto_shash *hash; +}; +struct mac_tfm_ctx {struct crypto_aes_ctx key;u8 __aligned(8) consts[];
@@ -145,6 +163,31 @@ static int xts_set_key(struct crypto_skcipher *tfm, const u8 *in_key,return -EINVAL ; } +static int essiv_cbc_set_key (struct crypto_skcipher *tfm,const u8 *in_key, +unsigned int key_len) +{ +struct crypto_aes_essiv_cbc_ctx *ctx =crypto_skcipher_ctx (tfm); +SHASH_DESC_ON_STACK (desc, ctx->hash); +u8 digest[SHA256_DIGEST_SIZE ]; +int ret; + + ret =aes_expandkey (&ctx->key1, in_key, key_len); +if (ret) + goto out; + + desc->tfm = ctx->hash; +crypto_shash_digest (desc, in_key, key_len, digest); + + ret =aes_expandkey (&ctx->key2, digest,sizeof (digest)); +if (ret) + goto out; + +return 0 ; +out: +crypto_skcipher_set_flags (tfm,CRYPTO_TFM_RES_BAD_KEY_LEN ); +return -EINVAL ; +} +static int ecb_encrypt (struct skcipher_request *req) {struct crypto_skcipher *tfm =crypto_skcipher_reqtfm (req);
@@ -361,6 +404,74 @@ static int cts_cbc_decrypt(struct skcipher_request *req)return skcipher_walk_done (&walk,0 ); } +static int essiv_cbc_init_tfm (struct crypto_skcipher *tfm) +{ +struct crypto_aes_essiv_cbc_ctx *ctx =crypto_skcipher_ctx (tfm); + + ctx->hash =crypto_alloc_shash ("sha256" ,0 ,0 ); +if (IS_ERR (ctx->hash)) +return PTR_ERR (ctx->hash); + +return 0 ; +} + +static void essiv_cbc_exit_tfm (struct crypto_skcipher *tfm) +{ +struct crypto_aes_essiv_cbc_ctx *ctx =crypto_skcipher_ctx (tfm); + +crypto_free_shash (ctx->hash); +} + +static int essiv_cbc_encrypt (struct skcipher_request *req) +{ +struct crypto_skcipher *tfm =crypto_skcipher_reqtfm (req); +struct crypto_aes_essiv_cbc_ctx *ctx =crypto_skcipher_ctx (tfm); +int err, first, rounds =6 + ctx->key1.key_length /4 ; +struct skcipher_walk walk; +u8 iv[AES_BLOCK_SIZE ]; +unsigned int blocks; + +memcpy (iv, req->iv,crypto_skcipher_ivsize (tfm)); + + err =skcipher_walk_virt (&walk, req, false); + +for (first =1 ; (blocks = (walk.nbytes /AES_BLOCK_SIZE )); first =0 ) { +kernel_neon_begin (); +aes_essiv_cbc_encrypt (walk.dst.virt.addr, walk.src.virt.addr, + ctx->key1.key_enc, rounds, blocks, + ctx->key2.key_enc, iv, first); +kernel_neon_end (); + err =skcipher_walk_done (&walk, walk.nbytes %AES_BLOCK_SIZE ); + } + +return err; +} + +static int essiv_cbc_decrypt (struct skcipher_request *req) +{ +struct crypto_skcipher *tfm =crypto_skcipher_reqtfm (req); +struct crypto_aes_essiv_cbc_ctx *ctx =crypto_skcipher_ctx (tfm); +int err, first, rounds =6 + ctx->key1.key_length /4 ; +struct skcipher_walk walk; +u8 iv[AES_BLOCK_SIZE ]; +unsigned int blocks; + +memcpy (iv, req->iv,crypto_skcipher_ivsize (tfm)); + + err =skcipher_walk_virt (&walk, req, false); + +for (first =1 ; (blocks = (walk.nbytes /AES_BLOCK_SIZE )); first =0 ) { +kernel_neon_begin (); +aes_essiv_cbc_decrypt (walk.dst.virt.addr, walk.src.virt.addr, + ctx->key1.key_dec, rounds, blocks, + ctx->key2.key_enc, iv, first); +kernel_neon_end (); + err =skcipher_walk_done (&walk, walk.nbytes %AES_BLOCK_SIZE ); + } + +return err; +} +static int ctr_encrypt (struct skcipher_request *req) {struct crypto_skcipher *tfm =crypto_skcipher_reqtfm (req);
@@ -504,6 +615,24 @@ static struct skcipher_alg aes_algs[] = { { .encrypt = cts_cbc_encrypt, .decrypt = cts_cbc_decrypt, .init = cts_cbc_init_tfm, +}, { + .base = { + .cra_name = "__essiv(cbc(aes),aes,sha256)", + .cra_driver_name = "__essiv-cbc-aes-sha256-" MODE, + .cra_priority = PRIO + 1, + .cra_flags = CRYPTO_ALG_INTERNAL, + .cra_blocksize = AES_BLOCK_SIZE, + .cra_ctxsize = sizeof(struct crypto_aes_essiv_cbc_ctx), + .cra_module = THIS_MODULE, + }, + .min_keysize = AES_MIN_KEY_SIZE, + .max_keysize = AES_MAX_KEY_SIZE, + .ivsize = sizeof(u64), + .setkey = essiv_cbc_set_key, + .encrypt = essiv_cbc_encrypt, + .decrypt = essiv_cbc_decrypt, + .init = essiv_cbc_init_tfm, + .exit = essiv_cbc_exit_tfm, }, { .base = { .cra_name = "__ctr(aes)",
arch/arm64/crypto/aes-modes.S +99 -0
105 lines not on this page · raw message
Signature · 1 line
2.17.1
Quoted 3 lines · Ard Biesheuvel
From: Ard Biesheuvel <[email protected]>
...
Quoted 5 lines
- given that hardware already exists that can perform en/decryption including ESSIV generation of a range of blocks, it would be useful to encapsulate this in the ESSIV template, and teach at least dm-crypt how to use it (given that it often processes 8 512-byte sectors at a time)
I thought about this a bit more, and it occurred to me that the capability of issuing several sectors at a time and letting the lower layers increment the IV between sectors is orthogonal to whether ESSIV is being used or not, and so it probably belongs in another wrapper.
I.e., if we define a skcipher template like dmplain64le(), which is defined as taking a sector size as part of the key, and which increments a 64 LE counter between sectors if multiple are passed, it can be used not only for ESSIV but also for XTS, which I assume can be h/w accelerated in the same way.
So with that in mind, I think we should decouple the multi-sector discussion and leave it for a followup series, preferably proposed by someone who also has access to some hardware to prototype it on.
Herbert Xu
maintainerQuoted 4 lines · Ard Biesheuvel
So with that in mind, I think we should decouple the multi-sector discussion and leave it for a followup series, preferably proposed by someone who also has access to some hardware to prototype it on.
Yes that makes sense.
Thanks,
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Quoted 7 lines · Herbert Xu
Quoted 4 lines · Ard Biesheuvel
So with that in mind, I think we should decouple the multi-sector discussion and leave it for a followup series, preferably proposed by someone who also has access to some hardware to prototype it on.
Yes that makes sense.
Yes.
And TBH, the most important optimization for dm-crypt in this case is processing 8 512-bytes sectors in 4k encryption block (because page cache will generate page-sized bios) and with XTS mode and linear IV (plain64), not ESSIV.
Dm-crypt can use 4k sectors directly, there are only two blockers - you need LUKS2 to support it, and many devices just do not advertise physical 4k sectors (many SSDs). So switching to 4k could cause some problems with partial 4k writes (after a crash or power-fail).
The plan for the dm-crypt side is more to focus on using 4k native sectors than this micro-optimization in HW.
Milan
Eric Biggers
maintainerQuoted 22 lines · Ard Biesheuvel
Quoted 3 lines · Ard Biesheuvel
From: Ard Biesheuvel <[email protected]>
...
Quoted 5 lines
- given that hardware already exists that can perform en/decryption including ESSIV generation of a range of blocks, it would be useful to encapsulate this in the ESSIV template, and teach at least dm-crypt how to use it (given that it often processes 8 512-byte sectors at a time)
I thought about this a bit more, and it occurred to me that the capability of issuing several sectors at a time and letting the lower layers increment the IV between sectors is orthogonal to whether ESSIV is being used or not, and so it probably belongs in another wrapper.
I.e., if we define a skcipher template like
dmplain64le(), which is defined as taking a sector size as part of the key, and which increments a 64 LE counter between sectors if multiple are passed, it can be used not only for ESSIV but also for XTS, which I assume can be h/w accelerated in the same way.
Quoted 4 lines
So with that in mind, I think we should decouple the multi-sector discussion and leave it for a followup series, preferably proposed by someone who also has access to some hardware to prototype it on.
This makes sense, but if we're going to leave that functionality out of the essiv template, I think we should revisit whether the essiv template takes a __le64 sector number vs. just an IV matching the cipher block size. To me, defining the IV to be a __le64 seems like a layering violation. Also, dm-crypt and fscrypt already know how to zero-pad the sector number to form the full 16 byte IV, and your patch just duplicates that logic in the essiv template too, which makes it more complicated than necessary.
E.g., the following incremental patch for the skcipher case would simplify it:
(You'd have to do it for the AEAD case too.)
crypto/essiv.c +14 -36
@@ -57,11 +57,6 @@ struct essiv_tfm_ctx {struct crypto_shash *hash; }; -struct essiv_skcipher_request_ctx { -u8 iv[MAX_INNER_IV_SIZE ]; -struct skcipher_request skcipher_req; -}; -struct essiv_aead_request_ctx {u8 iv[2 ][MAX_INNER_IV_SIZE ];struct scatterlist src[4 ], dst[4 ];
@@ -161,39 +156,32 @@ static void essiv_skcipher_done(struct crypto_async_request *areq, int err)skcipher_request_complete (req, err); } -static void essiv_skcipher_prepare_subreq (struct skcipher_request *req) +static int essiv_skcipher_crypt (struct skcipher_request *req,bool enc) {struct crypto_skcipher *tfm =crypto_skcipher_reqtfm (req);const struct essiv_tfm_ctx *tctx =crypto_skcipher_ctx (tfm); -struct essiv_skcipher_request_ctx *rctx =skcipher_request_ctx (req); -struct skcipher_request *subreq = &rctx->skcipher_req; - -memset (rctx->iv,0 ,crypto_cipher_blocksize (tctx->essiv_cipher)); -memcpy (rctx->iv, req->iv,crypto_skcipher_ivsize (tfm)); +struct skcipher_request *subreq =skcipher_request_ctx (req); -crypto_cipher_encrypt_one (tctx->essiv_cipher, rctx->iv, rctx->iv); +crypto_cipher_encrypt_one (tctx->essiv_cipher, req->iv, req->iv);skcipher_request_set_tfm (subreq, tctx->u.skcipher);skcipher_request_set_crypt (subreq, req->src, req->dst, req->cryptlen, - rctx->iv); + req->iv);skcipher_request_set_callback (subreq,skcipher_request_flags (req), essiv_skcipher_done, req); + +return enc ?crypto_skcipher_encrypt (subreq) : +crypto_skcipher_decrypt (subreq); }static int essiv_skcipher_encrypt (struct skcipher_request *req) { -struct essiv_skcipher_request_ctx *rctx =skcipher_request_ctx (req); - -essiv_skcipher_prepare_subreq (req); -return crypto_skcipher_encrypt (&rctx->skcipher_req); +return essiv_skcipher_crypt (req, true); }static int essiv_skcipher_decrypt (struct skcipher_request *req) { -struct essiv_skcipher_request_ctx *rctx =skcipher_request_ctx (req); - -essiv_skcipher_prepare_subreq (req); -return crypto_skcipher_decrypt (&rctx->skcipher_req); +return essiv_skcipher_crypt (req, false); }static void essiv_aead_done (struct crypto_async_request *areq,int err)
@@ -300,24 +288,14 @@ static int essiv_skcipher_init_tfm(struct crypto_skcipher *tfm)struct essiv_instance_ctx *ictx =skcipher_instance_ctx (inst);struct essiv_tfm_ctx *tctx =crypto_skcipher_ctx (tfm);struct crypto_skcipher *skcipher; -unsigned int subreq_size;int err; - BUILD_BUG_ON(offsetofend(struct essiv_skcipher_request_ctx, - skcipher_req) != - sizeof(struct essiv_skcipher_request_ctx)); - skcipher =crypto_spawn_skcipher (&ictx->u.skcipher_spawn);if (IS_ERR (skcipher))return PTR_ERR (skcipher); - subreq_size = FIELD_SIZEOF(struct essiv_skcipher_request_ctx, - skcipher_req) + -crypto_skcipher_reqsize (skcipher); - -crypto_skcipher_set_reqsize (tfm, - offsetof(struct essiv_skcipher_request_ctx , - skcipher_req) + subreq_size); +crypto_skcipher_set_reqsize (tfm,sizeof (struct skcipher_request ) + +crypto_skcipher_reqsize (skcipher)); err =essiv_init_tfm (ictx, tctx);if (err) {
@@ -567,9 +545,9 @@ static int essiv_create(struct crypto_template *tmpl, struct rtattr **tb) skcipher_inst->alg.min_keysize =crypto_skcipher_alg_min_keysize (skcipher_alg); skcipher_inst->alg.max_keysize =crypto_skcipher_alg_max_keysize (skcipher_alg); - skcipher_inst->alg.ivsize =ESSIV_IV_SIZE ; - skcipher_inst->alg.chunksize = skcipher_alg->chunksize; - skcipher_inst->alg.walksize = skcipher_alg->walksize; + skcipher_inst->alg.ivsize =crypto_skcipher_alg_ivsize (skcipher_alg); + skcipher_inst->alg.chunksize =crypto_skcipher_alg_chunksize (skcipher_alg); + skcipher_inst->alg.walksize =crypto_skcipher_alg_walksize (skcipher_alg); skcipher_inst->free = essiv_skcipher_free_instance;