Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
4cc79cc
Pass the correct arguments to _startnetkey if klips fails
mohicks Mar 1, 2021
69a1300
Add git to the travis dependency
shussain Mar 17, 2021
227d766
Fix -Wstringop-truncation errors
mohicks Mar 18, 2021
95a1bda
Fix incorrect logic in error path
mohicks Mar 29, 2021
988f0ee
Add string of caller to suppress warning
mohicks Mar 29, 2021
5e95e7c
Limit maximum memcpy to iv size
mohicks Mar 29, 2021
23948c6
Fix -Wenum-conversion warnings related to algo/hash/prf IDs
mohicks Mar 18, 2021
1d5795f
Disable efence banner for test ap06-algo2ikev2
mohicks Mar 29, 2021
76c0eb9
stop tcpdump from resolving service port numbers
mohicks Mar 29, 2021
101b01b
Fix gcc-10 link errors due to duplicated symbols
mohicks Mar 29, 2021
23d3edf
wo#11419: Disable efence in tests to prevent segfault
mohicks Mar 31, 2021
e111894
when looking for a mask for ::/0, bitstomask6 routine gets it wrong
mcr Apr 19, 2021
76e2d93
include cbor2diag for unit test cases
mcr Jan 22, 2021
8b0998f
added cborseq2diag and output
mcr Jan 23, 2021
30fd08a
initial setup for wo01-msgstop unit test case, using QCBOR
mcr Jan 17, 2021
9f8aa06
added wo02 test, and sorted wo01 as shutdown
mcr Jan 24, 2021
bb63557
added wo03, with options for pluto debug
mcr Jan 24, 2021
5880c8d
updated test cases for revised CDDL
mcr Jan 24, 2021
d027eff
change encoding to be map of maps
mcr Jan 24, 2021
a5a9cc1
added wo04 for connection
mcr Jan 26, 2021
7577276
encode the left/right now
mcr Jan 26, 2021
6573d24
complete most of the QCBOR encoding for the whack message
mcr Jan 26, 2021
611b0a7
change right.host_addr to distinguish left/right
mcr Jan 27, 2021
5e240a2
updated qcbor
mcr Feb 1, 2021
d66864a
QCBOR based encoder and decoder, probably almost feature complete exc…
mcr Feb 3, 2021
2a5d71d
initialize size of sendbuf before encoding
mcr Feb 4, 2021
f27112c
log magic bytes in order, log size, and pass entire buffer to decoder
mcr Feb 4, 2021
c77bf9d
examine CBOR output from examples
mcr Feb 7, 2021
7db4c2f
added conn policy and lifetimes to connection
mcr Feb 7, 2021
5efaab0
log size of whack message clearly
mcr Feb 7, 2021
3341a84
turn off detail of readwrite test for now
mcr Feb 7, 2021
4fcd6c0
add keys properly, remove some cruft and fix bug where label key was …
mcr Feb 8, 2021
3b1c825
added step2X to call READWRITE to validate resulting CBOR
mcr Feb 8, 2021
f531dd1
add missing int/bool types from whack_end
mcr Feb 8, 2021
b23474f
use newly created cborseq2pretty
mcr Feb 8, 2021
1021584
added cborseq2pretty to utils until it gets released
mcr Feb 8, 2021
10fa939
added cbor pretty version of moon.conf, host-host
mcr Feb 8, 2021
547cd9a
remove duplicate processing of whack_status
mcr Feb 8, 2021
2016dbb
whack status request can be alone
mcr Feb 8, 2021
ce9f55a
enable whack library test 05
mcr Feb 8, 2021
b242545
encode more options
mcr Feb 8, 2021
b7c34b5
added cborseq2pretty check on connection output
mcr Feb 8, 2021
7776a6e
updated wo05 test to use cborseq2pretty, and to re-initialize size of…
mcr Feb 8, 2021
631eaee
it seems that some public keys were not loaded correctly before!
mcr Feb 8, 2021
6c9baa6
change whack_cbor_decode_msg to have a length as a value/result param…
mcr Feb 8, 2021
595e2b6
updated pol01 with cbor whack changes
mcr Feb 8, 2021
8b83355
collect host_addr definitions in one place
mcr Feb 8, 2021
47a77cc
additional keys now properly loaded
mcr Feb 8, 2021
fea8b87
arrange to free strings that whack_cbor_decode_msg allocates
mcr Feb 8, 2021
d72241c
when reading saved whack files, just find out how big the file is, an…
mcr Feb 8, 2021
783021c
clear out the whackmessage in the read routine, set ip addresses to u…
mcr Feb 8, 2021
08f707f
updates to test cases to deal with subtle changes due to updated libw…
mcr Feb 8, 2021
fd60475
added WHACK_OPT_END_ADDR_FAMILY attribute
mcr Feb 8, 2021
95c98ef
do better logging for address inconsistency, and avoid comparing left…
mcr Feb 8, 2021
c66d966
changes to test case to deal with additions made to libwhack for miss…
mcr Feb 8, 2021
fedb4c2
do not initialize the nexthop, and in the address consistency check, …
mcr Feb 8, 2021
2eee5b1
updated prio, due to initialization of host_addr
mcr Feb 8, 2021
195ec55
split whacklib.c into two files so that unnecessary code is not linke…
mcr Feb 9, 2021
956b172
call git submodule at each version
mcr Feb 9, 2021
6e476c0
updated QCBOR to one with warnings patched
mcr Feb 9, 2021
448f7c4
make sbin directory in which to put tcpdump
mcr Feb 9, 2021
9dd8787
fix qcbor submodule link, to warningless code
mcr Feb 9, 2021
2329214
added unit test to validate encoding of --initiate
mcr Feb 14, 2021
bcea05f
test case for calling initiate
mcr Feb 14, 2021
d6909b6
change conn name to mytunnel
mcr Feb 14, 2021
0ea1087
setup recorded file with --initiate at the end
mcr Feb 14, 2021
ef756e6
enable passert() with -DEBUG!
mcr Feb 14, 2021
cadefc2
set missing whack_* variables when reading, and validate whack_initia…
mcr Feb 14, 2021
2d00a6e
log when the connection is inititiated via whack
mcr Feb 14, 2021
0319495
move and rename whackread, because it is only ever used inside pluto,…
mcr Feb 16, 2021
781da27
return intelligent diagnostic message when decoding wrong values, upd…
mcr Feb 18, 2021
f803591
rip unused whackpacker content out of file
mcr Feb 18, 2021
a89b73f
if QCBOR is not compiled with consistent -DCONFIG options, resulting …
mcr Feb 18, 2021
20fd1e1
updates to test cases based upon CBORSEQ tag type
mcr Sep 3, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "lib/libwhack/qcbor"]
path = lib/libwhack/qcbor
url = https://github.com/AnimaGUS-minerva/QCBOR.git
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ addons:
- make
- flex
- bison
- git
- python-minimal
- libgmp-dev
- libpcap0.8-dev
Expand Down Expand Up @@ -52,18 +53,20 @@ before_script:
- tests/utils/testsetup.sh
- "PATH=$HOME/stuff/sbin:$PATH export PATH"
- which tcpdump
- gem install cbor-diag

