diff mbox series

[API-NEXT,v3,17/17] linux-gen: ipsec: support ChaCha20-Poly1305

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

Commit Message

Github ODP bot Jan. 30, 2018, 3 p.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: abc7b3bb0babe8efa0fde52752bcd514f2f0d422
 ** Merge commit sha: 15e0c830b5937ae889b7bcf6822797dbe0ecb799
 **/
 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;
 	}