[Openvpn-devel] make struct key * argument of init_key_ctx const

Message ID 1508751613-23728-1-git-send-email-steffan.karger@fox-it.com
State Accepted
Headers show
Series [Openvpn-devel] make struct key * argument of init_key_ctx const | expand

Commit Message

Steffan Karger Oct. 22, 2017, 10:40 p.m. UTC
This can be const, and should thus be const.  (Also, resolves a compiler
warning.)

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
---
 src/openvpn/crypto.c         | 2 +-
 src/openvpn/crypto.h         | 2 +-
 src/openvpn/crypto_backend.h | 2 +-
 src/openvpn/crypto_mbedtls.c | 2 +-
 src/openvpn/crypto_openssl.c | 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

Comments

Gert Doering Nov. 3, 2017, 7:24 a.m. UTC | #1
Hi,

On Mon, Oct 23, 2017 at 11:40:13AM +0200, Steffan Karger wrote:
> This can be const, and should thus be const.  (Also, resolves a compiler
> warning.)
> 
> Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
> ---
>  src/openvpn/crypto.c         | 2 +-
>  src/openvpn/crypto.h         | 2 +-
>  src/openvpn/crypto_backend.h | 2 +-
>  src/openvpn/crypto_mbedtls.c | 2 +-
>  src/openvpn/crypto_openssl.c | 2 +-
>  5 files changed, 5 insertions(+), 5 deletions(-)

I think the patch is good, but it *so* does not apply for me...

Applying: make struct key * argument of init_key_ctx const
error: patch failed: src/openvpn/crypto.c:826
error: src/openvpn/crypto.c: patch does not apply
error: patch failed: src/openvpn/crypto.h:321
error: src/openvpn/crypto.h: patch does not apply
error: patch failed: src/openvpn/crypto_backend.h:334
error: src/openvpn/crypto_backend.h: patch does not apply
error: patch failed: src/openvpn/crypto_mbedtls.c:563
error: src/openvpn/crypto_mbedtls.c: patch does not apply
error: patch failed: src/openvpn/crypto_openssl.c:677
error: src/openvpn/crypto_openssl.c: patch does not apply
Patch failed at 0001 make struct key * argument of init_key_ctx const

what tree is this based on...?

gert
Gert Doering Nov. 3, 2017, 7:27 a.m. UTC | #2
Hi,

On Fri, Nov 03, 2017 at 07:24:33PM +0100, Gert Doering wrote:
> On Mon, Oct 23, 2017 at 11:40:13AM +0200, Steffan Karger wrote:
> > This can be const, and should thus be const.  (Also, resolves a compiler
> > warning.)
[..]
> I think the patch is good, but it *so* does not apply for me...
> 
> Applying: make struct key * argument of init_key_ctx const
> error: patch failed: src/openvpn/crypto.c:826
> error: src/openvpn/crypto.c: patch does not apply
> error: patch failed: src/openvpn/crypto.h:321
> error: src/openvpn/crypto.h: patch does not apply

Looked at the first two occurences, and the confusion is explained - this
change is already in "master" but not in 2.4

master/crypto.h

void init_key_ctx(struct key_ctx *ctx, const struct key *key,
                  const struct key_type *kt, int enc,
                  const char *prefix);

2.4/crypto.h

void init_key_ctx(struct key_ctx *ctx, struct key *key,
                  const struct key_type *kt, int enc,
                  const char *prefix);

I'm too lazy to trace which patch changed master, and did not get 
cherrypicked to 2.4 - but this is reasonable to apply to 2.4 (-only),
so I will :-) - ACK.

gert
Gert Doering Nov. 3, 2017, 7:32 a.m. UTC | #3
ACK, 2.4-only (already in master)

Your patch has been applied to the release/2.4 branch.

