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>
16 * DOC: Authenticated Encryption With Associated Data (AEAD) Cipher API
33 * pointer to the associated data memory location before performing the
35 * data memory is filled during the encryption operation. For decryption, the
36 * associated data memory must contain data that is used to verify the integrity
37 * of the decrypted data. Another deviation from the asynchronous block cipher
38 * operation is that the caller should explicitly check for -EBADMSG of the
40 * a breach in the integrity of the message. In essence, that -EBADMSG error
47 * associated data || plaintext or ciphertext.
50 * (resp. ciphertext) will grow (resp. shrink) by the authentication tag size
53 * In-place encryption/decryption is enabled by using the same scatterlist
56 * Even in the out-of-place case, space must be reserved in the destination for
57 * the associated data, even though it won't be written to. This makes the
58 * in-place and out-of-place cases more consistent. It is permissible for the
59 * "destination" associated data to alias the "source" associated data.
61 * As with the other scatterlist crypto APIs, zero-length scatterlist elements
63 * associated data, the first element must point to the plaintext/ciphertext.
67 * of the associated data buffer must contain a second copy of the IV. This is
71 * treat the IV as associated data; nevertheless the length passed to
78 * struct aead_request - AEAD request
80 * @assoclen: Length in bytes of associated data for authentication
81 * @cryptlen: Length of data to be encrypted or decrypted
83 * @src: Source data
84 * @dst: Destination data
85 * @__ctx: Start of private context data
102 * struct aead_alg - AEAD cipher definition
103 * @maxauthsize: Set the maximum authentication tag size supported by the
106 * integrity of the encrypted data, a consumer typically wants the
109 * @setauthsize: Set authentication size for the AEAD transformation. This
110 * function is used to specify the consumer requested size of the
112 * during encryption or the size of the authentication tag to be
114 * responsible for checking the authentication tag size for
165 * crypto_alloc_aead() - allocate AEAD cipher handle
182 return &tfm->base; in crypto_aead_tfm()
186 * crypto_free_aead() - zeroize and free aead handle
203 return container_of(crypto_aead_tfm(tfm)->__crt_alg, in crypto_aead_alg()
209 return alg->ivsize; in crypto_aead_alg_ivsize()
213 * crypto_aead_ivsize() - obtain IV size
216 * The size of the IV for the aead referenced by the cipher handle is
217 * returned. This IV size may be zero if the cipher does not need an IV.
219 * Return: IV size in bytes
227 * crypto_aead_authsize() - obtain maximum authentication data size
230 * The maximum size of the authentication data for the AEAD cipher referenced
231 * by the AEAD cipher handle is returned. The authentication data size may be
232 * zero if the cipher implements a hard-coded maximum.
234 * The authentication data may also be known as "tag value".
236 * Return: authentication data size / tag size in bytes
240 return tfm->authsize; in crypto_aead_authsize()
245 return alg->maxauthsize; in crypto_aead_alg_maxauthsize()
254 * crypto_aead_blocksize() - obtain block size of cipher
257 * The block size for the AEAD referenced with the cipher handle is returned.
259 * data returned by the encryption or decryption operation
261 * Return: block size of cipher
289 * crypto_aead_setkey() - set key for cipher
298 * different cipher modes depending on the key size, such as AES-128 vs AES-192
299 * vs. AES-256. When providing a 16 byte key for an AES cipher handle, AES-128
308 * crypto_aead_setauthsize() - set authentication data size
310 * @authsize: size of the authentication data / tag in bytes
312 * Set the authentication data size / tag size. AEAD requires an authentication
313 * tag (or MAC) in addition to the associated data.
321 return __crypto_aead_cast(req->base.tfm); in crypto_aead_reqtfm()
325 * crypto_aead_encrypt() - encrypt plaintext
329 * Encrypt plaintext data using the aead_request handle. That data structure
330 * and how it is filled with data is discussed with the aead_request_*
333 * IMPORTANT NOTE The encryption operation creates the authentication data /
334 * tag. That data is concatenated with the created ciphertext.
335 * The ciphertext memory size is therefore the given number of
336 * block cipher blocks + the size defined by the
346 * crypto_aead_decrypt() - decrypt ciphertext
350 * Decrypt ciphertext data using the aead_request handle. That data structure
351 * and how it is filled with data is discussed with the aead_request_*
355 * authentication data / tag. That authentication data / tag
356 * must have the size defined by the crypto_aead_setauthsize
360 * Return: 0 if the cipher operation was successful; -EBADMSG: The AEAD
361 * cipher operation performs the authentication of the data during the
364 * integrity of the ciphertext or the associated data was violated);
372 * The aead_request data structure contains all pointers to data required for
381 * crypto_aead_reqsize() - obtain size of the request data structure
388 return tfm->reqsize; in crypto_aead_reqsize()
392 * aead_request_set_tfm() - update cipher handle reference in request
397 * data structure with a different one.
402 req->base.tfm = crypto_aead_tfm(tfm); in aead_request_set_tfm()
406 * aead_request_alloc() - allocate request data structure
410 * Allocate the request data structure that must be used with the AEAD
412 * handle is registered in the request data structure.
430 * aead_request_free() - zeroize and free request data structure
431 * @req: request data structure cipher handle to be freed
439 * aead_request_set_callback() - set asynchronous callback function
443 * increase the wait queue beyond the initial maximum size;
446 * @data: The data pointer refers to memory that is not used by the kernel
450 * related functionality, it may need to access data structures of the
452 * callback function can access the memory via the "data" field in the
453 * crypto_async_request data structure provided to the callback function.
466 void *data) in aead_request_set_callback() argument
468 req->base.complete = compl; in aead_request_set_callback()
469 req->base.data = data; in aead_request_set_callback()
470 req->base.flags = flags; in aead_request_set_callback()
474 * aead_request_set_crypt - set data buffers
479 * @iv: IV for the cipher operation which must comply with the IV size defined
482 * Setting the source data and destination data scatter / gather lists which
483 * hold the associated data concatenated with the plaintext or ciphertext. See
488 * reversed - the source is the ciphertext and the destination is the plaintext.
492 * - AEAD encryption input: assoc data || plaintext
493 * - AEAD encryption output: assoc data || ciphertext || auth tag
494 * - AEAD decryption input: assoc data || ciphertext || auth tag
495 * - AEAD decryption output: assoc data || plaintext
499 * caller wants to have that data buffer filled, the caller must either
500 * use an in-place cipher operation (i.e. same memory location for
508 req->src = src; in aead_request_set_crypt()
509 req->dst = dst; in aead_request_set_crypt()
510 req->cryptlen = cryptlen; in aead_request_set_crypt()
511 req->iv = iv; in aead_request_set_crypt()
515 * aead_request_set_ad - set associated data information
517 * @assoclen: number of bytes in associated data
520 * the associated data.
525 req->assoclen = assoclen; in aead_request_set_ad()