summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReyk Floeter <reyk@cvs.openbsd.org>2010-12-01 12:01:26 +0000
committerReyk Floeter <reyk@cvs.openbsd.org>2010-12-01 12:01:26 +0000
commit2fc39f6f0f523657fc8e35163600d31da4109520 (patch)
tree66935366869ffe280f5dc17d19ffbbcd6dabcba3
parent9f11d0a4e8f2d4162c049751074e127504bd0b9b (diff)
Clarify the internal ibuf API: rename ibuf_copy() to ibuf_get() because
it returns a new buffer from the internal read offset like stdio get functions do and not the same buffer when it is called multiple times. Also rename the old ibuf_get() to ibuf_getdata() because it returns a "special" data type and it matches the stdio get* conventions. pointed out by mikeb@
-rw-r--r--sbin/iked/iked.h6
-rw-r--r--sbin/iked/ikev2.c25
-rw-r--r--sbin/iked/util.c8
3 files changed, 20 insertions, 19 deletions
diff --git a/sbin/iked/iked.h b/sbin/iked/iked.h
index 4eef8c34efb..0d7258cee37 100644
--- a/sbin/iked/iked.h
+++ b/sbin/iked/iked.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: iked.h,v 1.21 2010/11/17 16:43:45 ckuethe Exp $ */
+/* $OpenBSD: iked.h,v 1.22 2010/12/01 12:01:25 reyk Exp $ */
/* $vantronix: iked.h,v 1.61 2010/06/03 07:57:33 reyk Exp $ */
/*
@@ -746,9 +746,9 @@ size_t ibuf_length(struct ibuf *);
int ibuf_setsize(struct ibuf *, size_t);
u_int8_t *
ibuf_data(struct ibuf *);
-void *ibuf_get(struct ibuf *, size_t);
+void *ibuf_getdata(struct ibuf *, size_t);
struct ibuf *
- ibuf_copy(struct ibuf *, size_t);
+ ibuf_get(struct ibuf *, size_t);
struct ibuf *
ibuf_dup(struct ibuf *);
struct ibuf *
diff --git a/sbin/iked/ikev2.c b/sbin/iked/ikev2.c
index 84f36db73ce..99fe3afb8f5 100644
--- a/sbin/iked/ikev2.c
+++ b/sbin/iked/ikev2.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ikev2.c,v 1.25 2010/09/22 09:12:18 mikeb Exp $ */
+/* $OpenBSD: ikev2.c,v 1.26 2010/12/01 12:01:25 reyk Exp $ */
/* $vantronix: ikev2.c,v 1.101 2010/06/03 07:57:33 reyk Exp $ */
/*
@@ -2712,13 +2712,14 @@ ikev2_sa_keys(struct iked *env, struct iked_sa *sa)
goto done;
}
- if ((sa->sa_key_d = ibuf_copy(t, hash_length(prf))) == NULL ||
- (sa->sa_key_iauth = ibuf_copy(t, hash_keylength(integr))) == NULL ||
- (sa->sa_key_rauth = ibuf_copy(t, hash_keylength(integr))) == NULL ||
- (sa->sa_key_iencr = ibuf_copy(t, cipher_keylength(encr))) == NULL ||
- (sa->sa_key_rencr = ibuf_copy(t, cipher_keylength(encr))) == NULL ||
- (sa->sa_key_iprf = ibuf_copy(t, hash_length(prf))) == NULL ||
- (sa->sa_key_rprf = ibuf_copy(t, hash_length(prf))) == NULL) {
+ /* ibuf_get() returns a new buffer from the next read offset */
+ if ((sa->sa_key_d = ibuf_get(t, hash_length(prf))) == NULL ||
+ (sa->sa_key_iauth = ibuf_get(t, hash_keylength(integr))) == NULL ||
+ (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) {
log_debug("%s: failed to get SA keys", __func__);
goto done;
}
@@ -3117,14 +3118,14 @@ ikev2_childsa_negotiate(struct iked *env, struct iked_sa *sa,
csa->csa_allocated = 1;
}
- if (encrxf && (csa->csa_encrkey = ibuf_copy(keymat,
+ if (encrxf && (csa->csa_encrkey = ibuf_get(keymat,
encrxf->xform_keylength / 8)) == NULL) {
log_debug("%s: failed to get CHILD SA encryption key",
__func__);
childsa_free(csa);
goto done;
}
- if (integrxf && (csa->csa_integrkey = ibuf_copy(keymat,
+ if (integrxf && (csa->csa_integrkey = ibuf_get(keymat,
integrxf->xform_keylength / 8)) == NULL) {
log_debug("%s: failed to get CHILD SA integrity key",
__func__);
@@ -3150,14 +3151,14 @@ ikev2_childsa_negotiate(struct iked *env, struct iked_sa *sa,
csb->csa_local = csa->csa_peer;
csb->csa_peer = csa->csa_local;
- if (encrxf && (csb->csa_encrkey = ibuf_copy(keymat,
+ if (encrxf && (csb->csa_encrkey = ibuf_get(keymat,
encrxf->xform_keylength / 8)) == NULL) {
log_debug("%s: failed to get CHILD SA encryption key",
__func__);
childsa_free(csb);
goto done;
}
- if (integrxf && (csb->csa_integrkey = ibuf_copy(keymat,
+ if (integrxf && (csb->csa_integrkey = ibuf_get(keymat,
integrxf->xform_keylength / 8)) == NULL) {
log_debug("%s: failed to get CHILD SA integrity key",
__func__);
diff --git a/sbin/iked/util.c b/sbin/iked/util.c
index ed6ffd7258f..52fe6033b1a 100644
--- a/sbin/iked/util.c
+++ b/sbin/iked/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.7 2010/06/29 21:04:42 reyk Exp $ */
+/* $OpenBSD: util.c,v 1.8 2010/12/01 12:01:25 reyk Exp $ */
/* $vantronix: util.c,v 1.39 2010/06/02 12:22:58 reyk Exp $ */
/*
@@ -888,7 +888,7 @@ ibuf_data(struct ibuf *buf)
}
void *
-ibuf_get(struct ibuf *buf, size_t len)
+ibuf_getdata(struct ibuf *buf, size_t len)
{
void *data;
@@ -900,11 +900,11 @@ ibuf_get(struct ibuf *buf, size_t len)
}
struct ibuf *
-ibuf_copy(struct ibuf *buf, size_t len)
+ibuf_get(struct ibuf *buf, size_t len)
{
void *data;
- if ((data = ibuf_get(buf, len)) == NULL)
+ if ((data = ibuf_getdata(buf, len)) == NULL)
return (NULL);
return (ibuf_new(data, len));