2022-02-21 16:13:25

by Nicolai Stange

[permalink] [raw]
Subject: [PATCH v4 04/15] crypto: dh - constify struct dh's pointer members

struct dh contains several pointer members corresponding to DH parameters:
->key, ->p and ->g. A subsequent commit will introduce "dh" wrapping
templates of the form "ffdhe2048(dh)", "ffdhe3072(dh)" and so on in order
to provide built-in support for the well-known safe-prime ffdhe group
parameters specified in RFC 7919. These templates will need to set the
group parameter related members of the (serialized) struct dh instance
passed to the inner "dh" kpp_alg instance, i.e. ->p and ->g, to some
constant, static storage arrays.

Turn the struct dh pointer members' types into "pointer to const" in
preparation for this.

Signed-off-by: Nicolai Stange <[email protected]>
---
include/crypto/dh.h | 6 +++---
security/keys/dh.c | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/crypto/dh.h b/include/crypto/dh.h
index 2585f0e6bb69..67f3f6bca527 100644
--- a/include/crypto/dh.h
+++ b/include/crypto/dh.h
@@ -30,9 +30,9 @@
* @g_size: Size of DH generator G
*/
struct dh {
- void *key;
- void *p;
- void *g;
+ const void *key;
+ const void *p;
+ const void *g;
unsigned int key_size;
unsigned int p_size;
unsigned int g_size;
diff --git a/security/keys/dh.c b/security/keys/dh.c
index 4573fc15617d..b339760a31dd 100644
--- a/security/keys/dh.c
+++ b/security/keys/dh.c
@@ -15,7 +15,7 @@
#include <keys/user-type.h>
#include "internal.h"

-static ssize_t dh_data_from_key(key_serial_t keyid, void **data)
+static ssize_t dh_data_from_key(key_serial_t keyid, const void **data)
{
struct key *key;
key_ref_t key_ref;
--
2.26.2


2022-02-21 17:55:31

by Hannes Reinecke

[permalink] [raw]
Subject: Re: [PATCH v4 04/15] crypto: dh - constify struct dh's pointer members

On 2/21/22 13:10, Nicolai Stange wrote:
> struct dh contains several pointer members corresponding to DH parameters:
> ->key, ->p and ->g. A subsequent commit will introduce "dh" wrapping
> templates of the form "ffdhe2048(dh)", "ffdhe3072(dh)" and so on in order
> to provide built-in support for the well-known safe-prime ffdhe group
> parameters specified in RFC 7919. These templates will need to set the
> group parameter related members of the (serialized) struct dh instance
> passed to the inner "dh" kpp_alg instance, i.e. ->p and ->g, to some
> constant, static storage arrays.
>
> Turn the struct dh pointer members' types into "pointer to const" in
> preparation for this.
>
> Signed-off-by: Nicolai Stange <[email protected]>
> ---
> include/crypto/dh.h | 6 +++---
> security/keys/dh.c | 2 +-
> 2 files changed, 4 insertions(+), 4 deletions(-)
>
Reviewed-by: Hannes Reinecke <[email protected]>

Cheers,

Hannes
--
Dr. Hannes Reinecke Kernel Storage Architect
[email protected] +49 911 74053 688
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), GF: Felix Imendörffer