install:
- if [ "$TRAVIS_OS_NAME" = osx ]; then brew install libpcap libgmp flex bison; fi
- "PATH=$HOME/stuff/sbin:/usr/lib/ccache:$PATH export PATH"
- "echo WERROR=-Werror >Makefile.inc.local"
- "echo ARCH=${BUILD_ARCH} >>Makefile.inc.local"
- if [ "$BUILD_ARCH" = i386 ]; then echo "USERLINKEXTRA=-m32" >>Makefile.inc.local; echo "USERCOMPILEEXTRA=-m32" >>Makefile.inc.local; fi
- mkdir -p $HOME/stuff/sbin
- cp tests/utils/cborseq2pretty.rb $HOME/stuff/sbin

script:
- export PATH=$PATH:$HOME/stuff/bin
- "cat Makefile.inc.local"
- "make env | sort -f"
- git --version
- ./tests/utils/$TEST_JOB

6 changes: 3 additions & 3 deletions include/pluto/ike_alg.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ struct ike_alg {
const char *name;
const char *officname;
enum ikev2_trans_type algo_type;
u_int16_t ikev1_algo_id; /* IKEv1 number */
enum ikev2_trans_type_encr algo_v2id;
u_int16_t ikev1_algo_id; /* IKEv1 number */
unsigned algo_v2id;
struct ike_alg *algo_next;
};