commit 94793462a977ad09c14530ff20eedc98bb35d36c
Author: Steffan Karger
Date:   Mon Oct 23 11:40:13 2017 +0200

     make struct key * argument of init_key_ctx const

     Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
     Acked-by: Gert Doering <gert@greenie.muc.de>
     Message-Id: <1508751613-23728-1-git-send-email-steffan.karger@fox-it.com>
     URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15660.html
     Signed-off-by: Gert Doering <gert@greenie.muc.de>


--
kind regards,

Gert Doering


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

Patch

diff --git a/src/openvpn/crypto.c b/src/openvpn/crypto.c
index 704ec71..566a1f6 100644
--- a/src/openvpn/crypto.c
+++ b/src/openvpn/crypto.c
@@ -826,7 +826,7 @@  init_key_type(struct key_type *kt, const char *ciphername,
 
 /* given a key and key_type, build a key_ctx */
 void
-init_key_ctx(struct key_ctx *ctx, struct key *key,
+init_key_ctx(struct key_ctx *ctx, const struct key *key,
              const struct key_type *kt, int enc,
              const char *prefix)
 {
diff --git a/src/openvpn/crypto.h b/src/openvpn/crypto.h
index 86b2863..8fbfdf0 100644
--- a/src/openvpn/crypto.h
+++ b/src/openvpn/crypto.h
@@ -321,7 +321,7 @@  void init_key_type(struct key_type *kt, const char *ciphername,
  * Key context functions
  */
 
-void init_key_ctx(struct key_ctx *ctx, struct key *key,
+void init_key_ctx(struct key_ctx *ctx, const struct key *key,
                   const struct key_type *kt, int enc,
                   const char *prefix);
 
diff --git a/src/openvpn/crypto_backend.h b/src/openvpn/crypto_backend.h
index 4644ca0..07e7358 100644
--- a/src/openvpn/crypto_backend.h
+++ b/src/openvpn/crypto_backend.h
@@ -334,7 +334,7 @@  void cipher_ctx_free(cipher_ctx_t *ctx);
  * @param enc           Whether to encrypt or decrypt (either
  *                      \c MBEDTLS_OP_ENCRYPT or \c MBEDTLS_OP_DECRYPT).
  */
-void cipher_ctx_init(cipher_ctx_t *ctx, uint8_t *key, int key_len,
+void cipher_ctx_init(cipher_ctx_t *ctx, const uint8_t *key, int key_len,
                      const cipher_kt_t *kt, int enc);
 
 /**
diff --git a/src/openvpn/crypto_mbedtls.c b/src/openvpn/crypto_mbedtls.c
index c6a2c26..adef7ce 100644
--- a/src/openvpn/crypto_mbedtls.c
+++ b/src/openvpn/crypto_mbedtls.c
@@ -563,7 +563,7 @@  cipher_ctx_free(mbedtls_cipher_context_t *ctx)
 }
 
 void
-cipher_ctx_init(mbedtls_cipher_context_t *ctx, uint8_t *key, int key_len,
+cipher_ctx_init(mbedtls_cipher_context_t *ctx, const uint8_t *key, int key_len,
                 const mbedtls_cipher_info_t *kt, const mbedtls_operation_t operation)
 {
     ASSERT(NULL != kt && NULL != ctx);
diff --git a/src/openvpn/crypto_openssl.c b/src/openvpn/crypto_openssl.c
index 439d8df..61d610d 100644
--- a/src/openvpn/crypto_openssl.c
+++ b/src/openvpn/crypto_openssl.c
@@ -677,7 +677,7 @@  cipher_ctx_free(EVP_CIPHER_CTX *ctx)
 }
 
 void
-cipher_ctx_init(EVP_CIPHER_CTX *ctx, uint8_t *key, int key_len,
+cipher_ctx_init(EVP_CIPHER_CTX *ctx, const uint8_t *key, int key_len,
                 const EVP_CIPHER *kt, int enc)
 {
     ASSERT(NULL != kt && NULL != ctx);