73 Commits

Author SHA1 Message Date
Michael Rash
12a6e9e93a Convert most strlcat() calls to use destination bound from sizeof()
This commit helps to ensure correctness of strlcat() calls in support of fixing
issue #2.
2013-04-27 20:41:12 -04:00
Michael Rash
b3f55bf1ab Convert most strlcpy() calls to use destination bound from sizeof()
This commit helps to ensure correctness of strlcpy() calls in support of fixing
issue #2.
2013-04-27 15:08:11 -04:00
Michael Rash
87fc50bb31 Merge remote-tracking branch 'fjoncourt/hmac_support' into hmac_support
This commit from Franck Joncourt closes #43
2013-04-12 21:16:20 -04:00
Franck Joncourt
fbd38d805b Added some else statements and their comments. 2013-04-12 14:48:26 +02:00
Michael Rash
c112cb4811 [test suite] get hmac iptables duplicated and sha512 long key tests to pass 2013-04-10 23:31:58 -04:00
Franck Joncourt
fd767a1f47 Resolve ip address in all of tha nat modes (mrash/fwknop#43). 2013-04-10 16:06:06 +02:00
Michael Rash
a59b5acc99 Merge patch from Franck in support of issue #43 2013-04-07 15:11:09 -04:00
Franck Joncourt
8f667c17ac Fixed Nat mode not resolving hostname to IP's.
Linked mrash/fwknop#43
2013-04-06 22:59:59 +02:00
Michael Rash
08c9cc0938 HMAC function rename for consistency
Make sure that HMAC function names conform to previously established get_*,
set_* naming convention.
2013-03-29 20:42:44 -04:00
Michael Rash
c7b5611fa4 Merge remote-tracking branch 'fjoncourt/hmac_support' into hmac_support
Significant merge from Franck Joncourt to add the ability to save command line
args to ~/.fwknoprc stanzas.  This merge is in support of #4.

Conflicts:
	lib/fko_util.c
	lib/fko_util.h
2013-03-17 21:34:23 -04:00
Michael Rash
4bdb71315a [client] --nat-rand-port bug fix
Bug fix for --nat-rand-port mode to ensure that the port to be
NAT'd is properly defined so that the fwknopd server will NAT
connnections to this port instead of applying the NAT operation to the
port that is to be accessed via -A.  This change also prints the
randomly assigned port to stdout regardless of whether --verbose mode is
used (since it not then the user will have no idea which port is
actually going to be NAT'd on the fwknopd side).
2013-03-16 14:38:20 -04:00
Michael Rash
253ccb7cea added encryption type/mode and message type string representations for FKO context diplay output 2013-03-14 22:26:44 -04:00
Michael Rash
6478d2b892 minor fix to remove extraneous memset() call 2013-03-11 22:54:10 -04:00
Michael Rash
7821e83dfc Merge branch 'hmac_support' of github.com:mrash/fwknop into hmac_support
Conflicts:
	client/fwknop.c
	lib/fko_hmac.c
2013-03-10 14:32:07 -04:00
Michael Rash
22dde8eb35 SPA with HMAC SHA256 and SHA384 now works
This is a fairly significant commit that lays the groundwork for getting
selectable HMAC modes working for both the client and server.  One libfko API
change was required so that the hmac_type is passed into fko_new_with_data().
This allows the server to set the hmac_type via access.conf stanzas.  The
effort in this commit will be extended to allow HMAC MD5, SHA1, and SHA512
also function properly.
2013-03-10 14:26:05 -04:00
Damien Stuart
6fa3be393c Renamed fko_set_hmac_type to fko_set_spa_hmac_type. Incorporated libfko changes and additions to the fko python module code. 2013-03-10 13:21:24 -04:00
Michael Rash
6f45b2c3b1 added HMAC SHA384 and SHA512 support, bug fix to allow shorter HMAC key lengths than associated digest block size 2013-03-09 23:27:08 -05:00
Michael Rash
44d05a6916 interim commit for supporting multiple HMAC digest types (# 45) 2013-03-07 23:14:48 -05:00
Michael Rash
39ca73a245 [test suite] added OpenSSL HMAC verification (closes #39) 2013-03-05 23:29:46 -05:00
Michael Rash
1dc47f80d8 Fix byte order warning
This commit fixes a byte order warning for both sha1.c and md5.c like so:

sha1.c:127:6: warning: #warning Undetermined or unsupported Byte Order... We will try LITTLE_ENDIAN [-Wcpp]

Also removed a couple of header includes that appear not be needed.
2013-03-03 14:29:08 -05:00
Michael Rash
b86e48dd66 remove a couple of unnecessary header includes 2013-03-02 23:16:26 -05:00
Damien Stuart
f9e1ae4859 Merge my working branch 'hmac_support' into hmac_header_fixes 2013-03-02 17:22:50 -05:00
Damien Stuart
6ecf81b16e First round if refactoring to clean up header dependencies. 2013-03-02 17:03:20 -05:00
Michael Rash
73b1931bd8 minor clean up for get_keys() base64 decoded key length 2013-02-28 22:25:04 -05:00
Michael Rash
ffcb77552b Remove lib/fko.h dependency on rijndael.h 2013-02-28 21:47:43 -05:00
Michael Rash
5b00d1756f set fko_ctx_t opaque pointers to NULL 2013-02-20 21:20:09 -05:00
Michael Rash
a413c6cf94 Continue atoi() replacement with strtol() wrapper, closes issue #21
This commit completes the conversion to the strtol() wrapper function in order
to remove all atoi() calls.  In addition, variable max values are enforced
using more broadly defined RCHK_* values.
2013-02-19 23:11:01 -05:00
Michael Rash
1afc8db96a Added strtol_wrapper() libfko utility function for atoi() replacement (#21)
This commit replaces most atoi() calls (which don't report errors) with a strtol()
wrapper function for stronger string -> integer conversion validation.
2013-02-18 19:32:53 -05:00
Michael Rash
7735e8ce7a minor comment typ fix 2013-02-17 12:02:48 -05:00
Michael Rash
aab3ba3b0c added --save-args-file and corresponding tests to the fwknop client 2013-02-14 22:50:14 -05:00
Michael Rash
47ea800889 merged in fwknop-2.0.4 changes 2013-01-18 17:25:16 -05:00
Damien Stuart
39410044c5 Set new libfko version. Client: allow dot (.) in validate_username, and display version and exit without creating an fko context. 2012-12-07 11:38:31 -05:00
Damien Stuart
f499e30900 Tweaks to fix issues with building the lib and client under Windows. Added .fwknop.last support on Windows. Bumped the lib version to 0.0.4. Fixed bug in username detection code. Removed -Werror from AM_INIT_AUTOMAKE which prevented setting of CPPFLAG for the lib build in some circumstances. 2012-11-19 08:43:14 -05:00
Michael Rash
627035fb22 Patch from Franck Joncourt for setting permissions via open()
[client+server] Applied patch from Franck Joncourt to remove unnecessary
chmod() call when creating client rc file and server replay cache file.
The permissions are now set appropriately via open(), and at the same
time this patch fixes a potential race condition since the previous code
used fopen() followed by chmod().
2012-10-23 21:47:56 -04:00
Michael Rash
55fa4841f2 another merge from master 2012-09-03 22:32:44 -04:00
Michael Rash
e3a78a175c verify_file_perms_ownership() to just return if the file doesn't exist 2012-09-01 21:55:52 -04:00
Michael Rash
dafcfbc488 bug fix to make sure to verify file permissions/ownership on files that actually exist 2012-08-31 23:00:45 -04:00
Michael Rash
5daaca01ea merged master 2.0.3 changes 2012-08-31 21:43:55 -04:00
Michael Rash
a60f05ad44 file permissions and client buffer overflow fix
- [client+server] Fernando Arnaboldi from IOActive found that strict
filesystem permissions for various fwknop files are not verified.  Added
warnings whenever permissions are not strict enough, and ensured that
files created by the fwknop client and server are only set to user
read/write.
- [client] Fernando Arnaboldi from IOActive found a local buffer overflow
in --last processing with a maliciously constructed ~/.fwknop.run file.
This has been fixed with proper validation of .fwknop.run arguments.
2012-08-29 22:21:43 -04:00
Michael Rash
8d6bc05295 merged from master 2012-08-17 21:19:52 -04:00
Michael Rash
3af8e4c517 [client] Added cipherdyne.com backup check in -R mode.
Added backup check against a cipherdyne.com 'myip' cgi instance in -R mode if
the normal check against cipherdyne.org fails.
2012-08-15 22:49:29 -04:00
Michael Rash
c37047ac93 Memory leak bug fix in --key-gen mode
This commit fixes the following memory caught with the test suite in valgrind
mode:

HEAP SUMMARY:
    in use at exit: 285 bytes in 4 blocks
  total heap usage: 11 allocs, 7 frees, 3,179 bytes allocated

5 bytes in 1 blocks are indirectly lost in loss record 1 of 4
   at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
   by 0x50CB801: strdup (strdup.c:43)
   by 0x4E3A7B2: fko_set_username (fko_user.c:96)
   by 0x4E39628: fko_new (fko_funcs.c:86)
   by 0x10AB54: main (fwknop.c:83)

7 bytes in 1 blocks are indirectly lost in loss record 2 of 4
   at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
   by 0x4E395D7: fko_new (fko_funcs.c:62)
   by 0x10AB54: main (fwknop.c:83)

17 bytes in 1 blocks are indirectly lost in loss record 3 of 4
   at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
   by 0x4E3A06A: fko_set_rand_value (fko_rand_value.c:114)
   by 0x4E39605: fko_new (fko_funcs.c:75)
   by 0x10AB54: main (fwknop.c:83)

285 (256 direct, 29 indirect) bytes in 1 blocks are definitely lost in loss record 4 of 4
   at 0x4C29DB4: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
   by 0x4E395BA: fko_new (fko_funcs.c:46)
   by 0x10AB54: main (fwknop.c:83)

LEAK SUMMARY:
   definitely lost: 256 bytes in 1 blocks
   indirectly lost: 29 bytes in 3 blocks
     possibly lost: 0 bytes in 0 blocks
   still reachable: 0 bytes in 0 blocks
        suppressed: 0 bytes in 0 blocks
2012-08-02 22:00:05 -04:00
Michael Rash
fd30a3491d minor variable rename LENGTH -> LEN, STRING_LENGTH -> STR_LEN 2012-07-29 21:57:05 -04:00
Michael Rash
ab52476bfc [test suite] [client] added --key-gen and --key-gen-file tests 2012-07-27 13:05:29 -04:00
Michael Rash
175374337d merged crypto_update after fwknop-2.0.1 merge to crypto_update from master 2012-07-24 17:10:00 -04:00
Michael Rash
c6b674617c completed merge from master after fwknop-2.0.1 release 2012-07-24 16:19:48 -04:00
Michael Rash
24dccb34ec [client] fix memory leak when unable to open --get-key file 2012-07-23 21:23:23 -04:00
Michael Rash
049545b459 [client] Fixed several minor memory leaks caught by valgrind
This commit fixes memory leaks like the following in the fwknop client:

HEAP SUMMARY:
    in use at exit: 300 bytes in 11 blocks
  total heap usage: 100 allocs, 89 frees, 16,583 bytes allocated

16 bytes in 1 blocks are indirectly lost in loss record 1 of 11
   at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
   by 0x5146C59: __nss_lookup_function (nsswitch.c:456)
   by 0x5C3D63E: ???
   by 0x50FF3FC: getpwuid_r@@GLIBC_2.2.5 (getXXbyYY_r.c:256)
   by 0x508938E: cuserid (cuserid.c:37)
   by 0x4E3983A: fko_set_username (fko_user.c:65)
   by 0x4E38D5C: fko_new (fko_funcs.c:84)
   by 0x10A824: main (fwknop.c:75)

16 bytes in 1 blocks are indirectly lost in loss record 2 of 11
   at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
   by 0x5146C59: __nss_lookup_function (nsswitch.c:456)
   by 0x5C3D658: ???
   by 0x50FF3FC: getpwuid_r@@GLIBC_2.2.5 (getXXbyYY_r.c:256)
   by 0x508938E: cuserid (cuserid.c:37)
   by 0x4E3983A: fko_set_username (fko_user.c:65)
   by 0x4E38D5C: fko_new (fko_funcs.c:84)
   by 0x10A824: main (fwknop.c:75)

16 bytes in 1 blocks are indirectly lost in loss record 3 of 11
   at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
   by 0x5146C59: __nss_lookup_function (nsswitch.c:456)
   by 0x5C3D672: ???
   by 0x50FF3FC: getpwuid_r@@GLIBC_2.2.5 (getXXbyYY_r.c:256)
   by 0x508938E: cuserid (cuserid.c:37)
   by 0x4E3983A: fko_set_username (fko_user.c:65)
   by 0x4E38D5C: fko_new (fko_funcs.c:84)
   by 0x10A824: main (fwknop.c:75)

16 bytes in 1 blocks are indirectly lost in loss record 4 of 11
   at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
   by 0x5146C59: __nss_lookup_function (nsswitch.c:456)
   by 0x5C3D68C: ???
   by 0x50FF3FC: getpwuid_r@@GLIBC_2.2.5 (getXXbyYY_r.c:256)
   by 0x508938E: cuserid (cuserid.c:37)
   by 0x4E3983A: fko_set_username (fko_user.c:65)
   by 0x4E38D5C: fko_new (fko_funcs.c:84)
   by 0x10A824: main (fwknop.c:75)
2012-07-22 23:09:32 -04:00
Michael Rash
de7aa3b619 Add INPUT ACCEPT rule for --nat-local connections
When using the --nat-local argument on the fwknop client command line, the
fwknopd server needs to add an INPUT ACCEPT rule for the requested access
since the incoming connection is destined for a local socket.  Added test
suite support to test --nat-local access.

[test suite] Minor bug fix to ensure that all file_find_regex() calls return
true if all regex's are matched and false if any regex does not match data in
the specified file.
2012-07-15 21:32:14 -04:00
Michael Rash
47e39272ed Make encrypt/decrypt code accept integer key lengths instead of using strlen()
Now that encryptions keys and hmac keys may be acquired from /dev/random with
--key-gen (and base64 encoded), they may contain NULL bytes.  This emphasizes
the need to not leverage code that assumes C-style strings when making use of
key information.
2012-07-10 21:44:06 -04:00