Expand Down Expand Up @@ -115,7 +115,7 @@ int ike_alg_register_enc(struct ike_encr_desc *e);
int ike_alg_register_integ(struct ike_integ_desc *a);
int ike_alg_register_prf(struct ike_prf_desc *a);
struct ike_alg *ike_alg_ikev2_find(enum ikev2_trans_type algo_type
, enum ikev2_trans_type_encr algo_v2id
, unsigned algo_v2id
, unsigned keysize);

static __inline__ struct ike_encr_desc *ike_alg_get_encr(int alg)
Expand Down
2 changes: 1 addition & 1 deletion include/pluto/whackfile.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
extern void close_whackrecordfile(void);
extern bool openwhackrecordfile(char *file);
extern bool writewhackrecord(char *buf, int buflen);
extern bool writewhackrecord(unsigned char *buf, int buflen);
150 changes: 105 additions & 45 deletions include/whack.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,105 @@ enum whack_opt_set {
WHACK_STOPWHACKRECORD=3, /* turn off recording to file */
};

enum whack_CBOR_actions {
WHACK_STATUS = 1,
WHACK_SHUTDOWN =2,
WHACK_OPTIONS =3,
WHACK_CONNECTION=4,
WHACK_ROUTE =5,
WHACK_UNROUTE =6,
WHACK_INITIATE =7,
WHACK_INITIATE_OPPO=8,
WHACK_TERMINATE=9,
WHACK_ADD_KEY =10,
WHACK_NOOP =23,
};

#define CborSignatureTag 55799
#define CborOpenSwanTag 0x4f50534e
#define CborIPv4Tag 260 /* squatted */
#define CborIPv6Tag 261

/* values < 24 get encoded in one byte, < 256 in two bytes */
enum whack_cbor_attributes {
WHACK_OPT_NAME = 1,
WHACK_OPT_DEBUGGING = 2,
WHACK_OPT_ASYNC = 128,
WHACK_OPT_SET = 129,
WHACK_OPT_RECORDFILE=130,
WHACK_OPT_MYID = 131,
WHACK_OPT_DELETE= 27,
WHACK_OPT_CRASHPEER=132,
WHACK_OPT_LISTEN =133,
WHACK_OPT_UNLISTEN =134,
WHACK_OPT_REREAD =135,
WHACK_OPT_LIST =136,
WHACK_OPT_PURGE_OCSP=137,
WHACK_OPT_IKE = 139,
WHACK_OPT_ESP = 140,
WHACK_OPT_CONNALIAS= 141,
WHACK_OPT_POLICYLABEL=142,
WHACK_OPT_OPPO_MY_CLIENT = 143,
WHACK_OPT_OPPO_PEER_CLIENT=144,
WHACK_OPT_DELETESTATE=145,

WHACK_OPT_LEFT = 3,
WHACK_OPT_RIGHT = 4,

WHACK_OPT_LIFETIME_IKE = 146,
WHACK_OPT_LIFETIME_IPSEC=147,
WHACK_OPT_LIFETIME_REKEY_MARGIN=148,
WHACK_OPT_LIFETIME_REKEY_FUZZ=149,
WHACK_OPT_LIFETIME_REKEY_TRIES=150,
WHACK_OPT_POLICY = 151,
WHACK_OPT_KEYVAL = 15,
WHACK_OPT_KEYID = 16,
WHACK_OPT_KEYALG = 17,
WHACK_OPT_END_ADDR_FAMILY=18,
};

enum whack_cbor_end_attr {
WHACK_OPT_END_ID = 5,
WHACK_OPT_END_CERT = 6,
WHACK_OPT_END_CA = 7,
WHACK_OPT_END_GROUPS =8,
WHACK_OPT_END_VIRT = 9,
WHACK_OPT_END_XAUTH_NAME =137, /* uncommon */
WHACK_OPT_END_HOST_ADDRNAME = 10,
WHACK_OPT_END_HOST_ADDR = 11,
WHACK_OPT_END_HOST_NEXTHOP = 12,
WHACK_OPT_END_HOST_SRCIP = 13,
WHACK_OPT_END_CLIENT = 14,

WHACK_OPT_HOST_TYPE = 15,
WHACK_OPT_KEYTYPE = 16,
WHACK_OPT_HAS_CLIENT= 17,
WHACK_OPT_HAS_CLIENT_WILDCARD=18,
WHACK_OPT_HAS_PORT_WILDCARD=19,
WHACK_OPT_HOST_PORT=20,
WHACK_OPT_PORT=138,
WHACK_OPT_XAUTH_SERVER=139,
WHACK_OPT_XAUTH_CLIENT=140,
WHACK_OPT_MODECFG_SERVER=141,
WHACK_OPT_MODECFG_CLIENT=142,
WHACK_OPT_CERTPOLICY=143,
WHACK_OPT_CERTTYPE=144,
WHACK_OPT_TUNDEV=145
};



