iv[1] = 0;
}
+/*
+ * Helper routine to copy IV
+ * Righ now we support only algorithms with IV length equals 0/8/16 bytes.
+ */
+static inline void
+copy_iv(uint64_t dst[IPSEC_MAX_IV_QWORD],
+ const uint64_t src[IPSEC_MAX_IV_QWORD], uint32_t len)
+{
+ RTE_BUILD_BUG_ON(IPSEC_MAX_IV_SIZE != 2 * sizeof(uint64_t));
+
+ switch (len) {
+ case IPSEC_MAX_IV_SIZE:
+ dst[1] = src[1];
+ /* fallthrough */
+ case sizeof(uint64_t):
+ dst[0] = src[0];
+ /* fallthrough */
+ case 0:
+ break;
+ default:
+ /* should never happen */
+ RTE_ASSERT(NULL);
+ }
+}
+
/*
* from RFC 4303 3.3.2.1.4:
* If the ESN option is enabled for the SA, the high-order 32
/* update spi, seqn and iv */
esph = (struct esp_hdr *)(ph + sa->hdr_len);
iv = (uint64_t *)(esph + 1);
- rte_memcpy(iv, ivp, sa->iv_len);
+ copy_iv(iv, ivp, sa->iv_len);
esph->spi = sa->spi;
esph->seq = sqn_low32(sqc);
/* update spi, seqn and iv */
esph = (struct esp_hdr *)(ph + uhlen);
iv = (uint64_t *)(esph + 1);
- rte_memcpy(iv, ivp, sa->iv_len);
+ copy_iv(iv, ivp, sa->iv_len);
esph->spi = sa->spi;
esph->seq = sqn_low32(sqc);
ivc = rte_crypto_op_ctod_offset(cop, uint64_t *, sa->iv_ofs);
ivp = rte_pktmbuf_mtod_offset(mb, uint64_t *,
pofs + sizeof(struct esp_hdr));
- rte_memcpy(ivc, ivp, sa->iv_len);
+ copy_iv(ivc, ivp, sa->iv_len);
}
return 0;
}