summaryrefslogtreecommitdiff
path: root/ecp
diff options
context:
space:
mode:
Diffstat (limited to 'ecp')
-rw-r--r--ecp/src/ecp/core.c84
-rw-r--r--ecp/src/ecp/core.h30
-rw-r--r--ecp/src/ecp/vconn/vconn.c7
3 files changed, 83 insertions, 38 deletions
diff --git a/ecp/src/ecp/core.c b/ecp/src/ecp/core.c
index f6d8447..96b1034 100644
--- a/ecp/src/ecp/core.c
+++ b/ecp/src/ecp/core.c
@@ -1514,8 +1514,9 @@ void ecp_err_handle(ECPConnection *conn, unsigned char mtype, int err) {
static ssize_t _send_ireq(ECPConnection *conn, ECPTimerItem *ti) {
ECPBuffer packet;
ECPBuffer payload;
- unsigned char pkt_buf[ECP_SIZE_PKT_BUF(0, ECP_MTYPE_INIT_REQ, conn)];
- unsigned char pld_buf[ECP_SIZE_PLD_BUF(0, ECP_MTYPE_INIT_REQ, conn)];
+ unsigned char pkt_buf[ECP_SIZE_PKT_BUF_IREQ(ECP_SIZE_ZPAD_PLD, ECP_MTYPE_INIT_REQ, conn)];
+ unsigned char pld_buf[ECP_SIZE_PLD_BUF_IREQ(ECP_SIZE_ZPAD_PLD, ECP_MTYPE_INIT_REQ, conn)];
+ unsigned char *msg;
ssize_t rv;
packet.buffer = pkt_buf;
@@ -1524,8 +1525,10 @@ static ssize_t _send_ireq(ECPConnection *conn, ECPTimerItem *ti) {
payload.size = sizeof(pld_buf);
ecp_pld_set_type(payload.buffer, payload.size, ECP_MTYPE_INIT_REQ);
+ msg = ecp_pld_get_msg(payload.buffer, payload.size);
+ memset(msg, 0, ECP_SIZE_ZPAD_PLD);
- rv = _ecp_pld_send(conn, &packet, ECP_ECDH_IDX_PERMA, ECP_ECDH_IDX_INV, NULL, NULL, &payload, ECP_SIZE_PLD(0, ECP_MTYPE_INIT_REQ), 0, ti);
+ rv = _ecp_pld_send(conn, &packet, ECP_ECDH_IDX_PERMA, ECP_ECDH_IDX_INV, ECP_SIZE_ZPAD_HDR, NULL, NULL, &payload, ECP_SIZE_PLD(ECP_SIZE_ZPAD_PLD, ECP_MTYPE_INIT_REQ), 0, ti);
return rv;
}
@@ -1565,14 +1568,22 @@ ssize_t ecp_send_init_req(ECPConnection *conn, int retry) {
return rv;
}
-ssize_t ecp_handle_init_req(ECPSocket *sock, ECPConnection *parent, ecp_tr_addr_t *addr, unsigned char c_idx, unsigned char *public_buf, ecp_aead_key_t *shkey, ECP2Buffer *bufs) {
+ssize_t ecp_handle_init_req(ECPSocket *sock, ECPConnection *parent, ecp_tr_addr_t *addr, unsigned char c_idx, unsigned char *public_buf, unsigned char *msg, size_t msg_size, ecp_aead_key_t *shkey, ECP2Buffer *bufs) {
+ unsigned char _public_buf[ECP_SIZE_ECDH_PUB];
ssize_t rv;
+ int i;
+ if (msg_size < ECP_SIZE_ZPAD_PLD) return ECP_ERR_SIZE;
+ for (i=0; i<ECP_SIZE_ZPAD_PLD; i++) {
+ if (msg[i] != 0) return ECP_ERR;
+ }
+
+ memcpy(_public_buf, public_buf, sizeof(_public_buf));
ecp_tr_release(bufs->packet, 1);
- rv = ecp_send_init_rep(sock, parent, addr, c_idx, public_buf, shkey);
+ rv = ecp_send_init_rep(sock, parent, addr, c_idx, _public_buf, shkey);
if (rv < 0) return rv;
- return 0;
+ return ECP_SIZE_ZPAD_PLD;
}
ssize_t ecp_send_init_rep(ECPSocket *sock, ECPConnection *parent, ecp_tr_addr_t *addr, unsigned char c_idx, unsigned char *public_buf, ecp_aead_key_t *shkey) {
@@ -1602,6 +1613,7 @@ ssize_t ecp_send_init_rep(ECPSocket *sock, ECPConnection *parent, ecp_tr_addr_t
if (_rv) return _rv;
memcpy(msg+1+ECP_SIZE_ECDH_PUB, atag, ECP_SIZE_ATAG);
+ pkt_meta.zpad = 0;
pkt_meta.cookie = NULL;
pkt_meta.shkey = shkey;
pkt_meta.nonce = &nonce;
@@ -1691,8 +1703,8 @@ ssize_t ecp_write_open_req(ECPConnection *conn, ECPBuffer *payload) {
ssize_t ecp_send_open_req(ECPConnection *conn, unsigned char *cookie) {
ECPBuffer packet;
ECPBuffer payload;
- unsigned char pkt_buf[ECP_SIZE_PKT_BUF(2+ECP_SIZE_VBOX, ECP_MTYPE_OPEN_REQ, conn)+ECP_SIZE_COOKIE];
- unsigned char pld_buf[ECP_SIZE_PLD_BUF(2+ECP_SIZE_VBOX, ECP_MTYPE_OPEN_REQ, conn)+ECP_SIZE_COOKIE];
+ unsigned char pkt_buf[ECP_SIZE_PKT_BUF_OREQ(2+ECP_SIZE_VBOX, ECP_MTYPE_OPEN_REQ, conn)];
+ unsigned char pld_buf[ECP_SIZE_PLD_BUF_OREQ(2+ECP_SIZE_VBOX, ECP_MTYPE_OPEN_REQ, conn)];
ssize_t rv;
packet.buffer = pkt_buf;
@@ -2082,10 +2094,10 @@ ssize_t ecp_unpack(ECPSocket *sock, ECPConnection *parent, ecp_tr_addr_t *addr,
is_open = _ecp_conn_is_open(conn);
if (!is_open && !is_inb && (idx == ECP_ECDH_IDX_INV)) {
- /* init_rep message */
+ /* init reply message */
nonce_buf = packet+ECP_SIZE_PROTO+1;
- packet += ECP_SIZE_PROTO+1+ECP_SIZE_NONCE;
- pkt_size -= ECP_SIZE_PROTO+1+ECP_SIZE_NONCE;
+ packet += ECP_SIZE_PKT_HDR_IREP;
+ pkt_size -= ECP_SIZE_PKT_HDR_IREP;
s_idx = ECP_ECDH_IDX_PERMA;
c_idx = conn->key_curr;
@@ -2115,21 +2127,32 @@ ssize_t ecp_unpack(ECPSocket *sock, ECPConnection *parent, ecp_tr_addr_t *addr,
public_buf = packet+ECP_SIZE_PROTO+1;
if (s_idx == ECP_ECDH_IDX_PERMA) {
- nonce_buf = public_buf+ECP_SIZE_ECDH_PUB;
- packet += ECP_SIZE_PKT_HDR;
- pkt_size -= ECP_SIZE_PKT_HDR;
+ /* init request message */
+ unsigned char *zpad_buf;
+ int i;
+
+ if (pkt_size < (ECP_MIN_PKT+ECP_SIZE_ZPAD_HDR+ECP_SIZE_ZPAD_PLD)) return ECP_ERR_SIZE;
+
+ zpad_buf = public_buf+ECP_SIZE_ECDH_PUB;
+ nonce_buf = zpad_buf+ECP_SIZE_ZPAD_HDR;
+ packet += ECP_SIZE_PKT_HDR_IREQ;
+ pkt_size -= ECP_SIZE_PKT_HDR_IREQ;
+ for (i=0; i<ECP_SIZE_ZPAD_HDR; i++) {
+ if (zpad_buf[i] != 0) return ECP_ERR;
+ }
_rv = ecp_sock_dhkey_get(sock, s_idx, &key);
if (_rv) return _rv;
ecp_ecdh_shkey(&shkey, (ecp_ecdh_public_t *)public_buf, &key.private);
} else if (pkt_size >= (ECP_MIN_PKT+ECP_SIZE_COOKIE)) {
+ /* open request message */
unsigned char *cookie_buf;
cookie_buf = public_buf+ECP_SIZE_ECDH_PUB;
nonce_buf = cookie_buf+ECP_SIZE_COOKIE;
- packet += ECP_SIZE_PKT_HDR+ECP_SIZE_COOKIE;
- pkt_size -= ECP_SIZE_PKT_HDR+ECP_SIZE_COOKIE;
+ packet += ECP_SIZE_PKT_HDR_OREQ;
+ pkt_size -= ECP_SIZE_PKT_HDR_OREQ;
_rv = ecp_cookie_verify(sock, cookie_buf, public_buf);
if (_rv) return _rv;
@@ -2247,10 +2270,7 @@ ssize_t ecp_unpack(ECPSocket *sock, ECPConnection *parent, ecp_tr_addr_t *addr,
if (conn == NULL) {
switch (mtype) {
case ECP_MTYPE_INIT_REQ: {
- unsigned char _public_buf[ECP_SIZE_ECDH_PUB];
-
- memcpy(_public_buf, public_buf, sizeof(_public_buf));
- rv = ecp_handle_init_req(sock, parent, addr, c_idx, _public_buf, &shkey, bufs);
+ rv = ecp_handle_init_req(sock, parent, addr, c_idx, public_buf, msg, msg_size, &shkey, bufs);
if (rv < 0) goto unpack_fin;
payload += (hdr_size + rv);
@@ -2440,6 +2460,7 @@ static ssize_t _pack(ECPBuffer *packet, ECPPktMeta *pkt_meta, ECPBuffer *payload
pkt_size = ECP_MIN_PKT;
if (pkt_meta->public == NULL) pkt_size -= ECP_SIZE_ECDH_PUB;
+ if (pkt_meta->zpad) pkt_size += pkt_meta->zpad;
if (pkt_meta->cookie) pkt_size += ECP_SIZE_COOKIE;
if (packet->size < pkt_size) return ECP_ERR_SIZE;
@@ -2457,6 +2478,10 @@ static ssize_t _pack(ECPBuffer *packet, ECPPktMeta *pkt_meta, ECPBuffer *payload
memcpy(pkt_buf, pkt_meta->public, ECP_SIZE_ECDH_PUB);
pkt_buf += ECP_SIZE_ECDH_PUB;
}
+ if (pkt_meta->zpad) {
+ memset(pkt_buf, 0, pkt_meta->zpad);
+ pkt_buf += pkt_meta->zpad;
+ }
if (pkt_meta->cookie) {
memcpy(pkt_buf, pkt_meta->cookie, ECP_SIZE_COOKIE);
pkt_buf += ECP_SIZE_COOKIE;
@@ -2471,7 +2496,7 @@ static ssize_t _pack(ECPBuffer *packet, ECPPktMeta *pkt_meta, ECPBuffer *payload
return rv+hdr_size;
}
-static ssize_t _pack_conn(ECPConnection *conn, ECPBuffer *packet, unsigned char s_idx, unsigned char c_idx, unsigned char *cookie, ecp_nonce_t *_nonce, ECPBuffer *payload, size_t pld_size, ecp_tr_addr_t *addr) {
+static ssize_t _pack_conn(ECPConnection *conn, ECPBuffer *packet, unsigned char s_idx, unsigned char c_idx, uint16_t zpad, unsigned char *cookie, ecp_nonce_t *_nonce, ECPBuffer *payload, size_t pld_size, ecp_tr_addr_t *addr) {
ECPPktMeta pkt_meta;
ecp_ecdh_public_t public;
ecp_aead_key_t shkey;
@@ -2535,6 +2560,7 @@ pack_conn_fin:
if (rv) return rv;
+ pkt_meta.zpad = zpad;
pkt_meta.cookie = cookie;
pkt_meta.public = &public;
pkt_meta.shkey = &shkey;
@@ -2566,10 +2592,10 @@ ssize_t ecp_pack_irep(ECPConnection *parent, ECPBuffer *packet, ECPPktMeta *pkt_
return rv;
}
-ssize_t ecp_pack_conn(ECPConnection *conn, ECPBuffer *packet, unsigned char s_idx, unsigned char c_idx, unsigned char *cookie, ecp_nonce_t *nonce, ECPBuffer *payload, size_t pld_size, ecp_tr_addr_t *addr) {
+ssize_t ecp_pack_conn(ECPConnection *conn, ECPBuffer *packet, unsigned char s_idx, unsigned char c_idx, uint16_t zpad, unsigned char *cookie, ecp_nonce_t *nonce, ECPBuffer *payload, size_t pld_size, ecp_tr_addr_t *addr) {
ssize_t rv;
- rv = _pack_conn(conn, packet, s_idx, c_idx, cookie, nonce, payload, pld_size, addr);
+ rv = _pack_conn(conn, packet, s_idx, c_idx, zpad, cookie, nonce, payload, pld_size, addr);
if (rv < 0) return rv;
#ifdef ECP_WITH_VCONN
@@ -2669,12 +2695,12 @@ unsigned char *ecp_pld_get_msg(unsigned char *pld, size_t pld_size) {
return pld + ECP_SIZE_MTYPE + ECP_SIZE_MT_FLAG(pld[0]);
}
-ssize_t _ecp_pld_send(ECPConnection *conn, ECPBuffer *packet, unsigned char s_idx, unsigned char c_idx, unsigned char *cookie, ecp_nonce_t *n, ECPBuffer *payload, size_t pld_size, unsigned char flags, ECPTimerItem *ti) {
+ssize_t _ecp_pld_send(ECPConnection *conn, ECPBuffer *packet, unsigned char s_idx, unsigned char c_idx, uint16_t zpad, unsigned char *cookie, ecp_nonce_t *n, ECPBuffer *payload, size_t pld_size, unsigned char flags, ECPTimerItem *ti) {
ecp_tr_addr_t addr;
size_t pkt_size;
ssize_t rv;
- rv = ecp_pack_conn(conn, packet, s_idx, c_idx, cookie, n, payload, pld_size, &addr);
+ rv = ecp_pack_conn(conn, packet, s_idx, c_idx, zpad, cookie, n, payload, pld_size, &addr);
if (rv < 0) return rv;
pkt_size = rv;
@@ -2688,19 +2714,19 @@ ssize_t _ecp_pld_send(ECPConnection *conn, ECPBuffer *packet, unsigned char s_id
}
ssize_t ecp_pld_send(ECPConnection *conn, ECPBuffer *packet, ECPBuffer *payload, size_t pld_size, unsigned char flags) {
- return _ecp_pld_send(conn, packet, ECP_ECDH_IDX_INV, ECP_ECDH_IDX_INV, NULL, NULL, payload, pld_size, flags, NULL);
+ return _ecp_pld_send(conn, packet, ECP_ECDH_IDX_INV, ECP_ECDH_IDX_INV, 0, NULL, NULL, payload, pld_size, flags, NULL);
}
ssize_t ecp_pld_send_wtimer(ECPConnection *conn, ECPBuffer *packet, ECPBuffer *payload, size_t pld_size, unsigned char flags, ECPTimerItem *ti) {
- return _ecp_pld_send(conn, packet, ECP_ECDH_IDX_INV, ECP_ECDH_IDX_INV, NULL, NULL, payload, pld_size, flags, ti);
+ return _ecp_pld_send(conn, packet, ECP_ECDH_IDX_INV, ECP_ECDH_IDX_INV, 0, NULL, NULL, payload, pld_size, flags, ti);
}
ssize_t ecp_pld_send_wcookie(ECPConnection *conn, ECPBuffer *packet, ECPBuffer *payload, size_t pld_size, unsigned char flags, unsigned char *cookie) {
- return _ecp_pld_send(conn, packet, ECP_ECDH_IDX_INV, ECP_ECDH_IDX_INV, cookie, NULL, payload, pld_size, flags, NULL);
+ return _ecp_pld_send(conn, packet, ECP_ECDH_IDX_INV, ECP_ECDH_IDX_INV, 0, cookie, NULL, payload, pld_size, flags, NULL);
}
ssize_t ecp_pld_send_wnonce(ECPConnection *conn, ECPBuffer *packet, ECPBuffer *payload, size_t pld_size, unsigned char flags, ecp_nonce_t *nonce) {
- return _ecp_pld_send(conn, packet, ECP_ECDH_IDX_INV, ECP_ECDH_IDX_INV, NULL, nonce, payload, pld_size, flags, NULL);
+ return _ecp_pld_send(conn, packet, ECP_ECDH_IDX_INV, ECP_ECDH_IDX_INV, 0, NULL, nonce, payload, pld_size, flags, NULL);
}
ssize_t ecp_pld_send_irep(ECPSocket *sock, ECPConnection *parent, ecp_tr_addr_t *addr, ECPBuffer *packet, ECPPktMeta *pkt_meta, ECPBuffer *payload, size_t pld_size, unsigned char flags) {
diff --git a/ecp/src/ecp/core.h b/ecp/src/ecp/core.h
index e0fcde7..2e5bf14 100644
--- a/ecp/src/ecp/core.h
+++ b/ecp/src/ecp/core.h
@@ -54,11 +54,15 @@
#define ECP_SIZE_PROTO 2
#define ECP_SIZE_NONCE 8
#define ECP_SIZE_MTYPE 1
-#define ECP_SIZE_MTYPE 1
#define ECP_SIZE_ATAG (ECP_SIZE_HMAC_DIGEST)
#define ECP_SIZE_COOKIE (ECP_SIZE_NONCE+ECP_SIZE_ATAG)
+#define ECP_SIZE_ZPAD_HDR 64
+#define ECP_SIZE_ZPAD_PLD 64
#define ECP_SIZE_PKT_HDR (ECP_SIZE_PROTO+1+ECP_SIZE_ECDH_PUB+ECP_SIZE_NONCE)
+#define ECP_SIZE_PKT_HDR_IREQ (ECP_SIZE_PROTO+1+ECP_SIZE_ECDH_PUB+ECP_SIZE_ZPAD_HDR+ECP_SIZE_NONCE)
+#define ECP_SIZE_PKT_HDR_IREP (ECP_SIZE_PROTO+1+ECP_SIZE_NONCE)
+#define ECP_SIZE_PKT_HDR_OREQ (ECP_SIZE_PROTO+1+ECP_SIZE_ECDH_PUB+ECP_SIZE_COOKIE+ECP_SIZE_NONCE)
#define ECP_MAX_PKT 1412
#define ECP_MAX_PLD (ECP_MAX_PKT-ECP_SIZE_PKT_HDR-ECP_SIZE_AEAD_TAG)
@@ -73,7 +77,6 @@
#define ECP_SIZE_MT_PTS(T) ((T) & ECP_MTYPE_FLAG_PTS ? sizeof(ecp_pts_t) : 0)
#define ECP_SIZE_MT_FLAG(T) (ECP_SIZE_MT_FRAG(T)+ECP_SIZE_MT_PTS(T))
#define ECP_SIZE_PLD(X,T) ((X)+ECP_SIZE_MTYPE+ECP_SIZE_MT_FLAG(T))
-#define ECP_SIZE_PKT(X,T) (ECP_SIZE_PKT_HDR+ECP_SIZE_PLD(X,T)+ECP_SIZE_AEAD_TAG)
/*
#define ECP_CONN_PCOUNT(C) ((C)->pcount)
@@ -95,6 +98,22 @@
#define ECP_SIZE_PKT_BUF_IREP(X,T,P) (ECP_SIZE_PKT_HDR+ECP_SIZE_PLD_BUF_IREP(X,T,P)+ECP_SIZE_AEAD_TAG)
#ifdef ECP_WITH_VCONN
+#define ECP_SIZE_PLD_BUF_IREQ(X,T,C) (ECP_SIZE_PLD(X,T)+(ECP_CONN_PCOUNT(C) ? (ECP_CONN_PCOUNT(C)-1)*(ECP_SIZE_PKT_HDR+ECP_SIZE_MTYPE+ECP_SIZE_AEAD_TAG)+ECP_SIZE_PKT_HDR_IREQ+ECP_SIZE_MTYPE+ECP_SIZE_AEAD_TAG : 0))
+#define ECP_SIZE_PKT_BUF_IREQ(X,T,C) (ECP_SIZE_PKT_HDR_IREQ+ECP_SIZE_PLD(X,T)+ECP_SIZE_AEAD_TAG+ECP_CONN_PCOUNT(C)*(ECP_SIZE_PKT_HDR+ECP_SIZE_MTYPE+ECP_SIZE_AEAD_TAG))
+#else
+#define ECP_SIZE_PLD_BUF_IREQ(X,T,C) (ECP_SIZE_PLD(X,T))
+#define ECP_SIZE_PKT_BUF_IREQ(X,T,C) (ECP_SIZE_PKT_HDR_IREQ+ECP_SIZE_PLD(X,T)+ECP_SIZE_AEAD_TAG)
+#endif
+
+#ifdef ECP_WITH_VCONN
+#define ECP_SIZE_PLD_BUF_OREQ(X,T,C) (ECP_SIZE_PLD(X,T)+(ECP_CONN_PCOUNT(C) ? (ECP_CONN_PCOUNT(C)-1)*(ECP_SIZE_PKT_HDR+ECP_SIZE_MTYPE+ECP_SIZE_AEAD_TAG)+ECP_SIZE_PKT_HDR_OREQ+ECP_SIZE_MTYPE+ECP_SIZE_AEAD_TAG : 0))
+#define ECP_SIZE_PKT_BUF_OREQ(X,T,C) (ECP_SIZE_PKT_HDR_OREQ+ECP_SIZE_PLD(X,T)+ECP_SIZE_AEAD_TAG+ECP_CONN_PCOUNT(C)*(ECP_SIZE_PKT_HDR+ECP_SIZE_MTYPE+ECP_SIZE_AEAD_TAG))
+#else
+#define ECP_SIZE_PLD_BUF_OREQ(X,T,C) (ECP_SIZE_PLD(X,T))
+#define ECP_SIZE_PKT_BUF_OREQ(X,T,C) (ECP_SIZE_PKT_HDR_OREQ+ECP_SIZE_PLD(X,T)+ECP_SIZE_AEAD_TAG)
+#endif
+
+#ifdef ECP_WITH_VCONN
#define ecp_conn_is_root(C) ((C)->parent == NULL)
#else
#define ecp_conn_is_root(C) 1
@@ -241,6 +260,7 @@ typedef struct ECPDHShkey {
} ECPDHShkey;
typedef struct ECPPktMeta {
+ uint16_t zpad;
unsigned char *cookie;
ecp_ecdh_public_t *public;
ecp_aead_key_t *shkey;
@@ -402,7 +422,7 @@ ecp_send_open_t ecp_get_send_open_f(ECPConnection *conn);
void ecp_err_handle(ECPConnection *conn, unsigned char mtype, int err);
ssize_t ecp_send_init_req(ECPConnection *conn, int retry);
-ssize_t ecp_handle_init_req(ECPSocket *sock, ECPConnection *parent, ecp_tr_addr_t *addr, unsigned char c_idx, unsigned char *public_buf, ecp_aead_key_t *shkey, ECP2Buffer *bufs);
+ssize_t ecp_handle_init_req(ECPSocket *sock, ECPConnection *parent, ecp_tr_addr_t *addr, unsigned char c_idx, unsigned char *public_buf, unsigned char *msg, size_t msg_size, ecp_aead_key_t *shkey, ECP2Buffer *bufs);
ssize_t ecp_send_init_rep(ECPSocket *sock, ECPConnection *parent, ecp_tr_addr_t *addr, unsigned char c_idx, unsigned char *public_buf, ecp_aead_key_t *shkey);
ssize_t ecp_handle_init_rep(ECPConnection *conn, unsigned char *msg, size_t msg_size, unsigned char *nonce_buf, ECP2Buffer *bufs);
@@ -429,7 +449,7 @@ void ecp_nonce2buf(unsigned char *b, ecp_nonce_t *n);
void ecp_buf2nonce(ecp_nonce_t *n, unsigned char *b);
int ecp_pkt_get_seq(unsigned char *pkt, size_t pkt_size, ecp_seq_t *s);
ssize_t ecp_pack_irep(ECPConnection *parent, ECPBuffer *packet, ECPPktMeta *pkt_meta, ECPBuffer *payload, size_t pld_size, ecp_tr_addr_t *addr);
-ssize_t ecp_pack_conn(ECPConnection *conn, ECPBuffer *packet, unsigned char s_idx, unsigned char c_idx, unsigned char *cookie, ecp_nonce_t *nonce, ECPBuffer *payload, size_t pld_size, ecp_tr_addr_t *addr);
+ssize_t ecp_pack_conn(ECPConnection *conn, ECPBuffer *packet, unsigned char s_idx, unsigned char c_idx, uint16_t zpad, unsigned char *cookie, ecp_nonce_t *nonce, ECPBuffer *payload, size_t pld_size, ecp_tr_addr_t *addr);
int ecp_pld_get_type(unsigned char *pld, size_t pld_size, unsigned char *mtype);
int ecp_pld_set_type(unsigned char *pld, size_t pld_size, unsigned char mtype);
@@ -439,7 +459,7 @@ int ecp_pld_get_pts(unsigned char *pld, size_t pld_size, ecp_pts_t *pts);
int ecp_pld_set_pts(unsigned char *pld, size_t pld_size, ecp_pts_t pts);
unsigned char *ecp_pld_get_msg(unsigned char *pld, size_t pld_size);
-ssize_t _ecp_pld_send(ECPConnection *conn, ECPBuffer *packet, unsigned char s_idx, unsigned char c_idx, unsigned char *cookie, ecp_nonce_t *n, ECPBuffer *payload, size_t pld_size, unsigned char flags, ECPTimerItem *ti);
+ssize_t _ecp_pld_send(ECPConnection *conn, ECPBuffer *packet, unsigned char s_idx, unsigned char c_idx, uint16_t zpad, unsigned char *cookie, ecp_nonce_t *n, ECPBuffer *payload, size_t pld_size, unsigned char flags, ECPTimerItem *ti);
ssize_t ecp_pld_send(ECPConnection *conn, ECPBuffer *packet, ECPBuffer *payload, size_t pld_size, unsigned char flags);
ssize_t ecp_pld_send_wtimer(ECPConnection *conn, ECPBuffer *packet, ECPBuffer *payload, size_t pld_size, unsigned char flags, ECPTimerItem *ti);
ssize_t ecp_pld_send_wcookie(ECPConnection *conn, ECPBuffer *packet, ECPBuffer *payload, size_t pld_size, unsigned char flags, unsigned char *cookie);
diff --git a/ecp/src/ecp/vconn/vconn.c b/ecp/src/ecp/vconn/vconn.c
index 2f3f1b0..4ab71be 100644
--- a/ecp/src/ecp/vconn/vconn.c
+++ b/ecp/src/ecp/vconn/vconn.c
@@ -156,7 +156,6 @@ static ssize_t handle_relay(ECPConnection *conn, unsigned char *msg, size_t msg_
default:
return ECP_ERR_CTYPE;
-
}
if (conn_next == NULL) return ECP_ERR_NEXT;
@@ -207,7 +206,7 @@ ssize_t ecp_vconn_pack_parent(ECPConnection *conn, ECPBuffer *payload, ECPBuffer
if (payload->size < pkt_size+hdr_size) return ECP_ERR_SIZE;
memcpy(msg, packet->buffer, pkt_size);
- rv = ecp_pack_conn(conn, packet, ECP_ECDH_IDX_INV, ECP_ECDH_IDX_INV, NULL, NULL, payload, pkt_size+hdr_size, addr);
+ rv = ecp_pack_conn(conn, packet, ECP_ECDH_IDX_INV, ECP_ECDH_IDX_INV, 0, NULL, NULL, payload, pkt_size+hdr_size, addr);
return rv;
}
@@ -339,8 +338,8 @@ ssize_t ecp_vconn_send_open_req(ECPConnection *conn, unsigned char *cookie) {
ECPDHPub key_next;
ECPBuffer packet;
ECPBuffer payload;
- unsigned char pkt_buf[ECP_SIZE_PKT_BUF(2+ECP_SIZE_VBOX, ECP_MTYPE_OPEN_REQ, conn)+ECP_SIZE_COOKIE+ECP_SIZE_PLD(ECP_SIZE_ECDH_PUB, ECP_MTYPE_NEXT)];
- unsigned char pld_buf[ECP_SIZE_PLD_BUF(2+ECP_SIZE_VBOX, ECP_MTYPE_OPEN_REQ, conn)+ECP_SIZE_COOKIE+ECP_SIZE_PLD(ECP_SIZE_ECDH_PUB, ECP_MTYPE_NEXT)];
+ unsigned char pkt_buf[ECP_SIZE_PKT_BUF_OREQ(2+ECP_SIZE_VBOX, ECP_MTYPE_OPEN_REQ, conn)+ECP_SIZE_PLD(ECP_SIZE_ECDH_PUB, ECP_MTYPE_NEXT)];
+ unsigned char pld_buf[ECP_SIZE_PLD_BUF_OREQ(2+ECP_SIZE_VBOX, ECP_MTYPE_OPEN_REQ, conn)+ECP_SIZE_PLD(ECP_SIZE_ECDH_PUB, ECP_MTYPE_NEXT)];
unsigned char *msg;
unsigned char *_pld_buf;
size_t _pld_size;