diff mbox series

[API-NEXT,v2,16/16] linux-gen: ipsec: support ChaCha20-Poly1305

Message ID 1517130009-11837-17-git-send-email-odpbot@yandex.ru
State Superseded
Headers show
Series [API-NEXT,v2,1/16] api: crypto: clarify special nature of gcm and gmac | expand

Commit Message

Github ODP bot Jan. 28, 2018, 9 a.m. UTC
From: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>


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

Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>

---
/** Email created from pull request 434 (lumag:crypto-upd)
 ** https://github.com/Linaro/odp/pull/434
 ** Patch: https://github.com/Linaro/odp/pull/434.patch
 ** Base sha: 0bdad6d2562166eec4abeb957b6bb5067de9fe94
 ** Merge commit sha: 8947b874421e06f87f32ec66357967a71e46e986
 **/
 platform/linux-generic/odp_ipsec.c     |  1 +
 platform/linux-generic/odp_ipsec_sad.c | 12 ++++++++++++
 2 files changed, 13 insertions(+)
diff mbox series

Patch

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;
 	}