Lines Matching +full:data +full:- +full:size

1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * AEAD: Authenticated Encryption with Associated Data
5 * Copyright (c) 2007-2015 Herbert Xu <herbert@gondor.apana.org.au>
17 * DOC: Authenticated Encryption With Associated Data (AEAD) Cipher API
34 * pointer to the associated data memory location before performing the
36 * data memory is filled during the encryption operation. For decryption, the
37 * associated data memory must contain data that is used to verify the integrity
38 * of the decrypted data. Another deviation from the asynchronous block cipher
39 * operation is that the caller should explicitly check for -EBADMSG of the
41 * a breach in the integrity of the message. In essence, that -EBADMSG error
48 * associated data || plaintext or ciphertext.
51 * (resp. ciphertext) will grow (resp. shrink) by the authentication tag size
54 * In-place encryption/decryption is enabled by using the same scatterlist
57 * Even in the out-of-place case, space must be reserved in the destination for
58 * the associated data, even though it won't be written to. This makes the
59 * in-place and out-of-place cases more consistent. It is permissible for the
60 * "destination" associated data to alias the "source" associated data.
62 * As with the other scatterlist crypto APIs, zero-length scatterlist elements
64 * associated data, the first element must point to the plaintext/ciphertext.
68 * of the associated data buffer must contain a second copy of the IV. This is
72 * treat the IV as associated data; nevertheless the length passed to
80 * struct aead_request - AEAD request
82 * @assoclen: Length in bytes of associated data for authentication
83 * @cryptlen: Length of data to be encrypted or decrypted
85 * @src: Source data
86 * @dst: Destination data
87 * @__ctx: Start of private context data
104 * struct aead_alg - AEAD cipher definition
105 * @maxauthsize: Set the maximum authentication tag size supported by the
108 * integrity of the encrypted data, a consumer typically wants the
111 * @setauthsize: Set authentication size for the AEAD transformation. This
112 * function is used to specify the consumer requested size of the
114 * during encryption or the size of the authentication tag to be
116 * responsible for checking the authentication tag size for
167 * crypto_alloc_aead() - allocate AEAD cipher handle
184 return &tfm->base; in crypto_aead_tfm()
188 * crypto_free_aead() - zeroize and free aead handle
205 return container_of(crypto_aead_tfm(tfm)->__crt_alg, in crypto_aead_alg()
211 return alg->ivsize; in crypto_aead_alg_ivsize()
215 * crypto_aead_ivsize() - obtain IV size
218 * The size of the IV for the aead referenced by the cipher handle is
219 * returned. This IV size may be zero if the cipher does not need an IV.
221 * Return: IV size in bytes
229 * crypto_aead_authsize() - obtain maximum authentication data size
232 * The maximum size of the authentication data for the AEAD cipher referenced
233 * by the AEAD cipher handle is returned. The authentication data size may be
234 * zero if the cipher implements a hard-coded maximum.
236 * The authentication data may also be known as "tag value".
238 * Return: authentication data size / tag size in bytes
242 return tfm->authsize; in crypto_aead_authsize()
247 return alg->maxauthsize; in crypto_aead_alg_maxauthsize()
256 * crypto_aead_blocksize() - obtain block size of cipher
259 * The block size for the AEAD referenced with the cipher handle is returned.
261 * data returned by the encryption or decryption operation
263 * Return: block size of cipher
291 * crypto_aead_setkey() - set key for cipher
300 * different cipher modes depending on the key size, such as AES-128 vs AES-192
301 * vs. AES-256. When providing a 16 byte key for an AES cipher handle, AES-128
310 * crypto_aead_setauthsize() - set authentication data size
312 * @authsize: size of the authentication data / tag in bytes
314 * Set the authentication data size / tag size. AEAD requires an authentication
315 * tag (or MAC) in addition to the associated data.
323 return __crypto_aead_cast(req->base.tfm); in crypto_aead_reqtfm()
327 * crypto_aead_encrypt() - encrypt plaintext
331 * Encrypt plaintext data using the aead_request handle. That data structure
332 * and how it is filled with data is discussed with the aead_request_*
335 * IMPORTANT NOTE The encryption operation creates the authentication data /
336 * tag. That data is concatenated with the created ciphertext.
337 * The ciphertext memory size is therefore the given number of
338 * block cipher blocks + the size defined by the
348 * crypto_aead_decrypt() - decrypt ciphertext
352 * Decrypt ciphertext data using the aead_request handle. That data structure
353 * and how it is filled with data is discussed with the aead_request_*
357 * authentication data / tag. That authentication data / tag
358 * must have the size defined by the crypto_aead_setauthsize
362 * Return: 0 if the cipher operation was successful; -EBADMSG: The AEAD
363 * cipher operation performs the authentication of the data during the
366 * integrity of the ciphertext or the associated data was violated);
374 * The aead_request data structure contains all pointers to data required for
383 * crypto_aead_reqsize() - obtain size of the request data structure
390 return tfm->reqsize; in crypto_aead_reqsize()
394 * aead_request_set_tfm() - update cipher handle reference in request
399 * data structure with a different one.
404 req->base.tfm = crypto_aead_tfm(tfm); in aead_request_set_tfm()
408 * aead_request_alloc() - allocate request data structure
412 * Allocate the request data structure that must be used with the AEAD
414 * handle is registered in the request data structure.
432 * aead_request_free() - zeroize and free request data structure
433 * @req: request data structure cipher handle to be freed
441 * aead_request_set_callback() - set asynchronous callback function
445 * increase the wait queue beyond the initial maximum size;
448 * @data: The data pointer refers to memory that is not used by the kernel
452 * related functionality, it may need to access data structures of the
454 * callback function can access the memory via the "data" field in the
455 * crypto_async_request data structure provided to the callback function.
468 void *data) in aead_request_set_callback() argument
470 req->base.complete = compl; in aead_request_set_callback()
471 req->base.data = data; in aead_request_set_callback()
472 req->base.flags = flags; in aead_request_set_callback()
476 * aead_request_set_crypt - set data buffers
481 * @iv: IV for the cipher operation which must comply with the IV size defined
484 * Setting the source data and destination data scatter / gather lists which
485 * hold the associated data concatenated with the plaintext or ciphertext. See
490 * reversed - the source is the ciphertext and the destination is the plaintext.
494 * - AEAD encryption input: assoc data || plaintext
495 * - AEAD encryption output: assoc data || ciphertext || auth tag
496 * - AEAD decryption input: assoc data || ciphertext || auth tag
497 * - AEAD decryption output: assoc data || plaintext
501 * caller wants to have that data buffer filled, the caller must either
502 * use an in-place cipher operation (i.e. same memory location for
510 req->src = src; in aead_request_set_crypt()
511 req->dst = dst; in aead_request_set_crypt()
512 req->cryptlen = cryptlen; in aead_request_set_crypt()
513 req->iv = iv; in aead_request_set_crypt()
517 * aead_request_set_ad - set associated data information
519 * @assoclen: number of bytes in associated data
522 * the associated data.
527 req->assoclen = assoclen; in aead_request_set_ad()