DPDK  16.07.2
rte_crypto_sym.h
Go to the documentation of this file.
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 
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 
107  RTE_CRYPTO_CIPHER_LIST_END
108 };
109 
116 };
117 
133  struct {
134  uint8_t *data;
135  size_t length;
136  } key;
166 };
167 
240  RTE_CRYPTO_AUTH_LIST_END
241 };
242 
247 };
248 
262  struct {
263  uint8_t *data;
264  size_t length;
265  } key;
273  uint32_t digest_length;
285  uint32_t add_auth_data_length;
313 };
314 
320 };
321 
335  ;
336  union {
341  };
342 };
343 
352 };
353 
354 
356 
369  struct rte_mbuf *m_src;
370  struct rte_mbuf *m_dst;
372  enum rte_crypto_sym_op_sess_type sess_type;
373 
374  union {
379  };
380 
381  struct {
382  struct {
383  uint32_t offset;
396  uint32_t length;
420  } data;
422  struct {
423  uint8_t *data;
451  uint16_t length;
469  } iv;
470  } cipher;
471 
472  struct {
473  struct {
474  uint32_t offset;
494  uint32_t length;
513  } data;
515  struct {
516  uint8_t *data;
546  uint16_t length;
548  } digest;
550  struct {
551  uint8_t *data;
597  uint16_t length;
598  } aad;
600  } auth;
602 
603 
609 static inline void
611 {
612  memset(op, 0, sizeof(*op));
613 
614  op->sess_type = RTE_CRYPTO_SYM_OP_SESSIONLESS;
615 }
616 
617 
628 static inline struct rte_crypto_sym_xform *
630  void *priv_data, uint8_t nb_xforms)
631 {
632  struct rte_crypto_sym_xform *xform;
633 
634  sym_op->xform = xform = (struct rte_crypto_sym_xform *)priv_data;
635 
636  do {
638  xform = xform->next = --nb_xforms > 0 ? xform + 1 : NULL;
639  } while (xform);
640 
641  return sym_op->xform;
642 }
643 
644 
651 static inline int
653  struct rte_cryptodev_sym_session *sess)
654 {
655  sym_op->session = sess;
656  sym_op->sess_type = RTE_CRYPTO_SYM_OP_WITH_SESSION;
657 
658  return 0;
659 }
660 
661 
662 #ifdef __cplusplus
663 }
664 #endif
665 
666 #endif /* _RTE_CRYPTO_SYM_H_ */