Imported Upstream version 16.04
[deb_dpdk.git] / lib / librte_cryptodev / rte_crypto_sym.h
1 /*-
2  *   BSD LICENSE
3  *
4  *   Copyright(c) 2016 Intel Corporation. All rights reserved.
5  *
6  *   Redistribution and use in source and binary forms, with or without
7  *   modification, are permitted provided that the following conditions
8  *   are met:
9  *
10  *     * Redistributions of source code must retain the above copyright
11  *       notice, this list of conditions and the following disclaimer.
12  *     * Redistributions in binary form must reproduce the above copyright
13  *       notice, this list of conditions and the following disclaimer in
14  *       the documentation and/or other materials provided with the
15  *       distribution.
16  *     * Neither the name of Intel Corporation nor the names of its
17  *       contributors may be used to endorse or promote products derived
18  *       from this software without specific prior written permission.
19  *
20  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32
33 #ifndef _RTE_CRYPTO_SYM_H_
34 #define _RTE_CRYPTO_SYM_H_
35
36 /**
37  * @file rte_crypto_sym.h
38  *
39  * RTE Definitions for Symmetric Cryptography
40  *
41  * Defines symmetric cipher and authentication algorithms and modes, as well
42  * as supported symmetric crypto operation combinations.
43  */
44
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48
49 #include <string.h>
50
51 #include <rte_mbuf.h>
52 #include <rte_memory.h>
53 #include <rte_mempool.h>
54
55
56 /** Symmetric Cipher Algorithms */
57 enum rte_crypto_cipher_algorithm {
58         RTE_CRYPTO_CIPHER_NULL = 1,
59         /**< NULL cipher algorithm. No mode applies to the NULL algorithm. */
60
61         RTE_CRYPTO_CIPHER_3DES_CBC,
62         /**< Triple DES algorithm in CBC mode */
63         RTE_CRYPTO_CIPHER_3DES_CTR,
64         /**< Triple DES algorithm in CTR mode */
65         RTE_CRYPTO_CIPHER_3DES_ECB,
66         /**< Triple DES algorithm in ECB mode */
67
68         RTE_CRYPTO_CIPHER_AES_CBC,
69         /**< AES algorithm in CBC mode */
70         RTE_CRYPTO_CIPHER_AES_CCM,
71         /**< AES algorithm in CCM mode. When this cipher algorithm is used the
72          * *RTE_CRYPTO_AUTH_AES_CCM* element of the
73          * *rte_crypto_hash_algorithm* enum MUST be used to set up the related
74          * *rte_crypto_auth_xform* structure in the session context or in
75          * the op_params of the crypto operation structure in the case of a
76          * session-less crypto operation
77          */
78         RTE_CRYPTO_CIPHER_AES_CTR,
79         /**< AES algorithm in Counter mode */
80         RTE_CRYPTO_CIPHER_AES_ECB,
81         /**< AES algorithm in ECB mode */
82         RTE_CRYPTO_CIPHER_AES_F8,
83         /**< AES algorithm in F8 mode */
84         RTE_CRYPTO_CIPHER_AES_GCM,
85         /**< AES algorithm in GCM mode. When this cipher algorithm is used the
86          * *RTE_CRYPTO_AUTH_AES_GCM* element of the
87          * *rte_crypto_auth_algorithm* enum MUST be used to set up the related
88          * *rte_crypto_auth_setup_data* structure in the session context or in
89          * the op_params of the crypto operation structure in the case of a
90          * session-less crypto operation.
91          */
92         RTE_CRYPTO_CIPHER_AES_XTS,
93         /**< AES algorithm in XTS mode */
94
95         RTE_CRYPTO_CIPHER_ARC4,
96         /**< (A)RC4 cipher algorithm */
97
98         RTE_CRYPTO_CIPHER_KASUMI_F8,
99         /**< Kasumi algorithm in F8 mode */
100
101         RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
102         /**< SNOW3G algorithm in UEA2 mode */
103
104         RTE_CRYPTO_CIPHER_ZUC_EEA3,
105         /**< ZUC algorithm in EEA3 mode */
106
107         RTE_CRYPTO_CIPHER_LIST_END
108 };
109
110 /** Symmetric Cipher Direction */
111 enum rte_crypto_cipher_operation {
112         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
113         /**< Encrypt cipher operation */
114         RTE_CRYPTO_CIPHER_OP_DECRYPT
115         /**< Decrypt cipher operation */
116 };
117
118 /**
119  * Symmetric Cipher Setup Data.
120  *
121  * This structure contains data relating to Cipher (Encryption and Decryption)
122  *  use to create a session.
123  */
124 struct rte_crypto_cipher_xform {
125         enum rte_crypto_cipher_operation op;
126         /**< This parameter determines if the cipher operation is an encrypt or
127          * a decrypt operation. For the RC4 algorithm and the F8/CTR modes,
128          * only encrypt operations are valid.
129          */
130         enum rte_crypto_cipher_algorithm algo;
131         /**< Cipher algorithm */
132
133         struct {
134                 uint8_t *data;  /**< pointer to key data */
135                 size_t length;  /**< key length in bytes */
136         } key;
137         /**< Cipher key
138          *
139          * For the RTE_CRYPTO_CIPHER_AES_F8 mode of operation, key.data will
140          * point to a concatenation of the AES encryption key followed by a
141          * keymask. As per RFC3711, the keymask should be padded with trailing
142          * bytes to match the length of the encryption key used.
143          *
144          * For AES-XTS mode of operation, two keys must be provided and
145          * key.data must point to the two keys concatenated together (Key1 ||
146          * Key2). The cipher key length will contain the total size of both
147          * keys.
148          *
149          * Cipher key length is in bytes. For AES it can be 128 bits (16 bytes),
150          * 192 bits (24 bytes) or 256 bits (32 bytes).
151          *
152          * For the CCM mode of operation, the only supported key length is 128
153          * bits (16 bytes).
154          *
155          * For the RTE_CRYPTO_CIPHER_AES_F8 mode of operation, key.length
156          * should be set to the combined length of the encryption key and the
157          * keymask. Since the keymask and the encryption key are the same size,
158          * key.length should be set to 2 x the AES encryption key length.
159          *
160          * For the AES-XTS mode of operation:
161          *  - Two keys must be provided and key.length refers to total length of
162          *    the two keys.
163          *  - Each key can be either 128 bits (16 bytes) or 256 bits (32 bytes).
164          *  - Both keys must have the same size.
165          **/
166 };
167
168 /** Symmetric Authentication / Hash Algorithms */
169 enum rte_crypto_auth_algorithm {
170         RTE_CRYPTO_AUTH_NULL = 1,
171         /**< NULL hash algorithm. */
172
173         RTE_CRYPTO_AUTH_AES_CBC_MAC,
174         /**< AES-CBC-MAC algorithm. Only 128-bit keys are supported. */
175         RTE_CRYPTO_AUTH_AES_CCM,
176         /**< AES algorithm in CCM mode. This is an authenticated cipher. When
177          * this hash algorithm is used, the *RTE_CRYPTO_CIPHER_AES_CCM*
178          * element of the *rte_crypto_cipher_algorithm* enum MUST be used to
179          * set up the related rte_crypto_cipher_setup_data structure in the
180          * session context or the corresponding parameter in the crypto
181          * operation data structures op_params parameter MUST be set for a
182          * session-less crypto operation.
183          */
184         RTE_CRYPTO_AUTH_AES_CMAC,
185         /**< AES CMAC algorithm. */
186         RTE_CRYPTO_AUTH_AES_GCM,
187         /**< AES algorithm in GCM mode. When this hash algorithm
188          * is used, the RTE_CRYPTO_CIPHER_AES_GCM element of the
189          * rte_crypto_cipher_algorithm enum MUST be used to set up the related
190          * rte_crypto_cipher_setup_data structure in the session context, or
191          * the corresponding parameter in the crypto operation data structures
192          * op_params parameter MUST be set for a session-less crypto operation.
193          */
194         RTE_CRYPTO_AUTH_AES_GMAC,
195         /**< AES GMAC algorithm. When this hash algorithm
196         * is used, the RTE_CRYPTO_CIPHER_AES_GCM element of the
197         * rte_crypto_cipher_algorithm enum MUST be used to set up the related
198         * rte_crypto_cipher_setup_data structure in the session context,  or
199         * the corresponding parameter in the crypto operation data structures
200         * op_params parameter MUST be set for a session-less crypto operation.
201         */
202         RTE_CRYPTO_AUTH_AES_XCBC_MAC,
203         /**< AES XCBC algorithm. */
204
205         RTE_CRYPTO_AUTH_KASUMI_F9,
206         /**< Kasumi algorithm in F9 mode. */
207
208         RTE_CRYPTO_AUTH_MD5,
209         /**< MD5 algorithm */
210         RTE_CRYPTO_AUTH_MD5_HMAC,
211         /**< HMAC using MD5 algorithm */
212
213         RTE_CRYPTO_AUTH_SHA1,
214         /**< 128 bit SHA algorithm. */
215         RTE_CRYPTO_AUTH_SHA1_HMAC,
216         /**< HMAC using 128 bit SHA algorithm. */
217         RTE_CRYPTO_AUTH_SHA224,
218         /**< 224 bit SHA algorithm. */
219         RTE_CRYPTO_AUTH_SHA224_HMAC,
220         /**< HMAC using 224 bit SHA algorithm. */
221         RTE_CRYPTO_AUTH_SHA256,
222         /**< 256 bit SHA algorithm. */
223         RTE_CRYPTO_AUTH_SHA256_HMAC,
224         /**< HMAC using 256 bit SHA algorithm. */
225         RTE_CRYPTO_AUTH_SHA384,
226         /**< 384 bit SHA algorithm. */
227         RTE_CRYPTO_AUTH_SHA384_HMAC,
228         /**< HMAC using 384 bit SHA algorithm. */
229         RTE_CRYPTO_AUTH_SHA512,
230         /**< 512 bit SHA algorithm. */
231         RTE_CRYPTO_AUTH_SHA512_HMAC,
232         /**< HMAC using 512 bit SHA algorithm. */
233
234         RTE_CRYPTO_AUTH_SNOW3G_UIA2,
235         /**< SNOW3G algorithm in UIA2 mode. */
236
237         RTE_CRYPTO_AUTH_ZUC_EIA3,
238         /**< ZUC algorithm in EIA3 mode */
239
240         RTE_CRYPTO_AUTH_LIST_END
241 };
242
243 /** Symmetric Authentication / Hash Operations */
244 enum rte_crypto_auth_operation {
245         RTE_CRYPTO_AUTH_OP_VERIFY,      /**< Verify authentication digest */
246         RTE_CRYPTO_AUTH_OP_GENERATE     /**< Generate authentication digest */
247 };
248
249 /**
250  * Authentication / Hash transform data.
251  *
252  * This structure contains data relating to an authentication/hash crypto
253  * transforms. The fields op, algo and digest_length are common to all
254  * authentication transforms and MUST be set.
255  */
256 struct rte_crypto_auth_xform {
257         enum rte_crypto_auth_operation op;
258         /**< Authentication operation type */
259         enum rte_crypto_auth_algorithm algo;
260         /**< Authentication algorithm selection */
261
262         struct {
263                 uint8_t *data;  /**< pointer to key data */
264                 size_t length;  /**< key length in bytes */
265         } key;
266         /**< Authentication key data.
267          * The authentication key length MUST be less than or equal to the
268          * block size of the algorithm. It is the callers responsibility to
269          * ensure that the key length is compliant with the standard being used
270          * (for example RFC 2104, FIPS 198a).
271          */
272
273         uint32_t digest_length;
274         /**< Length of the digest to be returned. If the verify option is set,
275          * this specifies the length of the digest to be compared for the
276          * session.
277          *
278          * If the value is less than the maximum length allowed by the hash,
279          * the result shall be truncated.  If the value is greater than the
280          * maximum length allowed by the hash then an error will be generated
281          * by *rte_cryptodev_sym_session_create* or by the
282          * *rte_cryptodev_sym_enqueue_burst* if using session-less APIs.
283          */
284
285         uint32_t add_auth_data_length;
286         /**< The length of the additional authenticated data (AAD) in bytes.
287          * The maximum permitted value is 240 bytes, unless otherwise specified
288          * below.
289          *
290          * This field must be specified when the hash algorithm is one of the
291          * following:
292          *
293          * - For SNOW3G (@ref RTE_CRYPTO_AUTH_SNOW3G_UIA2), this is the
294          *   length of the IV (which should be 16).
295          *
296          * - For GCM (@ref RTE_CRYPTO_AUTH_AES_GCM).  In this case, this is
297          *   the length of the Additional Authenticated Data (called A, in NIST
298          *   SP800-38D).
299          *
300          * - For CCM (@ref RTE_CRYPTO_AUTH_AES_CCM).  In this case, this is
301          *   the length of the associated data (called A, in NIST SP800-38C).
302          *   Note that this does NOT include the length of any padding, or the
303          *   18 bytes reserved at the start of the above field to store the
304          *   block B0 and the encoded length.  The maximum permitted value in
305          *   this case is 222 bytes.
306          *
307          * @note
308          *  For AES-GMAC (@ref RTE_CRYPTO_AUTH_AES_GMAC) mode of operation
309          *  this field is not used and should be set to 0. Instead the length
310          *  of the AAD data is specified in the message length to hash field of
311          *  the rte_crypto_sym_op_data structure.
312          */
313 };
314
315 /** Crypto transformation types */
316 enum rte_crypto_sym_xform_type {
317         RTE_CRYPTO_SYM_XFORM_NOT_SPECIFIED = 0, /**< No xform specified */
318         RTE_CRYPTO_SYM_XFORM_AUTH,              /**< Authentication xform */
319         RTE_CRYPTO_SYM_XFORM_CIPHER             /**< Cipher xform  */
320 };
321
322 /**
323  * Symmetric crypto transform structure.
324  *
325  * This is used to specify the crypto transforms required, multiple transforms
326  * can be chained together to specify a chain transforms such as authentication
327  * then cipher, or cipher then authentication. Each transform structure can
328  * hold a single transform, the type field is used to specify which transform
329  * is contained within the union
330  */
331 struct rte_crypto_sym_xform {
332         struct rte_crypto_sym_xform *next;
333         /**< next xform in chain */
334         enum rte_crypto_sym_xform_type type
335         ; /**< xform type */
336         union {
337                 struct rte_crypto_auth_xform auth;
338                 /**< Authentication / hash xform */
339                 struct rte_crypto_cipher_xform cipher;
340                 /**< Cipher xform */
341         };
342 };
343
344 /**
345  * Crypto operation session type. This is used to specify whether a crypto
346  * operation has session structure attached for immutable parameters or if all
347  * operation information is included in the operation data structure.
348  */
349 enum rte_crypto_sym_op_sess_type {
350         RTE_CRYPTO_SYM_OP_WITH_SESSION, /**< Session based crypto operation */
351         RTE_CRYPTO_SYM_OP_SESSIONLESS   /**< Session-less crypto operation */
352 };
353
354
355 struct rte_cryptodev_sym_session;
356
357 /**
358  * Symmetric Cryptographic Operation.
359  *
360  * This structure contains data relating to performing symmetric cryptographic
361  * processing on a referenced mbuf data buffer.
362  *
363  * When a symmetric crypto operation is enqueued with the device for processing
364  * it must have a valid *rte_mbuf* structure attached, via m_src parameter,
365  * which contains the source data which the crypto operation is to be performed
366  * on.
367  */
368 struct rte_crypto_sym_op {
369         struct rte_mbuf *m_src; /**< source mbuf */
370         struct rte_mbuf *m_dst; /**< destination mbuf */
371
372         enum rte_crypto_sym_op_sess_type sess_type;
373
374         union {
375                 struct rte_cryptodev_sym_session *session;
376                 /**< Handle for the initialised session context */
377                 struct rte_crypto_sym_xform *xform;
378                 /**< Session-less API crypto operation parameters */
379         };
380
381         struct {
382                 struct {
383                         uint32_t offset;
384                          /**< Starting point for cipher processing, specified
385                           * as number of bytes from start of data in the source
386                           * buffer. The result of the cipher operation will be
387                           * written back into the output buffer starting at
388                           * this location.
389                           *
390                           * @note
391                           * For Snow3G @ RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
392                           * this field should be in bits.
393                           */
394
395                         uint32_t length;
396                          /**< The message length, in bytes, of the source buffer
397                           * on which the cryptographic operation will be
398                           * computed. This must be a multiple of the block size
399                           * if a block cipher is being used. This is also the
400                           * same as the result length.
401                           *
402                           * @note
403                           * In the case of CCM @ref RTE_CRYPTO_AUTH_AES_CCM,
404                           * this value should not include the length of the
405                           * padding or the length of the MAC; the driver will
406                           * compute the actual number of bytes over which the
407                           * encryption will occur, which will include these
408                           * values.
409                           *
410                           * @note
411                           * For AES-GMAC @ref RTE_CRYPTO_AUTH_AES_GMAC, this
412                           * field should be set to 0.
413                           *
414                           * @note
415                           * For Snow3G @ RTE_CRYPTO_AUTH_SNOW3G_UEA2
416                           * this field should be in bits.
417                           */
418                 } data; /**< Data offsets and length for ciphering */
419
420                 struct {
421                         uint8_t *data;
422                         /**< Initialisation Vector or Counter.
423                          *
424                          * - For block ciphers in CBC or F8 mode, or for Kasumi
425                          * in F8 mode, or for SNOW3G in UEA2 mode, this is the
426                          * Initialisation Vector (IV) value.
427                          *
428                          * - For block ciphers in CTR mode, this is the counter.
429                          *
430                          * - For GCM mode, this is either the IV (if the length
431                          * is 96 bits) or J0 (for other sizes), where J0 is as
432                          * defined by NIST SP800-38D. Regardless of the IV
433                          * length, a full 16 bytes needs to be allocated.
434                          *
435                          * - For CCM mode, the first byte is reserved, and the
436                          * nonce should be written starting at &iv[1] (to allow
437                          * space for the implementation to write in the flags
438                          * in the first byte). Note that a full 16 bytes should
439                          * be allocated, even though the length field will
440                          * have a value less than this.
441                          *
442                          * - For AES-XTS, this is the 128bit tweak, i, from
443                          * IEEE Std 1619-2007.
444                          *
445                          * For optimum performance, the data pointed to SHOULD
446                          * be 8-byte aligned.
447                          */
448                         phys_addr_t phys_addr;
449                         uint16_t length;
450                         /**< Length of valid IV data.
451                          *
452                          * - For block ciphers in CBC or F8 mode, or for Kasumi
453                          * in F8 mode, or for SNOW3G in UEA2 mode, this is the
454                          * length of the IV (which must be the same as the
455                          * block length of the cipher).
456                          *
457                          * - For block ciphers in CTR mode, this is the length
458                          * of the counter (which must be the same as the block
459                          * length of the cipher).
460                          *
461                          * - For GCM mode, this is either 12 (for 96-bit IVs)
462                          * or 16, in which case data points to J0.
463                          *
464                          * - For CCM mode, this is the length of the nonce,
465                          * which can be in the range 7 to 13 inclusive.
466                          */
467                 } iv;   /**< Initialisation vector parameters */
468         } cipher;
469
470         struct {
471                 struct {
472                         uint32_t offset;
473                          /**< Starting point for hash processing, specified as
474                           * number of bytes from start of packet in source
475                           * buffer.
476                           *
477                           * @note
478                           * For CCM and GCM modes of operation, this field is
479                           * ignored. The field @ref aad field
480                           * should be set instead.
481                           *
482                           * @note For AES-GMAC (@ref RTE_CRYPTO_AUTH_AES_GMAC)
483                           * mode of operation, this field specifies the start
484                           * of the AAD data in the source buffer.
485                           *
486                           * @note
487                           * For Snow3G @ RTE_CRYPTO_AUTH_SNOW3G_UIA2
488                           * this field should be in bits.
489                           */
490
491                         uint32_t length;
492                          /**< The message length, in bytes, of the source
493                           * buffer that the hash will be computed on.
494                           *
495                           * @note
496                           * For CCM and GCM modes of operation, this field is
497                           * ignored. The field @ref aad field should be set
498                           * instead.
499                           *
500                           * @note
501                           * For AES-GMAC @ref RTE_CRYPTO_AUTH_AES_GMAC mode
502                           * of operation, this field specifies the length of
503                           * the AAD data in the source buffer.
504                           *
505                           * @note
506                           * For Snow3G @ RTE_CRYPTO_AUTH_SNOW3G_UIA2
507                           * this field should be in bits.
508                           */
509                 } data; /**< Data offsets and length for authentication */
510
511                 struct {
512                         uint8_t *data;
513                         /**< If this member of this structure is set this is a
514                          * pointer to the location where the digest result
515                          * should be inserted (in the case of digest generation)
516                          * or where the purported digest exists (in the case of
517                          * digest verification).
518                          *
519                          * At session creation time, the client specified the
520                          * digest result length with the digest_length member
521                          * of the @ref rte_crypto_auth_xform structure. For
522                          * physical crypto devices the caller must allocate at
523                          * least digest_length of physically contiguous memory
524                          * at this location.
525                          *
526                          * For digest generation, the digest result will
527                          * overwrite any data at this location.
528                          *
529                          * @note
530                          * For GCM (@ref RTE_CRYPTO_AUTH_AES_GCM), for
531                          * "digest result" read "authentication tag T".
532                          *
533                          * If this member is not set the digest result is
534                          * understood to be in the destination buffer for
535                          * digest generation, and in the source buffer for
536                          * digest verification. The location of the digest
537                          * result in this case is immediately following the
538                          * region over which the digest is computed.
539                          */
540                         phys_addr_t phys_addr;
541                         /**< Physical address of digest */
542                         uint16_t length;
543                         /**< Length of digest */
544                 } digest; /**< Digest parameters */
545
546                 struct {
547                         uint8_t *data;
548                         /**< Pointer to Additional Authenticated Data (AAD)
549                          * needed for authenticated cipher mechanisms (CCM and
550                          * GCM), and to the IV for SNOW3G authentication
551                          * (@ref RTE_CRYPTO_AUTH_SNOW3G_UIA2). For other
552                          * authentication mechanisms this pointer is ignored.
553                          *
554                          * The length of the data pointed to by this field is
555                          * set up for the session in the @ref
556                          * rte_crypto_auth_xform structure as part of the @ref
557                          * rte_cryptodev_sym_session_create function call.
558                          * This length must not exceed 240 bytes.
559                          *
560                          * Specifically for CCM (@ref RTE_CRYPTO_AUTH_AES_CCM),
561                          * the caller should setup this field as follows:
562                          *
563                          * - the nonce should be written starting at an offset
564                          * of one byte into the array, leaving room for the
565                          * implementation to write in the flags to the first
566                          *  byte.
567                          *
568                          * - the additional  authentication data itself should
569                          * be written starting at an offset of 18 bytes into
570                          * the array, leaving room for the length encoding in
571                          * the first two bytes of the second block.
572                          *
573                          * - the array should be big enough to hold the above
574                          *  fields, plus any padding to round this up to the
575                          *  nearest multiple of the block size (16 bytes).
576                          *  Padding will be added by the implementation.
577                          *
578                          * Finally, for GCM (@ref RTE_CRYPTO_AUTH_AES_GCM), the
579                          * caller should setup this field as follows:
580                          *
581                          * - the AAD is written in starting at byte 0
582                          * - the array must be big enough to hold the AAD, plus
583                          * any space to round this up to the nearest multiple
584                          * of the block size (16 bytes).
585                          *
586                          * @note
587                          * For AES-GMAC (@ref RTE_CRYPTO_AUTH_AES_GMAC) mode of
588                          * operation, this field is not used and should be set
589                          * to 0. Instead the AAD data should be placed in the
590                          * source buffer.
591                          */
592                         phys_addr_t phys_addr;  /**< physical address */
593                         uint16_t length;        /**< Length of digest */
594                 } aad;
595                 /**< Additional authentication parameters */
596         } auth;
597 } __rte_cache_aligned;
598
599
600 /**
601  * Reset the fields of a symmetric operation to their default values.
602  *
603  * @param       op      The crypto operation to be reset.
604  */
605 static inline void
606 __rte_crypto_sym_op_reset(struct rte_crypto_sym_op *op)
607 {
608         memset(op, 0, sizeof(*op));
609
610         op->sess_type = RTE_CRYPTO_SYM_OP_SESSIONLESS;
611 }
612
613
614 /**
615  * Allocate space for symmetric crypto xforms in the private data space of the
616  * crypto operation. This also defaults the crypto xform type to
617  * RTE_CRYPTO_SYM_XFORM_NOT_SPECIFIED and configures the chaining of the xforms
618  * in the crypto operation
619  *
620  * @return
621  * - On success returns pointer to first crypto xform in crypto operations chain
622  * - On failure returns NULL
623  */
624 static inline struct rte_crypto_sym_xform *
625 __rte_crypto_sym_op_sym_xforms_alloc(struct rte_crypto_sym_op *sym_op,
626                 void *priv_data, uint8_t nb_xforms)
627 {
628         struct rte_crypto_sym_xform *xform;
629
630         sym_op->xform = xform = (struct rte_crypto_sym_xform *)priv_data;
631
632         do {
633                 xform->type = RTE_CRYPTO_SYM_XFORM_NOT_SPECIFIED;
634                 xform = xform->next = --nb_xforms > 0 ? xform + 1 : NULL;
635         } while (xform);
636
637         return sym_op->xform;
638 }
639
640
641 /**
642  * Attach a session to a symmetric crypto operation
643  *
644  * @param       sym_op  crypto operation
645  * @param       sess    cryptodev session
646  */
647 static inline int
648 __rte_crypto_sym_op_attach_sym_session(struct rte_crypto_sym_op *sym_op,
649                 struct rte_cryptodev_sym_session *sess)
650 {
651         sym_op->session = sess;
652         sym_op->sess_type = RTE_CRYPTO_SYM_OP_WITH_SESSION;
653
654         return 0;
655 }
656
657
658 #ifdef __cplusplus
659 }
660 #endif
661
662 #endif /* _RTE_CRYPTO_SYM_H_ */