aead.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630
  1. /*
  2. * AEAD: Authenticated Encryption with Associated Data
  3. *
  4. * Copyright (c) 2007 Herbert Xu <herbert@gondor.apana.org.au>
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License as published by the Free
  8. * Software Foundation; either version 2 of the License, or (at your option)
  9. * any later version.
  10. *
  11. */
  12. #ifndef _CRYPTO_AEAD_H
  13. #define _CRYPTO_AEAD_H
  14. #include <linux/crypto.h>
  15. #include <linux/kernel.h>
  16. #include <linux/slab.h>
  17. /**
  18. * DOC: Authenticated Encryption With Associated Data (AEAD) Cipher API
  19. *
  20. * The AEAD cipher API is used with the ciphers of type CRYPTO_ALG_TYPE_AEAD
  21. * (listed as type "aead" in /proc/crypto)
  22. *
  23. * The most prominent examples for this type of encryption is GCM and CCM.
  24. * However, the kernel supports other types of AEAD ciphers which are defined
  25. * with the following cipher string:
  26. *
  27. * authenc(keyed message digest, block cipher)
  28. *
  29. * For example: authenc(hmac(sha256), cbc(aes))
  30. *
  31. * The example code provided for the asynchronous block cipher operation
  32. * applies here as well. Naturally all *ablkcipher* symbols must be exchanged
  33. * the *aead* pendants discussed in the following. In addition, for the AEAD
  34. * operation, the aead_request_set_assoc function must be used to set the
  35. * pointer to the associated data memory location before performing the
  36. * encryption or decryption operation. In case of an encryption, the associated
  37. * data memory is filled during the encryption operation. For decryption, the
  38. * associated data memory must contain data that is used to verify the integrity
  39. * of the decrypted data. Another deviation from the asynchronous block cipher
  40. * operation is that the caller should explicitly check for -EBADMSG of the
  41. * crypto_aead_decrypt. That error indicates an authentication error, i.e.
  42. * a breach in the integrity of the message. In essence, that -EBADMSG error
  43. * code is the key bonus an AEAD cipher has over "standard" block chaining
  44. * modes.
  45. */
  46. /**
  47. * struct aead_request - AEAD request
  48. * @base: Common attributes for async crypto requests
  49. * @old: Boolean whether the old or new AEAD API is used
  50. * @assoclen: Length in bytes of associated data for authentication
  51. * @cryptlen: Length of data to be encrypted or decrypted
  52. * @iv: Initialisation vector
  53. * @assoc: Associated data
  54. * @src: Source data
  55. * @dst: Destination data
  56. * @__ctx: Start of private context data
  57. */
  58. struct aead_request {
  59. struct crypto_async_request base;
  60. bool old;
  61. unsigned int assoclen;
  62. unsigned int cryptlen;
  63. u8 *iv;
  64. struct scatterlist *assoc;
  65. struct scatterlist *src;
  66. struct scatterlist *dst;
  67. void *__ctx[] CRYPTO_MINALIGN_ATTR;
  68. };
  69. /**
  70. * struct aead_givcrypt_request - AEAD request with IV generation
  71. * @seq: Sequence number for IV generation
  72. * @giv: Space for generated IV
  73. * @areq: The AEAD request itself
  74. */
  75. struct aead_givcrypt_request {
  76. u64 seq;
  77. u8 *giv;
  78. struct aead_request areq;
  79. };
  80. /**
  81. * struct aead_alg - AEAD cipher definition
  82. * @maxauthsize: Set the maximum authentication tag size supported by the
  83. * transformation. A transformation may support smaller tag sizes.
  84. * As the authentication tag is a message digest to ensure the
  85. * integrity of the encrypted data, a consumer typically wants the
  86. * largest authentication tag possible as defined by this
  87. * variable.
  88. * @setauthsize: Set authentication size for the AEAD transformation. This
  89. * function is used to specify the consumer requested size of the
  90. * authentication tag to be either generated by the transformation
  91. * during encryption or the size of the authentication tag to be
  92. * supplied during the decryption operation. This function is also
  93. * responsible for checking the authentication tag size for
  94. * validity.
  95. * @setkey: see struct ablkcipher_alg
  96. * @encrypt: see struct ablkcipher_alg
  97. * @decrypt: see struct ablkcipher_alg
  98. * @geniv: see struct ablkcipher_alg
  99. * @ivsize: see struct ablkcipher_alg
  100. * @init: Initialize the cryptographic transformation object. This function
  101. * is used to initialize the cryptographic transformation object.
  102. * This function is called only once at the instantiation time, right
  103. * after the transformation context was allocated. In case the
  104. * cryptographic hardware has some special requirements which need to
  105. * be handled by software, this function shall check for the precise
  106. * requirement of the transformation and put any software fallbacks
  107. * in place.
  108. * @exit: Deinitialize the cryptographic transformation object. This is a
  109. * counterpart to @init, used to remove various changes set in
  110. * @init.
  111. *
  112. * All fields except @ivsize is mandatory and must be filled.
  113. */
  114. struct aead_alg {
  115. int (*setkey)(struct crypto_aead *tfm, const u8 *key,
  116. unsigned int keylen);
  117. int (*setauthsize)(struct crypto_aead *tfm, unsigned int authsize);
  118. int (*encrypt)(struct aead_request *req);
  119. int (*decrypt)(struct aead_request *req);
  120. int (*init)(struct crypto_aead *tfm);
  121. void (*exit)(struct crypto_aead *tfm);
  122. const char *geniv;
  123. unsigned int ivsize;
  124. unsigned int maxauthsize;
  125. struct crypto_alg base;
  126. };
  127. struct crypto_aead {
  128. int (*setkey)(struct crypto_aead *tfm, const u8 *key,
  129. unsigned int keylen);
  130. int (*setauthsize)(struct crypto_aead *tfm, unsigned int authsize);
  131. int (*encrypt)(struct aead_request *req);
  132. int (*decrypt)(struct aead_request *req);
  133. int (*givencrypt)(struct aead_givcrypt_request *req);
  134. int (*givdecrypt)(struct aead_givcrypt_request *req);
  135. struct crypto_aead *child;
  136. unsigned int authsize;
  137. unsigned int reqsize;
  138. struct crypto_tfm base;
  139. };
  140. static inline struct crypto_aead *__crypto_aead_cast(struct crypto_tfm *tfm)
  141. {
  142. return container_of(tfm, struct crypto_aead, base);
  143. }
  144. /**
  145. * crypto_alloc_aead() - allocate AEAD cipher handle
  146. * @alg_name: is the cra_name / name or cra_driver_name / driver name of the
  147. * AEAD cipher
  148. * @type: specifies the type of the cipher
  149. * @mask: specifies the mask for the cipher
  150. *
  151. * Allocate a cipher handle for an AEAD. The returned struct
  152. * crypto_aead is the cipher handle that is required for any subsequent
  153. * API invocation for that AEAD.
  154. *
  155. * Return: allocated cipher handle in case of success; IS_ERR() is true in case
  156. * of an error, PTR_ERR() returns the error code.
  157. */
  158. struct crypto_aead *crypto_alloc_aead(const char *alg_name, u32 type, u32 mask);
  159. static inline struct crypto_tfm *crypto_aead_tfm(struct crypto_aead *tfm)
  160. {
  161. return &tfm->base;
  162. }
  163. /**
  164. * crypto_free_aead() - zeroize and free aead handle
  165. * @tfm: cipher handle to be freed
  166. */
  167. static inline void crypto_free_aead(struct crypto_aead *tfm)
  168. {
  169. crypto_destroy_tfm(tfm, crypto_aead_tfm(tfm));
  170. }
  171. static inline struct crypto_aead *crypto_aead_crt(struct crypto_aead *tfm)
  172. {
  173. return tfm;
  174. }
  175. static inline struct old_aead_alg *crypto_old_aead_alg(struct crypto_aead *tfm)
  176. {
  177. return &crypto_aead_tfm(tfm)->__crt_alg->cra_aead;
  178. }
  179. static inline struct aead_alg *crypto_aead_alg(struct crypto_aead *tfm)
  180. {
  181. return container_of(crypto_aead_tfm(tfm)->__crt_alg,
  182. struct aead_alg, base);
  183. }
  184. static inline unsigned int crypto_aead_alg_ivsize(struct aead_alg *alg)
  185. {
  186. return alg->base.cra_aead.encrypt ? alg->base.cra_aead.ivsize :
  187. alg->ivsize;
  188. }
  189. /**
  190. * crypto_aead_ivsize() - obtain IV size
  191. * @tfm: cipher handle
  192. *
  193. * The size of the IV for the aead referenced by the cipher handle is
  194. * returned. This IV size may be zero if the cipher does not need an IV.
  195. *
  196. * Return: IV size in bytes
  197. */
  198. static inline unsigned int crypto_aead_ivsize(struct crypto_aead *tfm)
  199. {
  200. return crypto_aead_alg_ivsize(crypto_aead_alg(tfm));
  201. }
  202. /**
  203. * crypto_aead_authsize() - obtain maximum authentication data size
  204. * @tfm: cipher handle
  205. *
  206. * The maximum size of the authentication data for the AEAD cipher referenced
  207. * by the AEAD cipher handle is returned. The authentication data size may be
  208. * zero if the cipher implements a hard-coded maximum.
  209. *
  210. * The authentication data may also be known as "tag value".
  211. *
  212. * Return: authentication data size / tag size in bytes
  213. */
  214. static inline unsigned int crypto_aead_authsize(struct crypto_aead *tfm)
  215. {
  216. return tfm->authsize;
  217. }
  218. /**
  219. * crypto_aead_blocksize() - obtain block size of cipher
  220. * @tfm: cipher handle
  221. *
  222. * The block size for the AEAD referenced with the cipher handle is returned.
  223. * The caller may use that information to allocate appropriate memory for the
  224. * data returned by the encryption or decryption operation
  225. *
  226. * Return: block size of cipher
  227. */
  228. static inline unsigned int crypto_aead_blocksize(struct crypto_aead *tfm)
  229. {
  230. return crypto_tfm_alg_blocksize(crypto_aead_tfm(tfm));
  231. }
  232. static inline unsigned int crypto_aead_alignmask(struct crypto_aead *tfm)
  233. {
  234. return crypto_tfm_alg_alignmask(crypto_aead_tfm(tfm));
  235. }
  236. static inline u32 crypto_aead_get_flags(struct crypto_aead *tfm)
  237. {
  238. return crypto_tfm_get_flags(crypto_aead_tfm(tfm));
  239. }
  240. static inline void crypto_aead_set_flags(struct crypto_aead *tfm, u32 flags)
  241. {
  242. crypto_tfm_set_flags(crypto_aead_tfm(tfm), flags);
  243. }
  244. static inline void crypto_aead_clear_flags(struct crypto_aead *tfm, u32 flags)
  245. {
  246. crypto_tfm_clear_flags(crypto_aead_tfm(tfm), flags);
  247. }
  248. /**
  249. * crypto_aead_setkey() - set key for cipher
  250. * @tfm: cipher handle
  251. * @key: buffer holding the key
  252. * @keylen: length of the key in bytes
  253. *
  254. * The caller provided key is set for the AEAD referenced by the cipher
  255. * handle.
  256. *
  257. * Note, the key length determines the cipher type. Many block ciphers implement
  258. * different cipher modes depending on the key size, such as AES-128 vs AES-192
  259. * vs. AES-256. When providing a 16 byte key for an AES cipher handle, AES-128
  260. * is performed.
  261. *
  262. * Return: 0 if the setting of the key was successful; < 0 if an error occurred
  263. */
  264. int crypto_aead_setkey(struct crypto_aead *tfm,
  265. const u8 *key, unsigned int keylen);
  266. /**
  267. * crypto_aead_setauthsize() - set authentication data size
  268. * @tfm: cipher handle
  269. * @authsize: size of the authentication data / tag in bytes
  270. *
  271. * Set the authentication data size / tag size. AEAD requires an authentication
  272. * tag (or MAC) in addition to the associated data.
  273. *
  274. * Return: 0 if the setting of the key was successful; < 0 if an error occurred
  275. */
  276. int crypto_aead_setauthsize(struct crypto_aead *tfm, unsigned int authsize);
  277. static inline struct crypto_aead *crypto_aead_reqtfm(struct aead_request *req)
  278. {
  279. return __crypto_aead_cast(req->base.tfm);
  280. }
  281. /**
  282. * crypto_aead_encrypt() - encrypt plaintext
  283. * @req: reference to the aead_request handle that holds all information
  284. * needed to perform the cipher operation
  285. *
  286. * Encrypt plaintext data using the aead_request handle. That data structure
  287. * and how it is filled with data is discussed with the aead_request_*
  288. * functions.
  289. *
  290. * IMPORTANT NOTE The encryption operation creates the authentication data /
  291. * tag. That data is concatenated with the created ciphertext.
  292. * The ciphertext memory size is therefore the given number of
  293. * block cipher blocks + the size defined by the
  294. * crypto_aead_setauthsize invocation. The caller must ensure
  295. * that sufficient memory is available for the ciphertext and
  296. * the authentication tag.
  297. *
  298. * Return: 0 if the cipher operation was successful; < 0 if an error occurred
  299. */
  300. static inline int crypto_aead_encrypt(struct aead_request *req)
  301. {
  302. return crypto_aead_reqtfm(req)->encrypt(req);
  303. }
  304. /**
  305. * crypto_aead_decrypt() - decrypt ciphertext
  306. * @req: reference to the ablkcipher_request handle that holds all information
  307. * needed to perform the cipher operation
  308. *
  309. * Decrypt ciphertext data using the aead_request handle. That data structure
  310. * and how it is filled with data is discussed with the aead_request_*
  311. * functions.
  312. *
  313. * IMPORTANT NOTE The caller must concatenate the ciphertext followed by the
  314. * authentication data / tag. That authentication data / tag
  315. * must have the size defined by the crypto_aead_setauthsize
  316. * invocation.
  317. *
  318. *
  319. * Return: 0 if the cipher operation was successful; -EBADMSG: The AEAD
  320. * cipher operation performs the authentication of the data during the
  321. * decryption operation. Therefore, the function returns this error if
  322. * the authentication of the ciphertext was unsuccessful (i.e. the
  323. * integrity of the ciphertext or the associated data was violated);
  324. * < 0 if an error occurred.
  325. */
  326. static inline int crypto_aead_decrypt(struct aead_request *req)
  327. {
  328. if (req->cryptlen < crypto_aead_authsize(crypto_aead_reqtfm(req)))
  329. return -EINVAL;
  330. return crypto_aead_reqtfm(req)->decrypt(req);
  331. }
  332. /**
  333. * DOC: Asynchronous AEAD Request Handle
  334. *
  335. * The aead_request data structure contains all pointers to data required for
  336. * the AEAD cipher operation. This includes the cipher handle (which can be
  337. * used by multiple aead_request instances), pointer to plaintext and
  338. * ciphertext, asynchronous callback function, etc. It acts as a handle to the
  339. * aead_request_* API calls in a similar way as AEAD handle to the
  340. * crypto_aead_* API calls.
  341. */
  342. /**
  343. * crypto_aead_reqsize() - obtain size of the request data structure
  344. * @tfm: cipher handle
  345. *
  346. * Return: number of bytes
  347. */
  348. unsigned int crypto_aead_reqsize(struct crypto_aead *tfm);
  349. /**
  350. * aead_request_set_tfm() - update cipher handle reference in request
  351. * @req: request handle to be modified
  352. * @tfm: cipher handle that shall be added to the request handle
  353. *
  354. * Allow the caller to replace the existing aead handle in the request
  355. * data structure with a different one.
  356. */
  357. static inline void aead_request_set_tfm(struct aead_request *req,
  358. struct crypto_aead *tfm)
  359. {
  360. req->base.tfm = crypto_aead_tfm(tfm->child);
  361. }
  362. /**
  363. * aead_request_alloc() - allocate request data structure
  364. * @tfm: cipher handle to be registered with the request
  365. * @gfp: memory allocation flag that is handed to kmalloc by the API call.
  366. *
  367. * Allocate the request data structure that must be used with the AEAD
  368. * encrypt and decrypt API calls. During the allocation, the provided aead
  369. * handle is registered in the request data structure.
  370. *
  371. * Return: allocated request handle in case of success; IS_ERR() is true in case
  372. * of an error, PTR_ERR() returns the error code.
  373. */
  374. static inline struct aead_request *aead_request_alloc(struct crypto_aead *tfm,
  375. gfp_t gfp)
  376. {
  377. struct aead_request *req;
  378. req = kmalloc(sizeof(*req) + crypto_aead_reqsize(tfm), gfp);
  379. if (likely(req))
  380. aead_request_set_tfm(req, tfm);
  381. return req;
  382. }
  383. /**
  384. * aead_request_free() - zeroize and free request data structure
  385. * @req: request data structure cipher handle to be freed
  386. */
  387. static inline void aead_request_free(struct aead_request *req)
  388. {
  389. kzfree(req);
  390. }
  391. /**
  392. * aead_request_set_callback() - set asynchronous callback function
  393. * @req: request handle
  394. * @flags: specify zero or an ORing of the flags
  395. * CRYPTO_TFM_REQ_MAY_BACKLOG the request queue may back log and
  396. * increase the wait queue beyond the initial maximum size;
  397. * CRYPTO_TFM_REQ_MAY_SLEEP the request processing may sleep
  398. * @compl: callback function pointer to be registered with the request handle
  399. * @data: The data pointer refers to memory that is not used by the kernel
  400. * crypto API, but provided to the callback function for it to use. Here,
  401. * the caller can provide a reference to memory the callback function can
  402. * operate on. As the callback function is invoked asynchronously to the
  403. * related functionality, it may need to access data structures of the
  404. * related functionality which can be referenced using this pointer. The
  405. * callback function can access the memory via the "data" field in the
  406. * crypto_async_request data structure provided to the callback function.
  407. *
  408. * Setting the callback function that is triggered once the cipher operation
  409. * completes
  410. *
  411. * The callback function is registered with the aead_request handle and
  412. * must comply with the following template
  413. *
  414. * void callback_function(struct crypto_async_request *req, int error)
  415. */
  416. static inline void aead_request_set_callback(struct aead_request *req,
  417. u32 flags,
  418. crypto_completion_t compl,
  419. void *data)
  420. {
  421. req->base.complete = compl;
  422. req->base.data = data;
  423. req->base.flags = flags;
  424. }
  425. /**
  426. * aead_request_set_crypt - set data buffers
  427. * @req: request handle
  428. * @src: source scatter / gather list
  429. * @dst: destination scatter / gather list
  430. * @cryptlen: number of bytes to process from @src
  431. * @iv: IV for the cipher operation which must comply with the IV size defined
  432. * by crypto_aead_ivsize()
  433. *
  434. * Setting the source data and destination data scatter / gather lists which
  435. * hold the associated data concatenated with the plaintext or ciphertext. See
  436. * below for the authentication tag.
  437. *
  438. * For encryption, the source is treated as the plaintext and the
  439. * destination is the ciphertext. For a decryption operation, the use is
  440. * reversed - the source is the ciphertext and the destination is the plaintext.
  441. *
  442. * For both src/dst the layout is associated data, plain/cipher text,
  443. * authentication tag.
  444. *
  445. * The content of the AD in the destination buffer after processing
  446. * will either be untouched, or it will contain a copy of the AD
  447. * from the source buffer. In order to ensure that it always has
  448. * a copy of the AD, the user must copy the AD over either before
  449. * or after processing. Of course this is not relevant if the user
  450. * is doing in-place processing where src == dst.
  451. *
  452. * IMPORTANT NOTE AEAD requires an authentication tag (MAC). For decryption,
  453. * the caller must concatenate the ciphertext followed by the
  454. * authentication tag and provide the entire data stream to the
  455. * decryption operation (i.e. the data length used for the
  456. * initialization of the scatterlist and the data length for the
  457. * decryption operation is identical). For encryption, however,
  458. * the authentication tag is created while encrypting the data.
  459. * The destination buffer must hold sufficient space for the
  460. * ciphertext and the authentication tag while the encryption
  461. * invocation must only point to the plaintext data size. The
  462. * following code snippet illustrates the memory usage
  463. * buffer = kmalloc(ptbuflen + (enc ? authsize : 0));
  464. * sg_init_one(&sg, buffer, ptbuflen + (enc ? authsize : 0));
  465. * aead_request_set_crypt(req, &sg, &sg, ptbuflen, iv);
  466. */
  467. static inline void aead_request_set_crypt(struct aead_request *req,
  468. struct scatterlist *src,
  469. struct scatterlist *dst,
  470. unsigned int cryptlen, u8 *iv)
  471. {
  472. req->src = src;
  473. req->dst = dst;
  474. req->cryptlen = cryptlen;
  475. req->iv = iv;
  476. }
  477. /**
  478. * aead_request_set_assoc() - set the associated data scatter / gather list
  479. * @req: request handle
  480. * @assoc: associated data scatter / gather list
  481. * @assoclen: number of bytes to process from @assoc
  482. *
  483. * Obsolete, do not use.
  484. */
  485. static inline void aead_request_set_assoc(struct aead_request *req,
  486. struct scatterlist *assoc,
  487. unsigned int assoclen)
  488. {
  489. req->assoc = assoc;
  490. req->assoclen = assoclen;
  491. req->old = true;
  492. }
  493. /**
  494. * aead_request_set_ad - set associated data information
  495. * @req: request handle
  496. * @assoclen: number of bytes in associated data
  497. *
  498. * Setting the AD information. This function sets the length of
  499. * the associated data.
  500. */
  501. static inline void aead_request_set_ad(struct aead_request *req,
  502. unsigned int assoclen)
  503. {
  504. req->assoclen = assoclen;
  505. req->old = false;
  506. }
  507. static inline struct crypto_aead *aead_givcrypt_reqtfm(
  508. struct aead_givcrypt_request *req)
  509. {
  510. return crypto_aead_reqtfm(&req->areq);
  511. }
  512. static inline int crypto_aead_givencrypt(struct aead_givcrypt_request *req)
  513. {
  514. return aead_givcrypt_reqtfm(req)->givencrypt(req);
  515. };
  516. static inline int crypto_aead_givdecrypt(struct aead_givcrypt_request *req)
  517. {
  518. return aead_givcrypt_reqtfm(req)->givdecrypt(req);
  519. };
  520. static inline void aead_givcrypt_set_tfm(struct aead_givcrypt_request *req,
  521. struct crypto_aead *tfm)
  522. {
  523. req->areq.base.tfm = crypto_aead_tfm(tfm);
  524. }
  525. static inline struct aead_givcrypt_request *aead_givcrypt_alloc(
  526. struct crypto_aead *tfm, gfp_t gfp)
  527. {
  528. struct aead_givcrypt_request *req;
  529. req = kmalloc(sizeof(struct aead_givcrypt_request) +
  530. crypto_aead_reqsize(tfm), gfp);
  531. if (likely(req))
  532. aead_givcrypt_set_tfm(req, tfm);
  533. return req;
  534. }
  535. static inline void aead_givcrypt_free(struct aead_givcrypt_request *req)
  536. {
  537. kfree(req);
  538. }
  539. static inline void aead_givcrypt_set_callback(
  540. struct aead_givcrypt_request *req, u32 flags,
  541. crypto_completion_t compl, void *data)
  542. {
  543. aead_request_set_callback(&req->areq, flags, compl, data);
  544. }
  545. static inline void aead_givcrypt_set_crypt(struct aead_givcrypt_request *req,
  546. struct scatterlist *src,
  547. struct scatterlist *dst,
  548. unsigned int nbytes, void *iv)
  549. {
  550. aead_request_set_crypt(&req->areq, src, dst, nbytes, iv);
  551. }
  552. static inline void aead_givcrypt_set_assoc(struct aead_givcrypt_request *req,
  553. struct scatterlist *assoc,
  554. unsigned int assoclen)
  555. {
  556. aead_request_set_assoc(&req->areq, assoc, assoclen);
  557. }
  558. static inline void aead_givcrypt_set_giv(struct aead_givcrypt_request *req,
  559. u8 *giv, u64 seq)
  560. {
  561. req->giv = giv;
  562. req->seq = seq;
  563. }
  564. #endif /* _CRYPTO_AEAD_H */