From: Dmitry Eremin-Solenikov <dmitry.ereminsoleni...@linaro.org>

Support IPsec ChaCha20-Poly1305 on top of linux-generic's crypto
support.

Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsoleni...@linaro.org>
---
/** Email created from pull request 428 (lumag:chacha-poly1305)
 ** https://github.com/Linaro/odp/pull/428
 ** Patch: https://github.com/Linaro/odp/pull/428.patch
 ** Base sha: 44974a09b01c79adb9637a5dff38539598a76737
 ** Merge commit sha: 516808773882a012c221502d190787c1cdddd1b9
 **/
 platform/linux-generic/odp_ipsec.c     |  1 +
 platform/linux-generic/odp_ipsec_sad.c | 12 ++++++++++++
 2 files changed, 13 insertions(+)

diff --git a/platform/linux-generic/odp_ipsec.c 
b/platform/linux-generic/odp_ipsec.c
index b6192377e..43d7b9f52 100644
--- a/platform/linux-generic/odp_ipsec.c
+++ b/platform/linux-generic/odp_ipsec.c
@@ -112,6 +112,7 @@ int odp_ipsec_auth_capability(odp_auth_alg_t auth,
                        continue;
 
                if (ODP_AUTH_ALG_AES_GCM == auth ||
+                   ODP_AUTH_ALG_CHACHA20_POLY1305 == auth ||
                    ODP_DEPRECATE(ODP_AUTH_ALG_AES128_GCM) == auth) {
                        uint8_t aad_len = 12;
 
diff --git a/platform/linux-generic/odp_ipsec_sad.c 
b/platform/linux-generic/odp_ipsec_sad.c
index 031adef65..d97735408 100644
--- a/platform/linux-generic/odp_ipsec_sad.c
+++ b/platform/linux-generic/odp_ipsec_sad.c
@@ -210,6 +210,8 @@ uint32_t _odp_ipsec_cipher_iv_len(odp_cipher_alg_t cipher)
 #endif
        case ODP_CIPHER_ALG_AES_GCM:
                return 12;
+       case ODP_CIPHER_ALG_CHACHA20_POLY1305:
+               return 12;
        default:
                return (uint32_t)-1;
        }
@@ -240,6 +242,8 @@ uint32_t _odp_ipsec_auth_digest_len(odp_auth_alg_t auth)
        case ODP_AUTH_ALG_AES_GCM:
        case ODP_AUTH_ALG_AES_GMAC:
                return 16;
+       case ODP_AUTH_ALG_CHACHA20_POLY1305:
+               return 16;
        default:
                return (uint32_t)-1;
        }
@@ -392,6 +396,11 @@ odp_ipsec_sa_t odp_ipsec_sa_create(const 
odp_ipsec_sa_param_t *param)
                ipsec_sa->esp_iv_len = 8;
                ipsec_sa->esp_block_len = 16;
                break;
+       case ODP_CIPHER_ALG_CHACHA20_POLY1305:
+               ipsec_sa->use_counter_iv = 1;
+               ipsec_sa->esp_iv_len = 8;
+               ipsec_sa->esp_block_len = 1;
+               break;
        default:
                goto error;
        }
@@ -411,6 +420,9 @@ odp_ipsec_sa_t odp_ipsec_sa_create(const 
odp_ipsec_sa_param_t *param)
                ipsec_sa->esp_block_len = 16;
                crypto_param.auth_iv.length = 12;
                break;
+       case ODP_AUTH_ALG_CHACHA20_POLY1305:
+               crypto_param.auth_aad_len = sizeof(ipsec_aad_t);
+               break;
        default:
                break;
        }

Reply via email to