From 0e1bb3dc23db1b25df469375e5e7810a14c09c71 Mon Sep 17 00:00:00 2001 From: tobhe Date: Thu, 4 Feb 2021 20:38:26 +0000 Subject: [PATCH] Rename 'struct group' to 'struct dh_group' for more clarity and to avoid name clashes. ok patrick@ --- sbin/iked/dh.c | 84 +++++++++++++++++++++++------------------------ sbin/iked/dh.h | 22 ++++++------- sbin/iked/iked.h | 4 +-- sbin/iked/ikev2.c | 16 ++++----- 4 files changed, 63 insertions(+), 63 deletions(-) diff --git a/sbin/iked/dh.c b/sbin/iked/dh.c index 30bf2a32c94..577f7371cce 100644 --- a/sbin/iked/dh.c +++ b/sbin/iked/dh.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dh.c,v 1.26 2021/02/04 20:15:02 tobhe Exp $ */ +/* $OpenBSD: dh.c,v 1.27 2021/02/04 20:38:26 tobhe Exp $ */ /* * Copyright (c) 2010-2014 Reyk Floeter @@ -36,34 +36,34 @@ #include "dh.h" #include "iked.h" -int dh_init(struct group *); -int dh_getlen(struct group *); -int dh_secretlen(struct group *); +int dh_init(struct dh_group *); +int dh_getlen(struct dh_group *); +int dh_secretlen(struct dh_group *); /* MODP */ -int modp_init(struct group *); -int modp_getlen(struct group *); -int modp_create_exchange(struct group *, uint8_t *); -int modp_create_shared(struct group *, uint8_t *, uint8_t *); +int modp_init(struct dh_group *); +int modp_getlen(struct dh_group *); +int modp_create_exchange(struct dh_group *, uint8_t *); +int modp_create_shared(struct dh_group *, uint8_t *, uint8_t *); /* ECP */ -int ec_init(struct group *); -int ec_getlen(struct group *); -int ec_secretlen(struct group *); -int ec_create_exchange(struct group *, uint8_t *); -int ec_create_shared(struct group *, uint8_t *, uint8_t *); +int ec_init(struct dh_group *); +int ec_getlen(struct dh_group *); +int ec_secretlen(struct dh_group *); +int ec_create_exchange(struct dh_group *, uint8_t *); +int ec_create_shared(struct dh_group *, uint8_t *, uint8_t *); #define EC_POINT2RAW_FULL 0 #define EC_POINT2RAW_XONLY 1 -int ec_point2raw(struct group *, const EC_POINT *, uint8_t *, size_t, int); +int ec_point2raw(struct dh_group *, const EC_POINT *, uint8_t *, size_t, int); EC_POINT * - ec_raw2point(struct group *, uint8_t *, size_t); + ec_raw2point(struct dh_group *, uint8_t *, size_t); /* curve25519 */ -int ec25519_init(struct group *); -int ec25519_getlen(struct group *); -int ec25519_create_exchange(struct group *, uint8_t *); -int ec25519_create_shared(struct group *, uint8_t *, uint8_t *); +int ec25519_init(struct dh_group *); +int ec25519_getlen(struct dh_group *); +int ec25519_create_exchange(struct dh_group *, uint8_t *); +int ec25519_create_shared(struct dh_group *, uint8_t *, uint8_t *); #define CURVE25519_SIZE 32 /* 256 bits */ struct curve25519_key { @@ -264,7 +264,7 @@ group_init(void) } void -group_free(struct group *group) +group_free(struct dh_group *group) { if (group == NULL) return; @@ -277,11 +277,11 @@ group_free(struct group *group) free(group); } -struct group * +struct dh_group * group_get(uint32_t id) { const struct group_id *p; - struct group *group; + struct dh_group *group; if ((p = group_getid(id)) == NULL) return (NULL); @@ -342,19 +342,19 @@ group_getid(uint32_t id) } int -dh_init(struct group *group) +dh_init(struct dh_group *group) { return (group->init(group)); } int -dh_getlen(struct group *group) +dh_getlen(struct dh_group *group) { return (group->getlen(group)); } int -dh_secretlen(struct group *group) +dh_secretlen(struct dh_group *group) { if (group->secretlen) return (group->secretlen(group)); @@ -363,7 +363,7 @@ dh_secretlen(struct group *group) } int -dh_create_exchange(struct group *group, struct ibuf **bufp, struct ibuf *iexchange) +dh_create_exchange(struct dh_group *group, struct ibuf **bufp, struct ibuf *iexchange) { struct ibuf *buf; @@ -376,7 +376,7 @@ dh_create_exchange(struct group *group, struct ibuf **bufp, struct ibuf *iexchan } int -dh_create_shared(struct group *group, struct ibuf **secretp, struct ibuf *exchange) +dh_create_shared(struct dh_group *group, struct ibuf **secretp, struct ibuf *exchange) { struct ibuf *buf; @@ -392,7 +392,7 @@ dh_create_shared(struct group *group, struct ibuf **secretp, struct ibuf *exchan } int -modp_init(struct group *group) +modp_init(struct dh_group *group) { BIGNUM *g = NULL, *p = NULL; DH *dh; @@ -418,7 +418,7 @@ modp_init(struct group *group) } int -modp_getlen(struct group *group) +modp_getlen(struct dh_group *group) { if (group->spec == NULL) return (0); @@ -426,7 +426,7 @@ modp_getlen(struct group *group) } int -modp_create_exchange(struct group *group, uint8_t *buf) +modp_create_exchange(struct dh_group *group, uint8_t *buf) { const BIGNUM *pub; DH *dh = group->dh; @@ -451,7 +451,7 @@ modp_create_exchange(struct group *group, uint8_t *buf) } int -modp_create_shared(struct group *group, uint8_t *secret, uint8_t *exchange) +modp_create_shared(struct dh_group *group, uint8_t *secret, uint8_t *exchange) { BIGNUM *ex; int len, ret; @@ -476,7 +476,7 @@ modp_create_shared(struct group *group, uint8_t *secret, uint8_t *exchange) } int -ec_init(struct group *group) +ec_init(struct dh_group *group) { if ((group->ec = EC_KEY_new_by_curve_name(group->spec->nid)) == NULL) return (-1); @@ -490,7 +490,7 @@ ec_init(struct group *group) } int -ec_getlen(struct group *group) +ec_getlen(struct dh_group *group) { if (group->spec == NULL) return (0); @@ -507,13 +507,13 @@ ec_getlen(struct group *group) * See also RFC 5903, 9. Changes from RFC 4753. */ int -ec_secretlen(struct group *group) +ec_secretlen(struct dh_group *group) { return (ec_getlen(group) / 2); } int -ec_create_exchange(struct group *group, uint8_t *buf) +ec_create_exchange(struct dh_group *group, uint8_t *buf) { size_t len; @@ -525,7 +525,7 @@ ec_create_exchange(struct group *group, uint8_t *buf) } int -ec_create_shared(struct group *group, uint8_t *secret, uint8_t *exchange) +ec_create_shared(struct dh_group *group, uint8_t *secret, uint8_t *exchange) { const EC_GROUP *ecgroup = NULL; const BIGNUM *privkey; @@ -573,7 +573,7 @@ ec_create_shared(struct group *group, uint8_t *secret, uint8_t *exchange) } int -ec_point2raw(struct group *group, const EC_POINT *point, +ec_point2raw(struct dh_group *group, const EC_POINT *point, uint8_t *buf, size_t len, int mode) { const EC_GROUP *ecgroup = NULL; @@ -638,7 +638,7 @@ ec_point2raw(struct group *group, const EC_POINT *point, } EC_POINT * -ec_raw2point(struct group *group, uint8_t *buf, size_t len) +ec_raw2point(struct dh_group *group, uint8_t *buf, size_t len) { const EC_GROUP *ecgroup = NULL; EC_POINT *point = NULL; @@ -689,7 +689,7 @@ ec_raw2point(struct group *group, uint8_t *buf, size_t len) } int -ec25519_init(struct group *group) +ec25519_init(struct dh_group *group) { static const uint8_t basepoint[CURVE25519_SIZE] = { 9 }; struct curve25519_key *curve25519; @@ -707,7 +707,7 @@ ec25519_init(struct group *group) } int -ec25519_getlen(struct group *group) +ec25519_getlen(struct dh_group *group) { if (group->spec == NULL) return (0); @@ -715,7 +715,7 @@ ec25519_getlen(struct group *group) } int -ec25519_create_exchange(struct group *group, uint8_t *buf) +ec25519_create_exchange(struct dh_group *group, uint8_t *buf) { struct curve25519_key *curve25519 = group->curve25519; @@ -724,7 +724,7 @@ ec25519_create_exchange(struct group *group, uint8_t *buf) } int -ec25519_create_shared(struct group *group, uint8_t *shared, uint8_t *public) +ec25519_create_shared(struct dh_group *group, uint8_t *shared, uint8_t *public) { struct curve25519_key *curve25519 = group->curve25519; diff --git a/sbin/iked/dh.h b/sbin/iked/dh.h index c89b148a6ca..a97fd0fa1ef 100644 --- a/sbin/iked/dh.h +++ b/sbin/iked/dh.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dh.h,v 1.13 2020/10/28 20:54:13 tobhe Exp $ */ +/* $OpenBSD: dh.h,v 1.14 2021/02/04 20:38:26 tobhe Exp $ */ /* * Copyright (c) 2010-2013 Reyk Floeter @@ -34,7 +34,7 @@ struct group_id { int nid; }; -struct group { +struct dh_group { int id; const struct group_id *spec; @@ -43,22 +43,22 @@ struct group { void *ec; void *curve25519; - int (*init)(struct group *); - int (*getlen)(struct group *); - int (*secretlen)(struct group *); - int (*exchange)(struct group *, uint8_t *); - int (*shared)(struct group *, uint8_t *, uint8_t *); + int (*init)(struct dh_group *); + int (*getlen)(struct dh_group *); + int (*secretlen)(struct dh_group *); + int (*exchange)(struct dh_group *, uint8_t *); + int (*shared)(struct dh_group *, uint8_t *, uint8_t *); }; #define DH_MAXSZ 1024 /* 8192 bits */ void group_init(void); -void group_free(struct group *); -struct group *group_get(uint32_t); +void group_free(struct dh_group *); +struct dh_group *group_get(uint32_t); const struct group_id *group_getid(uint32_t); -int dh_create_exchange(struct group *, struct ibuf **, struct ibuf *); -int dh_create_shared(struct group *, struct ibuf **, struct ibuf *); +int dh_create_exchange(struct dh_group *, struct ibuf **, struct ibuf *); +int dh_create_shared(struct dh_group *, struct ibuf **, struct ibuf *); #endif /* DH_GROUP_H */ diff --git a/sbin/iked/iked.h b/sbin/iked/iked.h index bf94b98bd07..e748ee6020e 100644 --- a/sbin/iked/iked.h +++ b/sbin/iked/iked.h @@ -1,4 +1,4 @@ -/* $OpenBSD: iked.h,v 1.183 2021/02/01 16:37:48 tobhe Exp $ */ +/* $OpenBSD: iked.h,v 1.184 2021/02/04 20:38:26 tobhe Exp $ */ /* * Copyright (c) 2019 Tobias Heider @@ -369,7 +369,7 @@ struct iked_kex { struct ibuf *kex_inonce; /* Ni */ struct ibuf *kex_rnonce; /* Nr */ - struct group *kex_dhgroup; /* DH group */ + struct dh_group *kex_dhgroup; /* DH group */ struct ibuf *kex_dhiexchange; struct ibuf *kex_dhrexchange; struct ibuf *kex_dhpeer; /* pointer to i or r */ diff --git a/sbin/iked/ikev2.c b/sbin/iked/ikev2.c index f98a273bedc..2ea7e7b23ac 100644 --- a/sbin/iked/ikev2.c +++ b/sbin/iked/ikev2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ikev2.c,v 1.302 2021/02/04 19:59:15 tobhe Exp $ */ +/* $OpenBSD: ikev2.c,v 1.303 2021/02/04 20:38:26 tobhe Exp $ */ /* * Copyright (c) 2019 Tobias Heider @@ -1244,7 +1244,7 @@ ikev2_init_ike_sa_peer(struct iked *env, struct iked_policy *pol, struct ikev2_notify *n; struct iked_sa *sa = NULL; struct ibuf *buf, *cookie = NULL; - struct group *group; + struct dh_group *group; ssize_t len; int ret = -1; struct iked_socket *sock; @@ -2964,7 +2964,7 @@ ikev2_handle_notifies(struct iked *env, struct iked_message *msg) struct iked_ipcomp *ic; struct iked_sa *sa; struct iked_spi rekey; - struct group *group; + struct dh_group *group; uint16_t groupid; unsigned int protoid; @@ -3113,7 +3113,7 @@ ikev2_resp_ike_sa_init(struct iked *env, struct iked_message *msg) struct ikev2_keyexchange *ke; struct iked_sa *sa = msg->msg_sa; struct ibuf *buf; - struct group *group; + struct dh_group *group; ssize_t len; int ret = -1; @@ -3829,7 +3829,7 @@ ikev2_send_create_child_sa(struct iked *env, struct iked_sa *sa, struct ikev2_notify *n; struct ikev2_payload *pld = NULL; struct ikev2_keyexchange *ke; - struct group *group; + struct dh_group *group; struct ibuf *e = NULL, *nonce = NULL; uint8_t *ptr; uint8_t firstpayload; @@ -4004,7 +4004,7 @@ ikev2_ike_sa_rekey(struct iked *env, void *arg) struct iked_sa *nsa = NULL; struct ikev2_payload *pld = NULL; struct ikev2_keyexchange *ke; - struct group *group; + struct dh_group *group; struct ibuf *e = NULL, *nonce = NULL; ssize_t len = 0; int ret = -1; @@ -5378,7 +5378,7 @@ ikev2_sa_keys(struct iked *env, struct iked_sa *sa, struct ibuf *key) { struct iked_hash *prf, *integr; struct iked_cipher *encr; - struct group *group; + struct dh_group *group; struct ibuf *ninr, *dhsecret, *skeyseed, *s, *t; size_t nonceminlen, ilen, rlen, tmplen; uint64_t ispi, rspi; @@ -5828,7 +5828,7 @@ ikev2_childsa_negotiate(struct iked *env, struct iked_sa *sa, struct iked_flow *flow, *saflow, *flowa, *flowb; struct iked_ipcomp *ic; struct ibuf *keymat = NULL, *seed = NULL, *dhsecret = NULL; - struct group *group; + struct dh_group *group; uint32_t spi = 0; unsigned int i; size_t ilen = 0; -- 2.20.1