Commit fb3652c1 authored by James Morris's avatar James Morris

[CRYPTO]: Update to IV get/set interface.

parent 03882e04
...@@ -982,6 +982,14 @@ test_des(void) ...@@ -982,6 +982,14 @@ test_des(void)
memcpy(tvmem, des_cbc_enc_tv_template, tsize); memcpy(tvmem, des_cbc_enc_tv_template, tsize);
des_tv = (void *) tvmem; des_tv = (void *) tvmem;
crypto_cipher_set_iv(tfm, des_tv[i].iv, crypto_tfm_alg_ivsize(tfm));
crypto_cipher_get_iv(tfm, res, crypto_tfm_alg_ivsize(tfm));
if (memcmp(res, des_tv[i].iv, sizeof(res))) {
printk("crypto_cipher_[set|get]_iv() failed\n");
goto out;
}
for (i = 0; i < DES_CBC_ENC_TEST_VECTORS; i++) { for (i = 0; i < DES_CBC_ENC_TEST_VECTORS; i++) {
printk("test %d:\n", i + 1); printk("test %d:\n", i + 1);
...@@ -1000,8 +1008,8 @@ test_des(void) ...@@ -1000,8 +1008,8 @@ test_des(void)
sg[0].offset = ((long) p & ~PAGE_MASK); sg[0].offset = ((long) p & ~PAGE_MASK);
sg[0].length = len; sg[0].length = len;
crypto_cipher_copy_iv(tfm, des_tv[i].iv, crypto_cipher_set_iv(tfm, des_tv[i].iv,
crypto_tfm_alg_ivsize(tfm)); crypto_tfm_alg_ivsize(tfm));
ret = crypto_cipher_encrypt(tfm, sg, 1); ret = crypto_cipher_encrypt(tfm, sg, 1);
if (ret) { if (ret) {
...@@ -1060,7 +1068,7 @@ test_des(void) ...@@ -1060,7 +1068,7 @@ test_des(void)
sg[1].offset = ((long) p & ~PAGE_MASK); sg[1].offset = ((long) p & ~PAGE_MASK);
sg[1].length = 11; sg[1].length = 11;
crypto_cipher_copy_iv(tfm, des_tv[i].iv, crypto_tfm_alg_ivsize(tfm)); crypto_cipher_set_iv(tfm, des_tv[i].iv, crypto_tfm_alg_ivsize(tfm));
ret = crypto_cipher_encrypt(tfm, sg, 2); ret = crypto_cipher_encrypt(tfm, sg, 2);
if (ret) { if (ret) {
...@@ -1108,7 +1116,7 @@ test_des(void) ...@@ -1108,7 +1116,7 @@ test_des(void)
sg[0].offset = ((long) p & ~PAGE_MASK); sg[0].offset = ((long) p & ~PAGE_MASK);
sg[0].length = len; sg[0].length = len;
crypto_cipher_copy_iv(tfm, des_tv[i].iv, crypto_cipher_set_iv(tfm, des_tv[i].iv,
crypto_tfm_alg_blocksize(tfm)); crypto_tfm_alg_blocksize(tfm));
ret = crypto_cipher_decrypt(tfm, sg, 1); ret = crypto_cipher_decrypt(tfm, sg, 1);
...@@ -1161,7 +1169,7 @@ test_des(void) ...@@ -1161,7 +1169,7 @@ test_des(void)
sg[1].offset = ((long) p & ~PAGE_MASK); sg[1].offset = ((long) p & ~PAGE_MASK);
sg[1].length = 4; sg[1].length = 4;
crypto_cipher_copy_iv(tfm, des_tv[i].iv, crypto_tfm_alg_ivsize(tfm)); crypto_cipher_set_iv(tfm, des_tv[i].iv, crypto_tfm_alg_ivsize(tfm));
ret = crypto_cipher_decrypt(tfm, sg, 2); ret = crypto_cipher_decrypt(tfm, sg, 2);
if (ret) { if (ret) {
......
...@@ -275,13 +275,20 @@ static inline int crypto_cipher_decrypt(struct crypto_tfm *tfm, ...@@ -275,13 +275,20 @@ static inline int crypto_cipher_decrypt(struct crypto_tfm *tfm,
return tfm->crt_cipher.cit_decrypt(tfm, sg, nsg); return tfm->crt_cipher.cit_decrypt(tfm, sg, nsg);
} }
static inline void crypto_cipher_copy_iv(struct crypto_tfm *tfm, static inline void crypto_cipher_set_iv(struct crypto_tfm *tfm,
u8 *src, size_t len) u8 *src, size_t len)
{ {
BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER); BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
memcpy(tfm->crt_cipher.cit_iv, src, len); memcpy(tfm->crt_cipher.cit_iv, src, len);
} }
static inline void crypto_cipher_get_iv(struct crypto_tfm *tfm,
u8 *dst, size_t len)
{
BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
memcpy(dst, tfm->crt_cipher.cit_iv, len);
}
static inline void crypto_comp_compress(struct crypto_tfm *tfm) static inline void crypto_comp_compress(struct crypto_tfm *tfm)
{ {
BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_COMP); BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_COMP);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment