Lines Matching refs:cipher_ctx
106 struct cipher_ctx { struct
208 struct cipher_ctx *cipher_ctx = in cipher_init() local
209 (struct cipher_ctx *)EVP_CIPHER_CTX_get_cipher_data(ctx); in cipher_init()
215 if (cipher_ctx->sess.ses != 0 && in cipher_init()
216 clean_devcrypto_session(&cipher_ctx->sess) == 0) in cipher_init()
219 cipher_ctx->sess.cipher = cipher_d->devcryptoid; in cipher_init()
220 cipher_ctx->sess.keylen = cipher_d->keylen; in cipher_init()
221 cipher_ctx->sess.key = (void *)key; in cipher_init()
222 cipher_ctx->op = enc ? COP_ENCRYPT : COP_DECRYPT; in cipher_init()
223 cipher_ctx->mode = cipher_d->flags & EVP_CIPH_MODE; in cipher_init()
224 cipher_ctx->blocksize = cipher_d->blocksize; in cipher_init()
226 cipher_ctx->sess.crid = (use_softdrivers == DEVCRYPTO_USE_SOFTWARE) ? in cipher_init()
229 ret = ioctl(cfd, CIOCGSESSION2, &cipher_ctx->sess); in cipher_init()
231 ret = ioctl(cfd, CIOCGSESSION, &cipher_ctx->sess); in cipher_init()
244 struct cipher_ctx *cipher_ctx = in cipher_do_cipher() local
245 (struct cipher_ctx *)EVP_CIPHER_CTX_get_cipher_data(ctx); in cipher_do_cipher()
255 cryp.ses = cipher_ctx->sess.ses; in cipher_do_cipher()
260 cryp.op = cipher_ctx->op; in cipher_do_cipher()
266 switch (cipher_ctx->mode) { in cipher_do_cipher()
292 switch (cipher_ctx->mode) { in cipher_do_cipher()
304 nblocks = (inl + cipher_ctx->blocksize - 1) in cipher_do_cipher()
305 / cipher_ctx->blocksize; in cipher_do_cipher()
325 struct cipher_ctx *cipher_ctx = in ctr_do_cipher() local
326 (struct cipher_ctx *)EVP_CIPHER_CTX_get_cipher_data(ctx); in ctr_do_cipher()
330 while (cipher_ctx->num && inl) { in ctr_do_cipher()
331 (*out++) = *(in++) ^ cipher_ctx->partial[cipher_ctx->num]; in ctr_do_cipher()
333 cipher_ctx->num = (cipher_ctx->num + 1) % cipher_ctx->blocksize; in ctr_do_cipher()
337 if (inl > cipher_ctx->blocksize) { in ctr_do_cipher()
338 nblocks = inl/cipher_ctx->blocksize; in ctr_do_cipher()
339 len = nblocks * cipher_ctx->blocksize; in ctr_do_cipher()
349 memset(cipher_ctx->partial, 0, cipher_ctx->blocksize); in ctr_do_cipher()
350 if (cipher_do_cipher(ctx, cipher_ctx->partial, cipher_ctx->partial, in ctr_do_cipher()
351 cipher_ctx->blocksize) < 1) in ctr_do_cipher()
354 out[cipher_ctx->num] = in[cipher_ctx->num] in ctr_do_cipher()
355 ^ cipher_ctx->partial[cipher_ctx->num]; in ctr_do_cipher()
356 cipher_ctx->num++; in ctr_do_cipher()
365 struct cipher_ctx *cipher_ctx = in cipher_ctrl() local
366 (struct cipher_ctx *)EVP_CIPHER_CTX_get_cipher_data(ctx); in cipher_ctrl()
368 struct cipher_ctx *to_cipher_ctx; in cipher_ctrl()
373 if (cipher_ctx == NULL) in cipher_ctrl()
377 (struct cipher_ctx *)EVP_CIPHER_CTX_get_cipher_data(to_ctx); in cipher_ctrl()
379 return cipher_init(to_ctx, (void *)cipher_ctx->sess.key, EVP_CIPHER_CTX_iv(ctx), in cipher_ctrl()
380 (cipher_ctx->op == COP_ENCRYPT)); in cipher_ctrl()
383 memset(&cipher_ctx->sess, 0, sizeof(cipher_ctx->sess)); in cipher_ctrl()
395 struct cipher_ctx *cipher_ctx = in cipher_cleanup() local
396 (struct cipher_ctx *)EVP_CIPHER_CTX_get_cipher_data(ctx); in cipher_cleanup()
398 return clean_devcrypto_session(&cipher_ctx->sess); in cipher_cleanup()
499 sizeof(struct cipher_ctx))) { in prepare_cipher_methods()