diff mbox series

[API-NEXT,v4,15/15] linux-gen: ipsec: support ChaCha20-Poly1305

Message ID 1517331619-18755-16-git-send-email-odpbot@yandex.ru
State New
Headers show
Series [API-NEXT,v4,1/15] api: crypto: add enumeration for AES-CMAC | expand

Commit Message

Github ODP bot Jan. 30, 2018, 5 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: 5718327018debbb02aacb464493504c95fbe57a3
 ** Merge commit sha: c5d9389a8d3b1a532e290aff4508756a920173ee
 **/
 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;
 	}