echainiv.c (75bf465f0bc33e9b776a46d6a1b9b990f5fb7c37) | echainiv.c (0f8f6d86d415f9d88dc0f7847f11d0c52dba1965) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-or-later 2/* 3 * echainiv: Encrypted Chain IV Generator 4 * 5 * This generator generates an IV based on a sequence number by multiplying 6 * it with a salt and then encrypting it with the same key as used to encrypt 7 * the plain text. This algorithm requires that the block size be equal 8 * to the IV size. It is mainly useful for CBC. --- 119 unchanged lines hidden (view full) --- 128 inst->alg.decrypt = echainiv_decrypt; 129 130 inst->alg.init = aead_init_geniv; 131 inst->alg.exit = aead_exit_geniv; 132 133 inst->alg.base.cra_ctxsize = sizeof(struct aead_geniv_ctx); 134 inst->alg.base.cra_ctxsize += inst->alg.ivsize; 135 | 1// SPDX-License-Identifier: GPL-2.0-or-later 2/* 3 * echainiv: Encrypted Chain IV Generator 4 * 5 * This generator generates an IV based on a sequence number by multiplying 6 * it with a salt and then encrypting it with the same key as used to encrypt 7 * the plain text. This algorithm requires that the block size be equal 8 * to the IV size. It is mainly useful for CBC. --- 119 unchanged lines hidden (view full) --- 128 inst->alg.decrypt = echainiv_decrypt; 129 130 inst->alg.init = aead_init_geniv; 131 inst->alg.exit = aead_exit_geniv; 132 133 inst->alg.base.cra_ctxsize = sizeof(struct aead_geniv_ctx); 134 inst->alg.base.cra_ctxsize += inst->alg.ivsize; 135 |
136 inst->free = aead_geniv_free; 137 | |
138 err = aead_register_instance(tmpl, inst); | 136 err = aead_register_instance(tmpl, inst); |
139 if (err) 140 goto free_inst; 141 142out: 143 return err; 144 | 137 if (err) { |
145free_inst: | 138free_inst: |
146 aead_geniv_free(inst); 147 goto out; | 139 inst->free(inst); 140 } 141 return err; |
148} 149 | 142} 143 |
150static void echainiv_free(struct crypto_instance *inst) 151{ 152 aead_geniv_free(aead_instance(inst)); 153} 154 | |
155static struct crypto_template echainiv_tmpl = { 156 .name = "echainiv", 157 .create = echainiv_aead_create, | 144static struct crypto_template echainiv_tmpl = { 145 .name = "echainiv", 146 .create = echainiv_aead_create, |
158 .free = echainiv_free, | |
159 .module = THIS_MODULE, 160}; 161 162static int __init echainiv_module_init(void) 163{ 164 return crypto_register_template(&echainiv_tmpl); 165} 166 167static void __exit echainiv_module_exit(void) 168{ 169 crypto_unregister_template(&echainiv_tmpl); 170} 171 172subsys_initcall(echainiv_module_init); 173module_exit(echainiv_module_exit); 174 175MODULE_LICENSE("GPL"); 176MODULE_DESCRIPTION("Encrypted Chain IV Generator"); 177MODULE_ALIAS_CRYPTO("echainiv"); | 147 .module = THIS_MODULE, 148}; 149 150static int __init echainiv_module_init(void) 151{ 152 return crypto_register_template(&echainiv_tmpl); 153} 154 155static void __exit echainiv_module_exit(void) 156{ 157 crypto_unregister_template(&echainiv_tmpl); 158} 159 160subsys_initcall(echainiv_module_init); 161module_exit(echainiv_module_exit); 162 163MODULE_LICENSE("GPL"); 164MODULE_DESCRIPTION("Encrypted Chain IV Generator"); 165MODULE_ALIAS_CRYPTO("echainiv"); |