algif_aead.c (8e1fa89aa8bc2870009b4486644e4a58f2e2a4f5) | algif_aead.c (7d2c3f54e6f646887d019faa45f35d6fe9fe82ce) |
---|---|
1/* 2 * algif_aead: User-space interface for AEAD algorithms 3 * 4 * Copyright (C) 2014, Stephan Mueller <smueller@chronox.de> 5 * 6 * This file provides the user-space API for AEAD ciphers. 7 * 8 * This program is free software; you can redistribute it and/or modify it --- 269 unchanged lines hidden (view full) --- 278 /* Initialize the crypto operation */ 279 aead_request_set_crypt(&areq->cra_u.aead_req, rsgl_src, 280 areq->first_rsgl.sgl.sg, used, ctx->iv); 281 aead_request_set_ad(&areq->cra_u.aead_req, ctx->aead_assoclen); 282 aead_request_set_tfm(&areq->cra_u.aead_req, tfm); 283 284 if (msg->msg_iocb && !is_sync_kiocb(msg->msg_iocb)) { 285 /* AIO operation */ | 1/* 2 * algif_aead: User-space interface for AEAD algorithms 3 * 4 * Copyright (C) 2014, Stephan Mueller <smueller@chronox.de> 5 * 6 * This file provides the user-space API for AEAD ciphers. 7 * 8 * This program is free software; you can redistribute it and/or modify it --- 269 unchanged lines hidden (view full) --- 278 /* Initialize the crypto operation */ 279 aead_request_set_crypt(&areq->cra_u.aead_req, rsgl_src, 280 areq->first_rsgl.sgl.sg, used, ctx->iv); 281 aead_request_set_ad(&areq->cra_u.aead_req, ctx->aead_assoclen); 282 aead_request_set_tfm(&areq->cra_u.aead_req, tfm); 283 284 if (msg->msg_iocb && !is_sync_kiocb(msg->msg_iocb)) { 285 /* AIO operation */ |
286 sock_hold(sk); |
|
286 areq->iocb = msg->msg_iocb; 287 aead_request_set_callback(&areq->cra_u.aead_req, 288 CRYPTO_TFM_REQ_MAY_BACKLOG, 289 af_alg_async_cb, areq); 290 err = ctx->enc ? crypto_aead_encrypt(&areq->cra_u.aead_req) : 291 crypto_aead_decrypt(&areq->cra_u.aead_req); | 287 areq->iocb = msg->msg_iocb; 288 aead_request_set_callback(&areq->cra_u.aead_req, 289 CRYPTO_TFM_REQ_MAY_BACKLOG, 290 af_alg_async_cb, areq); 291 err = ctx->enc ? crypto_aead_encrypt(&areq->cra_u.aead_req) : 292 crypto_aead_decrypt(&areq->cra_u.aead_req); |
293 294 /* AIO operation in progress */ 295 if (err == -EINPROGRESS || err == -EBUSY) { 296 /* Remember output size that will be generated. */ 297 areq->outlen = outlen; 298 299 return -EIOCBQUEUED; 300 } 301 302 sock_put(sk); |
|
292 } else { 293 /* Synchronous operation */ 294 aead_request_set_callback(&areq->cra_u.aead_req, 295 CRYPTO_TFM_REQ_MAY_BACKLOG, 296 crypto_req_done, &ctx->wait); 297 err = crypto_wait_req(ctx->enc ? 298 crypto_aead_encrypt(&areq->cra_u.aead_req) : 299 crypto_aead_decrypt(&areq->cra_u.aead_req), 300 &ctx->wait); 301 } 302 | 303 } else { 304 /* Synchronous operation */ 305 aead_request_set_callback(&areq->cra_u.aead_req, 306 CRYPTO_TFM_REQ_MAY_BACKLOG, 307 crypto_req_done, &ctx->wait); 308 err = crypto_wait_req(ctx->enc ? 309 crypto_aead_encrypt(&areq->cra_u.aead_req) : 310 crypto_aead_decrypt(&areq->cra_u.aead_req), 311 &ctx->wait); 312 } 313 |
303 /* AIO operation in progress */ 304 if (err == -EINPROGRESS) { 305 sock_hold(sk); | |
306 | 314 |
307 /* Remember output size that will be generated. */ 308 areq->outlen = outlen; 309 310 return -EIOCBQUEUED; 311 } 312 | |
313free: | 315free: |
314 af_alg_free_areq_sgls(areq); 315 sock_kfree_s(sk, areq, areq->areqlen); | 316 af_alg_free_resources(areq); |
316 317 return err ? err : outlen; 318} 319 320static int aead_recvmsg(struct socket *sock, struct msghdr *msg, 321 size_t ignored, int flags) 322{ 323 struct sock *sk = sock->sk; --- 296 unchanged lines hidden --- | 317 318 return err ? err : outlen; 319} 320 321static int aead_recvmsg(struct socket *sock, struct msghdr *msg, 322 size_t ignored, int flags) 323{ 324 struct sock *sk = sock->sk; --- 296 unchanged lines hidden --- |