/* this is the historic message from Openswan < 3.1 */
struct legacy_whack_message {
u_int32_t magic;

/* for WHACK_STATUS: */
bool whack_status;

/* for WHACK_SHUTDOWN */
bool whack_shutdown;
};

/* whack message should be size independant, but it is in host-endian format */
struct whack_message {
u_int32_t magic;
Expand Down Expand Up @@ -250,43 +349,7 @@ struct whack_message {

/* for use with general option adjustments */
enum whack_opt_set opt_set;
char *string1;
char *string2;
char *string3;

/* space for strings (hope there is enough room):
* Note that pointers don't travel on wire.
* 1 connection name [name_len]
* 2 left's name [left.host.name.len]
* 3 left's cert
* 4 left's ca
* 5 left's groups
* 6 left's updown
* 7 left's virt
* 8 right's name [left.host.name.len]
* 9 right's cert
* 10 right's ca
* 11 right's groups
* 12 right's updown
* 13 right's virt
* 14 keyid
* 15 myid
* 16 ike
* 17 esp
* 18 tpmeval
* 19 left.xauth_name
* 20 right.xauth_name
* 21 connalias
* 22 left.host_addr_name
* 23 right.host_addr_name
* 24 genstring1 - used with opt_set
* 25 genstring2
* 26 genstring3
* 27 genstring4
* plus keyval (limit: 8K bits + overhead), a chunk.
*/
u_int32_t str_size;
unsigned char string[4096];
char *string1; /* for whackrecord file */
};

/* options of whack --list*** command */
Expand Down Expand Up @@ -320,19 +383,16 @@ struct whack_message {
#define REREAD_ALL LRANGES(REREAD_SECRETS, REREAD_CRLS) /* all reread options */
#define REREAD_TPMEVAL 0x40 /* evaluate in Tcl */


struct whackpacker {
struct whack_message *msg;
unsigned char *str_roof;
unsigned char *str_next;
int n;
int cnt;
};
struct whackpacker;

extern err_t pack_whack_msg(struct whackpacker *wp);
extern err_t unpack_whack_msg (struct whackpacker *wp);
extern void clear_end(struct whack_end *e);

extern err_t whack_cbor_encode_msg(struct whack_message *wm, unsigned char *buf, size_t *buf_len);
extern err_t whack_cbor_decode_msg(struct whack_message *wm, unsigned char *buf, size_t *buf_len);
extern void whack_free_msg(struct whack_message *wm);

extern size_t whack_get_secret(char *buf, size_t bufsize);
extern int whack_get_value(char *buf, size_t bufsize);

Expand Down
2 changes: 1 addition & 1 deletion lib/libcrypto/liboswcrypto/xfrm_plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ ike_alg_ikev1_find(enum ikev2_trans_type algo_type
*/
struct ike_alg *
ike_alg_ikev2_find(enum ikev2_trans_type algo_type
, enum ikev2_trans_type_encr algo_v2id
, unsigned algo_v2id
, unsigned keysize __attribute__((unused)))
{
struct ike_alg *e=ike_alg_base[algo_type];
Expand Down
14 changes: 7 additions & 7 deletions lib/libipsecconf/interfaces.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@

char *starter_find_physical_iface(int sock, char *iface)
{
static char _if[IFNAMSIZ+1];
static char _if[IFNAMSIZ];
char *b;
struct ifreq req;
FILE *f;
char line[256];

strncpy(req.ifr_name, iface, IFNAMSIZ);
strncpy(req.ifr_name, iface, IFNAMSIZ-1);
if (ioctl(sock, SIOCGIFFLAGS, &req)==0) {
if (req.ifr_flags & IFF_UP) {
strncpy(_if, iface, IFNAMSIZ);
strncpy(_if, iface, IFNAMSIZ-1);
return _if;
}
}
Expand All @@ -68,19 +68,19 @@ char *starter_find_physical_iface(int sock, char *iface)
if ((strncmp(line,"IP_PHYS=\"", 9)==0) &&
(line[strlen(line)-2]=='"') &&
(line[strlen(line)-1]=='\n')) {
strncpy(_if, line+9, MIN(strlen(line)-11,IFNAMSIZ));
strncpy(_if, line+9, MIN(strlen(line)-11,IFNAMSIZ-1));
break;
}
else if ((strncmp(line,"IP_PHYS=", 8)==0) &&
(line[8]!='"') &&
(line[strlen(line)-1]=='\n')) {
strncpy(_if, line+8, MIN(strlen(line)-9,IFNAMSIZ));
strncpy(_if, line+8, MIN(strlen(line)-9,IFNAMSIZ-1));
break;
}
}
fclose(f);
if (*_if) {
strncpy(req.ifr_name, _if, IFNAMSIZ);
strcpy(req.ifr_name, _if);
if (ioctl(sock, SIOCGIFFLAGS, &req)==0) {
if (req.ifr_flags & IFF_UP) {
return _if;
Expand Down Expand Up @@ -108,7 +108,7 @@ int starter_iface_find(char *iface, int af, ip_address *dst, ip_address *nh)
phys = starter_find_physical_iface(sock, iface);
if (!phys) goto failed;

strncpy(req.ifr_name, phys, IFNAMSIZ);
strncpy(req.ifr_name, phys, IFNAMSIZ-1);
if (ioctl(sock, SIOCGIFFLAGS, &req)!=0) goto failed;
if (!(req.ifr_flags & IFF_UP)) goto failed;

Expand Down
42 changes: 10 additions & 32 deletions lib/libipsecconf/starterwhack.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,33 +181,6 @@ int starter_whack_read_reply(int sock,
return ret;
}

/* returns length of result... XXX unit test would be good here */
int serialize_whack_msg(struct whack_message *msg)
{
struct whackpacker wp;
ssize_t len;
err_t ugh;

/**
* Pack strings
*/
wp.cnt = 0;
wp.msg = msg;
wp.str_next = (unsigned char *)msg->string;
wp.str_roof = (unsigned char *)&msg->string[sizeof(msg->string)];

ugh = pack_whack_msg(&wp);

if(ugh)
{
starter_log(LOG_LEVEL_ERR, "send_wack_msg(): can't pack strings: %s", ugh);
return -1;
}

len = wp.str_next - (unsigned char *)msg;
return len;
}

static int send_whack_msg(struct starter_config *cfg, struct whack_message *msg)
{
if(cfg->send_whack_msg) {
Expand All @@ -223,14 +196,19 @@ static int send_whack_msg_to_socket(struct starter_config *cfg, struct whack_mes
struct sockaddr_un ctl_addr =
{ .sun_family = AF_UNIX };
int sock;
ssize_t len;
size_t len;
unsigned char sendbuf[4096];
int ret;

/* copy socket location */
strncpy(ctl_addr.sun_path, cfg->ctlbase, sizeof(ctl_addr.sun_path));
strncpy(ctl_addr.sun_path, cfg->ctlbase, sizeof(ctl_addr.sun_path)-1);

len = serialize_whack_msg(msg);
if(len == -1) return -1; /* already logged error */
len = sizeof(sendbuf);
err_t ugh = whack_cbor_encode_msg(msg, sendbuf, &len);
if(ugh) {
starter_log(LOG_LEVEL_ERR, "error encoding: %s", ugh);
return -1;
}

/**
* Connect to pluto ctl
Expand All @@ -251,7 +229,7 @@ static int send_whack_msg_to_socket(struct starter_config *cfg, struct whack_mes
/**
* Send message
*/
if (write(sock, msg, len) != len) {
if (write(sock, sendbuf, len) != len) {
starter_log(LOG_LEVEL_ERR, "write(pluto_ctl) failed: %s",
strerror(errno));
close(sock);
Expand Down
Loading