-/* $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 <reyk@openbsd.org>
#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 {
}
void
-group_free(struct group *group)
+group_free(struct dh_group *group)
{
if (group == NULL)
return;
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);
}
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));
}
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;
}
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;
}
int
-modp_init(struct group *group)
+modp_init(struct dh_group *group)
{
BIGNUM *g = NULL, *p = NULL;
DH *dh;
}
int
-modp_getlen(struct group *group)
+modp_getlen(struct dh_group *group)
{
if (group->spec == NULL)
return (0);
}
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;
}
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;
}
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);
}
int
-ec_getlen(struct group *group)
+ec_getlen(struct dh_group *group)
{
if (group->spec == NULL)
return (0);
* 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;
}
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;
}
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;
}
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;
}
int
-ec25519_init(struct group *group)
+ec25519_init(struct dh_group *group)
{
static const uint8_t basepoint[CURVE25519_SIZE] = { 9 };
struct curve25519_key *curve25519;
}
int
-ec25519_getlen(struct group *group)
+ec25519_getlen(struct dh_group *group)
{
if (group->spec == NULL)
return (0);
}
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;
}
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;
-/* $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 <reyk@openbsd.org>
int nid;
};
-struct group {
+struct dh_group {
int id;
const struct group_id
*spec;
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 */
-/* $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 <tobias.heider@stusta.de>
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;
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;
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;
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;
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;
{
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;
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;