Lines Matching refs:actx
77 static int afalg_create_sk(afalg_ctx *actx, const char *ciphertype,
427 static ossl_inline int afalg_set_key(afalg_ctx *actx, const unsigned char *key, in afalg_set_key() argument
431 ret = setsockopt(actx->bfd, SOL_ALG, ALG_SET_KEY, key, klen); in afalg_set_key()
440 static int afalg_create_sk(afalg_ctx *actx, const char *ciphertype, in afalg_create_sk() argument
446 actx->bfd = actx->sfd = -1; in afalg_create_sk()
453 actx->bfd = socket(AF_ALG, SOCK_SEQPACKET, 0); in afalg_create_sk()
454 if (actx->bfd == -1) { in afalg_create_sk()
460 r = bind(actx->bfd, (struct sockaddr *)&sa, sizeof(sa)); in afalg_create_sk()
467 actx->sfd = accept(actx->bfd, NULL, 0); in afalg_create_sk()
468 if (actx->sfd < 0) { in afalg_create_sk()
477 if (actx->bfd >= 0) in afalg_create_sk()
478 close(actx->bfd); in afalg_create_sk()
479 if (actx->sfd >= 0) in afalg_create_sk()
480 close(actx->sfd); in afalg_create_sk()
481 actx->bfd = actx->sfd = -1; in afalg_create_sk()
485 static int afalg_start_cipher_sk(afalg_ctx *actx, const unsigned char *in, in afalg_start_cipher_sk() argument
530 sbytes = sendmsg(actx->sfd, &msg, 0); in afalg_start_cipher_sk()
541 ret = vmsplice(actx->zc_pipe[1], &iov, 1, SPLICE_F_GIFT); in afalg_start_cipher_sk()
547 ret = splice(actx->zc_pipe[0], NULL, actx->sfd, NULL, inl, 0); in afalg_start_cipher_sk()
557 sbytes = sendmsg(actx->sfd, &msg, 0); in afalg_start_cipher_sk()
579 afalg_ctx *actx; in afalg_cipher_init() local
592 actx = EVP_CIPHER_CTX_get_cipher_data(ctx); in afalg_cipher_init()
593 if (actx == NULL) { in afalg_cipher_init()
618 ret = afalg_create_sk(actx, "skcipher", ciphername); in afalg_cipher_init()
624 ret = afalg_set_key(actx, key, len); in afalg_cipher_init()
629 if (afalg_init_aio(&actx->aio) == 0) in afalg_cipher_init()
633 pipe(actx->zc_pipe); in afalg_cipher_init()
636 actx->init_done = MAGIC_INIT_NUM; in afalg_cipher_init()
641 close(actx->sfd); in afalg_cipher_init()
642 close(actx->bfd); in afalg_cipher_init()
649 afalg_ctx *actx; in afalg_do_cipher() local
659 actx = (afalg_ctx *) EVP_CIPHER_CTX_get_cipher_data(ctx); in afalg_do_cipher()
660 if (actx == NULL || actx->init_done != MAGIC_INIT_NUM) { in afalg_do_cipher()
675 ret = afalg_start_cipher_sk(actx, (unsigned char *)in, inl, in afalg_do_cipher()
683 ret = afalg_fin_cipher_aio(&actx->aio, actx->sfd, out, inl); in afalg_do_cipher()
699 afalg_ctx *actx; in afalg_cipher_cleanup() local
707 actx = (afalg_ctx *) EVP_CIPHER_CTX_get_cipher_data(ctx); in afalg_cipher_cleanup()
708 if (actx == NULL || actx->init_done != MAGIC_INIT_NUM) in afalg_cipher_cleanup()
711 close(actx->sfd); in afalg_cipher_cleanup()
712 close(actx->bfd); in afalg_cipher_cleanup()
714 close(actx->zc_pipe[0]); in afalg_cipher_cleanup()
715 close(actx->zc_pipe[1]); in afalg_cipher_cleanup()
718 if (actx->aio.mode == MODE_SYNC) in afalg_cipher_cleanup()
719 close(actx->aio.efd); in afalg_cipher_cleanup()
720 io_destroy(actx->aio.aio_ctx); in afalg_cipher_cleanup()