From patchwork Mon Jan 22 08:00:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 125338 Delivered-To: patch@linaro.org Received: by 10.46.66.141 with SMTP id h13csp1023602ljf; Mon, 22 Jan 2018 00:04:28 -0800 (PST) X-Google-Smtp-Source: AH8x225hA8gtordZ6nCJ1IdOljFY4cD9oS8wvbqkMVbi7vS8T+49EiHinA2d4rm+UpGnNyxVmXcL X-Received: by 10.200.54.208 with SMTP id b16mr9734245qtc.187.1516608265833; Mon, 22 Jan 2018 00:04:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516608265; cv=none; d=google.com; s=arc-20160816; b=OQxO/kudNuNvBryVph9dHEIiEam36NrdKe9MZM29a/wKMLIoY/IAJKqxyWv2bJnu3w 8qUS6Ns+jdVYlH4sr6cYOrfkwxd88w0jAIWEFiHGFwTP5byCni0XhroZfknLDpFCUCzr Qu73qjczXOxOTjW53XAGEHWg1wWns3xdTHwaIKg5a9zgMr7QuA2sjg3hU/knqwZhO5Oz ZAhK+AYcgkTTGtGU5/splGCE1YDesx7mbHWFbqfZ5W1IwirnSeanZAjTCumMgWC+tRfL 1MqutJIOt6cguUcPiZZv/5/f+PtSFQ+3tx8LVa8m4sPUPE6tAosPGGAFyykX6IiXGl2o mY/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=WNCW5EZw33ZkJ0AyfFDjyGBG9WWJ3BcWYUx5R/80XLM=; b=taEccJL+R5qjK1zl5ADJcbH9o5Yj4clVq4uuKE3ktNrqc788ILv4CD9J25FFSKPSOB DT3ghqoPo00GCq3KUnszcuNV2kumRKEPYhCE/LPV5vxpsOF9izqTCLFzPzuVx5BFHmCY ulmQEFAfW33gdPshbeY4hnY8BR5tkEc2p/gVymik38+8im3WCvsgF+S2RSkohQ4fUG5m tTLaxdaSz0zfscipRPmU4eYd4OGlciJhlIf0lWWsm5lgF/qzIAPeutTWQHrXCPg7Wbt5 WwhXvG2Y2rNi3NdVYbtcPAz96I9SUZsFs3+Qk0BTto9I8NeGDnv+v2eDQguUmeTveRwM H0lw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id t199si10594452qke.19.2018.01.22.00.04.25; Mon, 22 Jan 2018 00:04:25 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 7DC7E61758; Mon, 22 Jan 2018 08:04:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2 autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 517A961798; Mon, 22 Jan 2018 08:01:12 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 2535061520; Mon, 22 Jan 2018 08:00:34 +0000 (UTC) Received: from forward101o.mail.yandex.net (forward101o.mail.yandex.net [37.140.190.181]) by lists.linaro.org (Postfix) with ESMTPS id 7A375617C4 for ; Mon, 22 Jan 2018 08:00:17 +0000 (UTC) Received: from mxback17j.mail.yandex.net (mxback17j.mail.yandex.net [IPv6:2a02:6b8:0:1619::93]) by forward101o.mail.yandex.net (Yandex) with ESMTP id EE5F7134342B for ; Mon, 22 Jan 2018 11:00:15 +0300 (MSK) Received: from smtp2o.mail.yandex.net (smtp2o.mail.yandex.net [2a02:6b8:0:1a2d::26]) by mxback17j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id a4trRI07Q2-0FkmcOQk; Mon, 22 Jan 2018 11:00:15 +0300 Received: by smtp2o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id yORTcTkY7i-0FHmlr75; Mon, 22 Jan 2018 11:00:15 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Mon, 22 Jan 2018 11:00:02 +0300 Message-Id: <1516608010-2535-5-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516608010-2535-1-git-send-email-odpbot@yandex.ru> References: <1516608010-2535-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 413 Subject: [lng-odp] [PATCH v1 4/12] api: crypto: use cipher_iv_ptr instead of override_iv_ptr X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Dmitry Eremin-Solenikov In preparation to add auth-specific IV, rename override_iv_ptr field to ciper_iv_ptr. Provide deprecated compatibility field override_iv_ptr. Signed-off-by: Dmitry Eremin-Solenikov Reviewed-by: Bill Fischofer Reviewed-by: Petri Savolainen Signed-off-by: Maxim Uvarov --- /** Email created from pull request 413 (SonicwallYhe:api-next) ** https://github.com/Linaro/odp/pull/413 ** Patch: https://github.com/Linaro/odp/pull/413.patch ** Base sha: 5a4502fc6bc53e6503169da3028f456b64811a0b ** Merge commit sha: 6669be7b55ab094f9e27d2101a6bb005ca87e405 **/ example/ipsec/odp_ipsec.c | 2 +- include/odp/api/spec/crypto.h | 18 ++++++++++++---- platform/linux-generic/odp_crypto.c | 26 ++++++++++++------------ platform/linux-generic/odp_ipsec.c | 8 ++++---- test/validation/api/crypto/odp_crypto_test_inp.c | 18 ++++++++-------- 5 files changed, 41 insertions(+), 31 deletions(-) diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c index 001f52084..c0978d0df 100644 --- a/example/ipsec/odp_ipsec.c +++ b/example/ipsec/odp_ipsec.c @@ -635,7 +635,7 @@ pkt_disposition_e do_ipsec_in_classify(odp_packet_t *pkt, if (esp) { params.cipher_range.offset = ipv4_data_p(ip) + hdr_len - buf; params.cipher_range.length = ipv4_data_len(ip) - hdr_len; - params.override_iv_ptr = esp->iv; + params.cipher_iv_ptr = esp->iv; } /* Issue crypto request */ diff --git a/include/odp/api/spec/crypto.h b/include/odp/api/spec/crypto.h index 25ce2f86c..e44892fbf 100644 --- a/include/odp/api/spec/crypto.h +++ b/include/odp/api/spec/crypto.h @@ -400,8 +400,13 @@ typedef struct odp_crypto_op_param_t { */ odp_packet_t out_pkt; - /** Override session IV pointer */ - uint8_t *override_iv_ptr; + /** Override session IV pointer for cipher */ + union { + /** @deprecated use cipher_iv_ptr */ + uint8_t *ODP_DEPRECATE(override_iv_ptr); + /** Override session IV pointer for cipher */ + uint8_t *cipher_iv_ptr; + }; /** Offset from start of packet for hash result * @@ -436,8 +441,13 @@ typedef struct odp_crypto_packet_op_param_t { /** Session handle from creation */ odp_crypto_session_t session; - /** Override session IV pointer */ - uint8_t *override_iv_ptr; + /** Override session IV pointer for cipher */ + union { + /** @deprecated use cipher_iv_ptr */ + uint8_t *ODP_DEPRECATE(override_iv_ptr); + /** Override session IV pointer for cipher */ + uint8_t *cipher_iv_ptr; + }; /** Offset from start of packet for hash result * diff --git a/platform/linux-generic/odp_crypto.c b/platform/linux-generic/odp_crypto.c index eab82e9fa..35a83ce0f 100644 --- a/platform/linux-generic/odp_crypto.c +++ b/platform/linux-generic/odp_crypto.c @@ -434,8 +434,8 @@ odp_crypto_alg_err_t cipher_encrypt(odp_packet_t pkt, void *iv_ptr; int ret; - if (param->override_iv_ptr) - iv_ptr = param->override_iv_ptr; + if (param->cipher_iv_ptr) + iv_ptr = param->cipher_iv_ptr; else if (session->p.cipher_iv.data) iv_ptr = session->cipher.iv_data; else @@ -465,8 +465,8 @@ odp_crypto_alg_err_t cipher_decrypt(odp_packet_t pkt, void *iv_ptr; int ret; - if (param->override_iv_ptr) - iv_ptr = param->override_iv_ptr; + if (param->cipher_iv_ptr) + iv_ptr = param->cipher_iv_ptr; else if (session->p.cipher_iv.data) iv_ptr = session->cipher.iv_data; else @@ -528,8 +528,8 @@ odp_crypto_alg_err_t aes_gcm_encrypt(odp_packet_t pkt, uint8_t block[EVP_MAX_MD_SIZE]; int ret; - if (param->override_iv_ptr) - iv_ptr = param->override_iv_ptr; + if (param->cipher_iv_ptr) + iv_ptr = param->cipher_iv_ptr; else if (session->p.cipher_iv.data) iv_ptr = session->cipher.iv_data; else @@ -575,8 +575,8 @@ odp_crypto_alg_err_t aes_gcm_decrypt(odp_packet_t pkt, uint8_t block[EVP_MAX_MD_SIZE]; int ret; - if (param->override_iv_ptr) - iv_ptr = param->override_iv_ptr; + if (param->cipher_iv_ptr) + iv_ptr = param->cipher_iv_ptr; else if (session->p.cipher_iv.data) iv_ptr = session->cipher.iv_data; else @@ -641,8 +641,8 @@ odp_crypto_alg_err_t aes_gmac_gen(odp_packet_t pkt, uint8_t block[EVP_MAX_MD_SIZE]; int ret; - if (param->override_iv_ptr) - iv_ptr = param->override_iv_ptr; + if (param->cipher_iv_ptr) + iv_ptr = param->cipher_iv_ptr; else if (session->p.cipher_iv.data) iv_ptr = session->cipher.iv_data; else @@ -680,8 +680,8 @@ odp_crypto_alg_err_t aes_gmac_check(odp_packet_t pkt, uint8_t block[EVP_MAX_MD_SIZE]; int ret; - if (param->override_iv_ptr) - iv_ptr = param->override_iv_ptr; + if (param->cipher_iv_ptr) + iv_ptr = param->cipher_iv_ptr; else if (session->p.cipher_iv.data) iv_ptr = session->cipher.iv_data; else @@ -1101,7 +1101,7 @@ odp_crypto_operation(odp_crypto_op_param_t *param, int rc; packet_param.session = param->session; - packet_param.override_iv_ptr = param->override_iv_ptr; + packet_param.cipher_iv_ptr = param->cipher_iv_ptr; packet_param.hash_result_offset = param->hash_result_offset; packet_param.aad_ptr = param->aad_ptr; packet_param.cipher_range = param->cipher_range; diff --git a/platform/linux-generic/odp_ipsec.c b/platform/linux-generic/odp_ipsec.c index b023d308d..ab4fb5543 100644 --- a/platform/linux-generic/odp_ipsec.c +++ b/platform/linux-generic/odp_ipsec.c @@ -477,7 +477,7 @@ static int ipsec_in_esp(odp_packet_t *pkt, state->ip_hdr_len - state->in.hdr_len - ipsec_sa->icv_len; - param->override_iv_ptr = state->iv; + param->cipher_iv_ptr = state->iv; state->esp.aad.spi = esp.spi; state->esp.aad.seq_no = esp.seq_no; @@ -560,7 +560,7 @@ static int ipsec_in_ah(odp_packet_t *pkt, return -1; } - param->override_iv_ptr = state->iv; + param->cipher_iv_ptr = state->iv; state->in.hdr_len = (ah.ah_len + 2) * 4; state->in.trl_len = 0; @@ -1079,7 +1079,7 @@ static int ipsec_out_esp(odp_packet_t *pkt, return -1; } - param->override_iv_ptr = state->iv; + param->cipher_iv_ptr = state->iv; memset(&esp, 0, sizeof(esp)); esp.spi = odp_cpu_to_be_32(ipsec_sa->spi); @@ -1229,7 +1229,7 @@ static int ipsec_out_ah(odp_packet_t *pkt, return -1; } - param->override_iv_ptr = state->iv; + param->cipher_iv_ptr = state->iv; if (odp_packet_extend_head(pkt, hdr_len, NULL, NULL) < 0) { status->error.alg = 1; diff --git a/test/validation/api/crypto/odp_crypto_test_inp.c b/test/validation/api/crypto/odp_crypto_test_inp.c index d795baafc..7309b5d52 100644 --- a/test/validation/api/crypto/odp_crypto_test_inp.c +++ b/test/validation/api/crypto/odp_crypto_test_inp.c @@ -78,7 +78,7 @@ static const char *cipher_alg_name(odp_cipher_alg_t cipher) static int alg_op(odp_packet_t pkt, odp_bool_t *ok, odp_crypto_session_t session, - uint8_t *op_iv_ptr, + uint8_t *cipher_iv_ptr, odp_packet_data_range_t *cipher_range, odp_packet_data_range_t *auth_range, uint8_t *aad, @@ -99,8 +99,8 @@ static int alg_op(odp_packet_t pkt, op_params.cipher_range = *cipher_range; op_params.auth_range = *auth_range; - if (op_iv_ptr) - op_params.override_iv_ptr = op_iv_ptr; + if (cipher_iv_ptr) + op_params.cipher_iv_ptr = cipher_iv_ptr; op_params.aad_ptr = aad; @@ -153,7 +153,7 @@ static int alg_op(odp_packet_t pkt, static int alg_packet_op(odp_packet_t pkt, odp_bool_t *ok, odp_crypto_session_t session, - uint8_t *op_iv_ptr, + uint8_t *cipher_iv_ptr, odp_packet_data_range_t *cipher_range, odp_packet_data_range_t *auth_range, uint8_t *aad, @@ -171,8 +171,8 @@ static int alg_packet_op(odp_packet_t pkt, op_params.cipher_range = *cipher_range; op_params.auth_range = *auth_range; - if (op_iv_ptr) - op_params.override_iv_ptr = op_iv_ptr; + if (cipher_iv_ptr) + op_params.cipher_iv_ptr = cipher_iv_ptr; op_params.aad_ptr = aad; @@ -210,7 +210,7 @@ static int alg_packet_op(odp_packet_t pkt, static int alg_packet_op_enq(odp_packet_t pkt, odp_bool_t *ok, odp_crypto_session_t session, - uint8_t *op_iv_ptr, + uint8_t *cipher_iv_ptr, odp_packet_data_range_t *cipher_range, odp_packet_data_range_t *auth_range, uint8_t *aad, @@ -229,8 +229,8 @@ static int alg_packet_op_enq(odp_packet_t pkt, op_params.cipher_range = *cipher_range; op_params.auth_range = *auth_range; - if (op_iv_ptr) - op_params.override_iv_ptr = op_iv_ptr; + if (cipher_iv_ptr) + op_params.cipher_iv_ptr = cipher_iv_ptr; op_params.aad_ptr = aad;