From patchwork Mon Nov 11 01:59:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "mrbff (Code Review)" X-Patchwork-Id: 3928 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:41ba:b0:5d9:9f4c:3bc7 with SMTP id a26csp2278037mad; Sun, 10 Nov 2024 18:00:10 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVh0uUh3KqxGh4XszlAMxY9DgbDjIXP6Gpc9SyXzfa7vhtXkG5UZJeJcbSWhWEAldXeIfRMi10Us1I=@openvpn.net X-Google-Smtp-Source: AGHT+IH/tPpj9ip7hhKr3fSwOTpoGrUX4P6afM4J4GRmitAaDD95n9uiad4d8U74VfhVocLk3kzp X-Received: by 2002:a05:6830:6008:b0:716:a95d:9ef with SMTP id 46e09a7af769-71a1c1e0e15mr9698859a34.2.1731290410178; Sun, 10 Nov 2024 18:00:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1731290410; cv=none; d=google.com; s=arc-20240605; b=GIZhAkmRssWnDxBopm6/+oBW+NzNQPaf336N8WWxhGlz8b+74q4GK6XCwN4UscADZI 4Dvd68PUNYpsD+qTzF0lTAdNvVJOrMPqK4/wzlIDzNJiVtIFTE6WCI0Gd7VcgmqU8wGg wg6UQQRQnB+YDR0x0lTF3bku18hldluQfUYnTuoSc4/h4MpACmOu3DyzLotx8ByunYoV tGcYknu9spCCS6SuoV6AEo3uyJhz0dzyt1ZqXKUS8bLj775sUUzBZf7ROXahQtptpOO6 23jgL+WqMAB7E0s1IBkHZCkFfOYh6hd+OnWZNRRk9DSkfe+23762NnjUVwwMsnuXYm3l TK5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=errors-to:cc:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject:user-agent :mime-version:message-id:references:auto-submitted:to:date:from :dkim-signature:dkim-signature:dkim-signature; bh=u+XvgMSs3ExLZPjtgLgo/u3Tr2KYb2t1XaAFnkf87HU=; fh=lm0MLPW7DntlrDqRECIiC9JlE1uPxhepE0URYHIf+eE=; b=Rc2UbBYFgAhY5D3Z/WODPV3MYAtkxUgdHV68n70MQq/BpmSUVHnbyRJRD5snRp+rku izSkiz6AebSTK9UUBVjRog9SVH+uT4J06Dolf7IqrVgt5LQvcczBgFGYXIQo/zvJOV7/ PxVvXo2V/GivoyJe5mjY9aUb6RWLp2fTBce7094tK46Mv0V99Xbi2F9cmPkhz3c5XvS4 hfsLCU0heWLjAC4QbffPx8v0G2OQz/YSdCn8fXxg0oOX2+LrxLLtlisYZNTcTFNyZosG 7q20rykMB9SmyhpppW5RZbzsd8xOGxITR9OWi/aEK79bzKliKANUcCxw3r2usqiD51Sv DITw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=IISnQ2I4; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=Znr+J8Wp; dkim=neutral (body hash did not verify) header.i=@openvpn.net header.s=google header.b=Nn9LXwPw; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=openvpn.net; dara=fail header.i=@openvpn.net Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id 006d021491bc7-5ee495202ffsi18771eaf.52.2024.11.10.18.00.09 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 Nov 2024 18:00:10 -0800 (PST) Received-SPF: pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) client-ip=216.105.38.7; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=IISnQ2I4; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=Znr+J8Wp; dkim=neutral (body hash did not verify) header.i=@openvpn.net header.s=google header.b=Nn9LXwPw; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=openvpn.net; dara=fail header.i=@openvpn.net Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1tAJig-0005K5-Gr; Mon, 11 Nov 2024 01:59:58 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1tAJie-0005Jt-TB for openvpn-devel@lists.sourceforge.net; Mon, 11 Nov 2024 01:59:56 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Type:Content-Transfer-Encoding:MIME-Version :Message-ID:Reply-To:References:Subject:List-Unsubscribe:List-Id:Cc:To:Date: From:Sender:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:List-Help: List-Subscribe:List-Post:List-Owner:List-Archive; bh=9Y3lJ1sLPXZpDUsheMyb0cGk0ljB71hhiD6PiVwhZts=; b=IISnQ2I4GaeqPfnDREZuQpKfrP 713lYgKHDJ2l7/GqJ0F5qzSq9dzXltsMVUK+4sdgLyUaX9RkvuxCkG71HMSdqcSO5iXPHO/8VkSUo dDyG8zaELPDFArDzMLOpcR4XRbe6Yyur4/chTckZ+GiHPyb0cmKuUjpLGlwgJYYfubBU=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Type:Content-Transfer-Encoding:MIME-Version:Message-ID:Reply-To: References:Subject:List-Unsubscribe:List-Id:Cc:To:Date:From:Sender:Content-ID :Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To: Resent-Cc:Resent-Message-ID:In-Reply-To:List-Help:List-Subscribe:List-Post: List-Owner:List-Archive; bh=9Y3lJ1sLPXZpDUsheMyb0cGk0ljB71hhiD6PiVwhZts=; b=Z nr+J8WpAGhgN7lpy75h5m7fkxRvSNYw3QVKpd2pvsC+A0fuQgvSQfzkMJvSmxpZEHGM7JDsPpIMwz JPbeFiyXbhQqyXy40v5RO5C7xMcewulRDa+4X60sp4WbQW88GQ7/4qfKo/049XtYi7xwOXcdgo4YS AmxdA4A9FwrlD2hs=; Received: from mail-wm1-f48.google.com ([209.85.128.48]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1tAJid-0001YP-DJ for openvpn-devel@lists.sourceforge.net; Mon, 11 Nov 2024 01:59:56 +0000 Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-43167ff0f91so35267505e9.1 for ; Sun, 10 Nov 2024 17:59:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvpn.net; s=google; t=1731290386; x=1731895186; darn=lists.sourceforge.net; h=user-agent:content-disposition:content-transfer-encoding :mime-version:message-id:reply-to:references:subject :list-unsubscribe:list-id:auto-submitted:cc:to:date:from:from:to:cc :subject:date:message-id:reply-to; bh=9Y3lJ1sLPXZpDUsheMyb0cGk0ljB71hhiD6PiVwhZts=; b=Nn9LXwPwzdI6hXpMk9ERsxBv3Rz1Dv4i2kw6pCB7B38/u6B60Q9S71L7x12eCO9PeT 6fsGu4ke/9AgQeUd6nquYqmwIMaCLIBAK1/qV+snQ9VG51PH+uPWGfPYRpuzEn/C85T/ dEZXlyXdqQ1knsgsr//bWC6i+zXu4Ao3npFFc06gXxM33ChifshzAOdvQWAyMNQHgru9 hXNj6Is5ACUfoRGMWs1X3sJuC01tAIKt/Y7AGt3OhcOkN3vv7nre92omvxGFeBfhQBmn Ouq5GPUPFNK4cjqTC30lWrrSdYd2IPLQ6JF22tYtDLQjxB8AxDQKhQnHaTNkiOBWG/Y5 TqfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731290386; x=1731895186; h=user-agent:content-disposition:content-transfer-encoding :mime-version:message-id:reply-to:references:subject :list-unsubscribe:list-id:auto-submitted:cc:to:date:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=9Y3lJ1sLPXZpDUsheMyb0cGk0ljB71hhiD6PiVwhZts=; b=kJAgpWDFs/iQ0cAN0+CCDK3vrnowSjuA5ZUZS0BC+86X884/dK6T+PuMhRI9nrjr/A s/hFi7kmB20ujlaWn8KXgWqrk7lu2L8BHc3XHO4UD5nx1gwypq/P7DQY56MesyRkdBGX khWEgPx7AWnXBrwEYizBmDRTDHyYkRzCZW79vrnzYNoK7qtlueAeL0tbpxMkztR8oV3o 1RqhMAz9LJArB9vx/6IOwS0YUSzCrHPUOQkIkaOtqOjKWvFFtO8ILo1+uZd6gVLj3ilw mSHRBpI+5Wj5spls5COyahwzY+w973s4wz0xAegLayzvu6ZsMz7qmBb4nvRpxgFbqRHz X2HA== X-Gm-Message-State: AOJu0YzPK/8ZQLf14Cgy/AMduL+tr6Jgo3finXhEQMyN3tUbUPXO96Tv MfP/Jr2FnW0ycw5TPRbfxfFyAVQObmQzpp7JCH0jPiGwrOrksBcZr94C6I0sg/Wl19T+n8dyNw/ x X-Received: by 2002:a05:600c:3b22:b0:431:52da:9d67 with SMTP id 5b1f17b1804b1-432b74fdaf9mr93667455e9.3.1731290386099; Sun, 10 Nov 2024 17:59:46 -0800 (PST) Received: from gerrit.openvpn.in (ec2-18-159-0-78.eu-central-1.compute.amazonaws.com. [18.159.0.78]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-432b04753d5sm165521515e9.0.2024.11.10.17.59.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Nov 2024 17:59:45 -0800 (PST) From: "plaisthos (Code Review)" X-Google-Original-From: "plaisthos (Code Review)" X-Gerrit-PatchSet: 1 Date: Mon, 11 Nov 2024 01:59:44 +0000 To: flichtenheld Auto-Submitted: auto-generated X-Gerrit-MessageType: newchange X-Gerrit-Change-Id: I74216d776d3e0a8dc987ec7b1671c8e8dcccdbd6 X-Gerrit-Change-Number: 797 X-Gerrit-Project: openvpn X-Gerrit-ChangeURL: X-Gerrit-Commit: 59ea1b1bf44959059e7f89362cc4e8c7dffc9974 References: Message-ID: <5719683e0d368a4edae012ee66a335b2d08f57aa-HTML@gerrit.openvpn.net> MIME-Version: 1.0 User-Agent: Gerrit/3.8.2 X-Spam-Score: -0.9 (/) X-Spam-Report: Spam detection software, running on the system "util-spamd-2.v13.lw.sourceforge.com", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Attention is currently required from: flichtenheld. Hello flichtenheld, I'd like you to do a code review. Please visit Content analysis details: (-0.9 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.128.48 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.7 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.128.48 listed in wl.mailspike.net] 0.0 WEIRD_PORT URI: Uses non-standard port number for HTTP 0.0 HTML_MESSAGE BODY: HTML included in message -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.0 T_KAM_HTML_FONT_INVALID Test for Invalidly Named or Formatted Colors in HTML X-Headers-End: 1tAJid-0001YP-DJ Subject: [Openvpn-devel] [M] Change in openvpn[master]: Use XOR instead of concatenation for calculation of IV from implicit IV X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: arne-openvpn@rfc2549.org, openvpn-devel@lists.sourceforge.net, frank@lichtenheld.com Cc: openvpn-devel Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: =?utf-8?q?1815389573038069846?= X-GMAIL-MSGID: =?utf-8?q?1815389573038069846?= X-getmail-filter-classifier: gerrit message type newchange Attention is currently required from: flichtenheld. Hello flichtenheld, I'd like you to do a code review. Please visit http://gerrit.openvpn.net/c/openvpn/+/797?usp=email to review the following change. Change subject: Use XOR instead of concatenation for calculation of IV from implicit IV ...................................................................... Use XOR instead of concatenation for calculation of IV from implicit IV This change prepares the extended packet id data where also the packet id part of the IV will be derived using xor. Using xor also in the AEAD case where this degenerates to a concatenation allows using the same IV generation code later. Change-Id: I74216d776d3e0a8dc987ec7b1671c8e8dcccdbd6 Signed-off-by: Arne Schwabe --- M src/openvpn/crypto.c M src/openvpn/crypto.h M src/openvpn/dco_freebsd.c M src/openvpn/dco_linux.c M src/openvpn/dco_win.c M src/openvpn/ssl.c M tests/unit_tests/openvpn/test_ssl.c 7 files changed, 37 insertions(+), 23 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/97/797/1 diff --git a/src/openvpn/crypto.c b/src/openvpn/crypto.c index d136663..a366474 100644 --- a/src/openvpn/crypto.c +++ b/src/openvpn/crypto.c @@ -95,12 +95,16 @@ goto err; } - /* Remainder of IV consists of implicit part (unique per session) */ - ASSERT(buf_write(&iv_buffer, ctx->implicit_iv, ctx->implicit_iv_len)); - ASSERT(iv_buffer.len == iv_len); + /* Write packet id part of IV to work buffer */ + ASSERT(buf_write(&work, iv, packet_id_size(false))); - /* Write explicit part of IV to work buffer */ - ASSERT(buf_write(&work, iv, iv_len - ctx->implicit_iv_len)); + /* Remainder of IV consists of implicit part (unique per session) + * XOR of packet and implicit IV */ + for (int i = 0; i < iv_len; i++) + { + iv[i] = iv[i] ^ ctx->implicit_iv[i]; + } + dmsg(D_PACKET_CONTENT, "ENCRYPT IV: %s", format_hex(iv, iv_len, 0, &gc)); /* Init cipher_ctx with IV. key & keylen are already initialized */ @@ -428,16 +432,21 @@ { uint8_t iv[OPENVPN_MAX_IV_LENGTH] = { 0 }; const int iv_len = cipher_ctx_iv_length(ctx->cipher); - const size_t packet_iv_len = iv_len - ctx->implicit_iv_len; + const size_t packet_iv_len = packet_id_size(false); - ASSERT(ctx->implicit_iv_len <= iv_len); - if (buf->len + ctx->implicit_iv_len < iv_len) + if (buf->len < packet_id_size(false)) { CRYPT_ERROR("missing IV info"); } memcpy(iv, BPTR(buf), packet_iv_len); - memcpy(iv + packet_iv_len, ctx->implicit_iv, ctx->implicit_iv_len); + + /* Remainder of IV consists of implicit part (unique per session) + * XOR of packet counter and implicit IV */ + for (int i = 0; i < iv_len; i++) + { + iv[i] = iv[i] ^ ctx->implicit_iv[i]; + } dmsg(D_PACKET_CONTENT, "DECRYPT IV: %s", format_hex(iv, iv_len, 0, &gc)); @@ -963,7 +972,6 @@ hmac_ctx_free(ctx->hmac); ctx->hmac = NULL; } - ctx->implicit_iv_len = 0; } void @@ -1079,18 +1087,15 @@ cipher_ctx_t *cipher = co->key_ctx_bi.encrypt.cipher; if (cipher_ctx_mode_aead(cipher)) { - size_t impl_iv_len = cipher_ctx_iv_length(cipher) - sizeof(packet_id_type); ASSERT(cipher_ctx_iv_length(cipher) <= OPENVPN_MAX_IV_LENGTH); ASSERT(cipher_ctx_iv_length(cipher) >= OPENVPN_AEAD_MIN_IV_LEN); /* Generate dummy implicit IV */ ASSERT(rand_bytes(co->key_ctx_bi.encrypt.implicit_iv, OPENVPN_MAX_IV_LENGTH)); - co->key_ctx_bi.encrypt.implicit_iv_len = impl_iv_len; memcpy(co->key_ctx_bi.decrypt.implicit_iv, co->key_ctx_bi.encrypt.implicit_iv, OPENVPN_MAX_IV_LENGTH); - co->key_ctx_bi.decrypt.implicit_iv_len = impl_iv_len; } } diff --git a/src/openvpn/crypto.h b/src/openvpn/crypto.h index 7b0f713..0ae86f4 100644 --- a/src/openvpn/crypto.h +++ b/src/openvpn/crypto.h @@ -163,9 +163,14 @@ { cipher_ctx_t *cipher; /**< Generic cipher %context. */ hmac_ctx_t *hmac; /**< Generic HMAC %context. */ + /** + * This implicit IV will be always XORed with the packet id that is sent on + * the wire to get the IV. For the older AEAD format the first 32 bits + * of implicit_iv are always 0 so this works as concatenation: after xor + * the lower 32 bit of the IV are the packet id and the rest of the IV is + * from the implicit IV. + */ uint8_t implicit_iv[OPENVPN_MAX_IV_LENGTH]; - /**< The implicit part of the IV */ - size_t implicit_iv_len; /**< The length of implicit_iv */ /** Counter for the number of plaintext encrypted using this cipher * in number of 128 bit blocks (only used for AEAD ciphers) */ uint64_t plaintext_blocks; diff --git a/src/openvpn/dco_freebsd.c b/src/openvpn/dco_freebsd.c index f4c3b02..bdde16f 100644 --- a/src/openvpn/dco_freebsd.c +++ b/src/openvpn/dco_freebsd.c @@ -395,7 +395,9 @@ key_len = cipher_kt_key_size(ciphername); nvlist_add_binary(nvl, "key", key, key_len); - nvlist_add_binary(nvl, "iv", implicit_iv, 8); + /* FreeBSD uses the contact operation, need to skip the first 4 null + * bytes */ + nvlist_add_binary(nvl, "iv", implicit_iv + 4, 8); } return (nvl); diff --git a/src/openvpn/dco_linux.c b/src/openvpn/dco_linux.c index b038382..c3e2ecc 100644 --- a/src/openvpn/dco_linux.c +++ b/src/openvpn/dco_linux.c @@ -585,8 +585,9 @@ if (dco_cipher != OVPN_CIPHER_ALG_NONE) { NLA_PUT(nl_msg, OVPN_KEY_DIR_ATTR_CIPHER_KEY, key_len, encrypt_key); + /* First 4 zero bytes as the kernel does concat instead of XOR */ NLA_PUT(nl_msg, OVPN_KEY_DIR_ATTR_NONCE_TAIL, nonce_tail_len, - encrypt_iv); + encrypt_iv + 4); } nla_nest_end(nl_msg, key_enc); @@ -595,8 +596,9 @@ if (dco_cipher != OVPN_CIPHER_ALG_NONE) { NLA_PUT(nl_msg, OVPN_KEY_DIR_ATTR_CIPHER_KEY, key_len, decrypt_key); + /* First 4 zero bytes as the kernel does concat instead of XOR */ NLA_PUT(nl_msg, OVPN_KEY_DIR_ATTR_NONCE_TAIL, nonce_tail_len, - decrypt_iv); + decrypt_iv + 4); } nla_nest_end(nl_msg, key_dec); diff --git a/src/openvpn/dco_win.c b/src/openvpn/dco_win.c index 9224bca..8f07ead 100644 --- a/src/openvpn/dco_win.c +++ b/src/openvpn/dco_win.c @@ -314,10 +314,12 @@ CopyMemory(crypto_data.Encrypt.Key, encrypt_key, key_len); crypto_data.Encrypt.KeyLen = (char)key_len; + /* First 4 zero bytes as ovpn-dco-win does concat instead of XOR */ CopyMemory(crypto_data.Encrypt.NonceTail, encrypt_iv, nonce_len); CopyMemory(crypto_data.Decrypt.Key, decrypt_key, key_len); crypto_data.Decrypt.KeyLen = (char)key_len; + /* First 4 zero bytes as ovpn-dco-win does concat instead of XOR */ CopyMemory(crypto_data.Decrypt.NonceTail, decrypt_iv, nonce_len); ASSERT(crypto_data.CipherAlg > 0); diff --git a/src/openvpn/ssl.c b/src/openvpn/ssl.c index a8cc83b..2d6cf64 100644 --- a/src/openvpn/ssl.c +++ b/src/openvpn/ssl.c @@ -1562,8 +1562,9 @@ impl_iv_len = cipher_ctx_iv_length(ctx->cipher) - sizeof(packet_id_type); ASSERT(impl_iv_len <= OPENVPN_MAX_IV_LENGTH); ASSERT(impl_iv_len <= key_len); - memcpy(ctx->implicit_iv, key, impl_iv_len); - ctx->implicit_iv_len = impl_iv_len; + CLEAR(ctx->implicit_iv); + /* The first bytes of the IV are filled with the packet id */ + memcpy(ctx->implicit_iv + sizeof(packet_id_type), key, impl_iv_len); } } diff --git a/tests/unit_tests/openvpn/test_ssl.c b/tests/unit_tests/openvpn/test_ssl.c index a1ca344..ae33cc6 100644 --- a/tests/unit_tests/openvpn/test_ssl.c +++ b/tests/unit_tests/openvpn/test_ssl.c @@ -284,18 +284,15 @@ if (cipher_ctx_mode_aead(cipher)) { - size_t impl_iv_len = cipher_ctx_iv_length(cipher) - sizeof(packet_id_type); ASSERT(cipher_ctx_iv_length(cipher) <= OPENVPN_MAX_IV_LENGTH); ASSERT(cipher_ctx_iv_length(cipher) >= OPENVPN_AEAD_MIN_IV_LEN); /* Generate dummy implicit IV */ ASSERT(rand_bytes(co->key_ctx_bi.encrypt.implicit_iv, OPENVPN_MAX_IV_LENGTH)); - co->key_ctx_bi.encrypt.implicit_iv_len = impl_iv_len; memcpy(co->key_ctx_bi.decrypt.implicit_iv, co->key_ctx_bi.encrypt.implicit_iv, OPENVPN_MAX_IV_LENGTH); - co->key_ctx_bi.decrypt.implicit_iv_len = impl_iv_len; } }