MCPcopy Create free account
hub / github.com/F-Stack/f-stack / inb_cpu_crypto_prepare

Function inb_cpu_crypto_prepare

dpdk/lib/ipsec/esp_inb.c:135–178  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

133}
134
135static inline uint32_t
136inb_cpu_crypto_prepare(const struct rte_ipsec_sa *sa, struct rte_mbuf *mb,
137 uint32_t *pofs, uint32_t plen, void *iv)
138{
139 struct aead_gcm_iv *gcm;
140 struct aead_ccm_iv *ccm;
141 struct aead_chacha20_poly1305_iv *chacha20_poly1305;
142 struct aesctr_cnt_blk *ctr;
143 uint64_t *ivp;
144 uint32_t clen;
145
146 ivp = rte_pktmbuf_mtod_offset(mb, uint64_t *,
147 *pofs + sizeof(struct rte_esp_hdr));
148 clen = 0;
149
150 switch (sa->algo_type) {
151 case ALGO_TYPE_AES_GCM:
152 case ALGO_TYPE_AES_GMAC:
153 gcm = (struct aead_gcm_iv *)iv;
154 aead_gcm_iv_fill(gcm, ivp[0], sa->salt);
155 break;
156 case ALGO_TYPE_AES_CCM:
157 ccm = (struct aead_ccm_iv *)iv;
158 aead_ccm_iv_fill(ccm, ivp[0], sa->salt);
159 break;
160 case ALGO_TYPE_CHACHA20_POLY1305:
161 chacha20_poly1305 = (struct aead_chacha20_poly1305_iv *)iv;
162 aead_chacha20_poly1305_iv_fill(chacha20_poly1305,
163 ivp[0], sa->salt);
164 break;
165 case ALGO_TYPE_AES_CBC:
166 case ALGO_TYPE_3DES_CBC:
167 copy_iv(iv, ivp, sa->iv_len);
168 break;
169 case ALGO_TYPE_AES_CTR:
170 ctr = (struct aesctr_cnt_blk *)iv;
171 aes_ctr_cnt_blk_fill(ctr, ivp[0], sa->salt);
172 break;
173 }
174
175 *pofs += sa->ctp.auth.offset;
176 clen = plen - sa->ctp.auth.length;
177 return clen;
178}
179
180/*
181 * Helper function for prepare() to deal with situation when

Callers 1

cpu_inb_pkt_prepareFunction · 0.85

Calls 5

aead_gcm_iv_fillFunction · 0.85
aead_ccm_iv_fillFunction · 0.85
copy_ivFunction · 0.85
aes_ctr_cnt_blk_fillFunction · 0.85

Tested by

no test coverage detected