Skip to contentSkip to conversation

make struct key * argument of init_key_ctx const

PATCH In review Steffan Karger 2 participants 4 messages Oct 23, 2017 – Nov 3, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 make struct key * argument of init_key_ctx const

This can be const, and should thus be const. (Also, resolves a compiler warning.)

---
 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(-)
src/openvpn/crypto.c +1 -1
index 704ec71..566a1f6 100644
@@ -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)
 {
src/openvpn/crypto.h +1 -1
index 86b2863..8fbfdf0 100644
@@ -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);
 
src/openvpn/crypto_backend.h +1 -1
index 4644ca0..07e7358 100644
@@ -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);
 
 /**
src/openvpn/crypto_mbedtls.c +1 -1
index c6a2c26..adef7ce 100644
@@ -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);
src/openvpn/crypto_openssl.c +1 -1
index 439d8df..61d610d 100644
@@ -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);
Signature · 1 line
2.7.4
#1 lore raw

Hi,

Quoted 11 lines · Steffan Karger

This can be const, and should thus be const. (Also, resolves a compiler warning.)

---
 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

Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
                                                           //www.muc.de/~gert/
Gert Doering - Munich, Germany                             [email protected]...
fax: +49-89-35655025                        [email protected]...
#2 lore raw

Hi,

Quoted 3 lines · Gert Doering
Quoted 2 lines · Steffan Karger

This can be const, and should thus be const. (Also, resolves a compiler warning.)

[..]

Quoted 7 lines

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

Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
                                                           //www.muc.de/~gert/
Gert Doering - Munich, Germany                             [email protected]...
fax: +49-89-35655025                        [email protected]...
#3 lore raw
In reply to Steffan Karger

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 <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg15660.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering