-/* $OpenBSD: iked.h,v 1.220 2023/06/28 14:10:24 tobhe Exp $ */
+/* $OpenBSD: iked.h,v 1.221 2023/07/16 15:21:46 claudio Exp $ */
/*
* Copyright (c) 2019 Tobias Heider <tobias.heider@stusta.de>
int ibuf_cat(struct ibuf *, struct ibuf *);
size_t ibuf_length(struct ibuf *);
int ibuf_setsize(struct ibuf *, size_t);
-void *ibuf_getdata(struct ibuf *, size_t);
struct ibuf *
- ibuf_get(struct ibuf *, size_t);
+ ibuf_getdata(struct ibuf *, size_t);
struct ibuf *
ibuf_dup(struct ibuf *);
struct ibuf *
-/* $OpenBSD: ikev2.c,v 1.372 2023/06/28 14:10:24 tobhe Exp $ */
+/* $OpenBSD: ikev2.c,v 1.373 2023/07/16 15:21:46 claudio Exp $ */
/*
* Copyright (c) 2019 Tobias Heider <tobias.heider@stusta.de>
goto done;
}
- /* ibuf_get() returns a new buffer from the next read offset */
- if ((sa->sa_key_d = ibuf_get(t, hash_length(prf))) == NULL ||
+ /* ibuf_getdata() returns a new buffer from the next read offset */
+ if ((sa->sa_key_d = ibuf_getdata(t, hash_length(prf))) == NULL ||
(!isaead &&
- (sa->sa_key_iauth = ibuf_get(t, hash_keylength(integr))) == NULL) ||
+ (sa->sa_key_iauth = ibuf_getdata(t, hash_keylength(integr))) ==
+ NULL) ||
(!isaead &&
- (sa->sa_key_rauth = ibuf_get(t, hash_keylength(integr))) == NULL) ||
- (sa->sa_key_iencr = ibuf_get(t, cipher_keylength(encr))) == NULL ||
- (sa->sa_key_rencr = ibuf_get(t, cipher_keylength(encr))) == NULL ||
- (sa->sa_key_iprf = ibuf_get(t, hash_length(prf))) == NULL ||
- (sa->sa_key_rprf = ibuf_get(t, hash_length(prf))) == NULL) {
+ (sa->sa_key_rauth = ibuf_getdata(t, hash_keylength(integr))) ==
+ NULL) ||
+ (sa->sa_key_iencr = ibuf_getdata(t, cipher_keylength(encr))) ==
+ NULL ||
+ (sa->sa_key_rencr = ibuf_getdata(t, cipher_keylength(encr))) ==
+ NULL ||
+ (sa->sa_key_iprf = ibuf_getdata(t, hash_length(prf))) == NULL ||
+ (sa->sa_key_rprf = ibuf_getdata(t, hash_length(prf))) == NULL) {
log_debug("%s: failed to get SA keys", SPI_SA(sa, __func__));
goto done;
}
csa->csa_spi.spi_size = 4;
}
- if (encrxf && (csa->csa_encrkey = ibuf_get(keymat,
+ if (encrxf && (csa->csa_encrkey = ibuf_getdata(keymat,
encrxf->xform_keylength / 8)) == NULL) {
log_debug("%s: failed to get CHILD SA encryption key",
__func__);
goto done;
}
- if (integrxf && (csa->csa_integrkey = ibuf_get(keymat,
+ if (integrxf && (csa->csa_integrkey = ibuf_getdata(keymat,
integrxf->xform_keylength / 8)) == NULL) {
log_debug("%s: failed to get CHILD SA integrity key",
__func__);
csb->csa_local = csa->csa_peer;
csb->csa_peer = csa->csa_local;
- if (encrxf && (csb->csa_encrkey = ibuf_get(keymat,
+ if (encrxf && (csb->csa_encrkey = ibuf_getdata(keymat,
encrxf->xform_keylength / 8)) == NULL) {
log_debug("%s: failed to get CHILD SA encryption key",
__func__);
goto done;
}
- if (integrxf && (csb->csa_integrkey = ibuf_get(keymat,
+ if (integrxf && (csb->csa_integrkey = ibuf_getdata(keymat,
integrxf->xform_keylength / 8)) == NULL) {
log_debug("%s: failed to get CHILD SA integrity key",
__func__);
-/* $OpenBSD: imsg_util.c,v 1.19 2023/06/19 17:19:50 claudio Exp $ */
+/* $OpenBSD: imsg_util.c,v 1.20 2023/07/16 15:21:46 claudio Exp $ */
/*
* Copyright (c) 2010-2013 Reyk Floeter <reyk@openbsd.org>
return (buf);
if (data == NULL) {
- if (ibuf_reserve(buf, len) == NULL) {
+ if (ibuf_add_zero(buf, len) != 0) {
ibuf_free(buf);
return (NULL);
}
size_t
ibuf_length(struct ibuf *buf)
{
- if (buf == NULL || buf->buf == NULL)
+ if (buf == NULL)
return (0);
return (ibuf_size(buf));
}
-void *
+struct ibuf *
ibuf_getdata(struct ibuf *buf, size_t len)
{
void *data;
return (NULL);
buf->rpos += len;
- return (data);
-}
-
-struct ibuf *
-ibuf_get(struct ibuf *buf, size_t len)
-{
- void *data;
-
- if ((data = ibuf_getdata(buf, len)) == NULL)
- return (NULL);
-
return (ibuf_new(data, len));
}