58 Commits

Author SHA1 Message Date
Jonathan Bennett
ae5451dccc Doxygen headers for libfko files 2016-01-01 02:04:24 +00:00
Michael Rash
a85b081f79 copyright update 2015-12-23 14:34:51 -05:00
Michael Rash
285ec0ddcb [server] add AFL support for fuzzing SPA Rijndael decryption routine directly with --afl-pkt-file 2014-12-03 20:25:05 -05:00
Michael Rash
4878607254 [libfko] removed fko_new_strdup() fault injection tag since fko_destroy() isn't called 2014-06-16 17:11:52 -04:00
Michael Rash
42a20616b4 [libfko] additional fault injection additions with test suite support 2014-06-14 21:27:18 -04:00
Michael Rash
82b05b9530 [libfko] fko_new() bug fix to not leak memory under fko_set_... error conditions
This commit changes how fko_new() deals with FKO context initialization
to not set ctx->initval back to zero (uninitialized) imediately after
calling each fko_set_... function and before checking the fko_set_... return
value.  The reason for this change is that fko_destroy() checks for
context initialization via ctx->initval before calling free() against
any heap allocated context member. So, if fko_set_... returns an error,
fko_destroy() (previous to this commit) would have no opportunity to
free such members.

This bug was found with fault injection testing provided by libfiu
together with valgrind. Specifically the following test suite command
exposes the problem (from the test/ directory):

./test-fwknop.pl --enable-complete --include "fault injection.*libfko"

In the resulting output/2.test file valgrind reports the following:

==27941== LEAK SUMMARY:
==27941==    definitely lost: 264 bytes in 1 blocks
==27941==    indirectly lost: 28 bytes in 3 blocks
==27941==      possibly lost: 0 bytes in 0 blocks
==27941==    still reachable: 1,099 bytes in 12 blocks
==27941==         suppressed: 0 bytes in 0 blocks

After this commit is applied, this changes to:

==7137== LEAK SUMMARY:
==7137==    definitely lost: 0 bytes in 0 blocks
==7137==    indirectly lost: 0 bytes in 0 blocks
==7137==      possibly lost: 0 bytes in 0 blocks
==7137==    still reachable: 1,099 bytes in 12 blocks
==7137==         suppressed: 0 bytes in 0 blocks

Note that 'definitely lost' in valgrind output means there is a real
memory leak that needs to be fixed whereas 'still reachable' is most
likely not a real problem according to:

http://valgrind.org/docs/manual/faq.html#faq.deflost
2014-06-06 21:28:28 -04:00
Michael Rash
6d1d66fe03 add --fault-injection-tag support to the client/server/libfko
This is a significant commit to add the ability to leverage libfko fault
injections from both the fwknop client and server command lines via a
new option '--fault-injection-tag <tag name>'.  This option is used by
the test suite with the tests/fault_injection.pl tests.
2014-06-05 23:05:49 -04:00
Michael Rash
35ad832392 [libfko] started on libfiu fault injection code 2014-05-24 10:14:28 -04:00
Michael Rash
9e990c9be0 fix header non-ascii chars, and introduce test suite support for detecting this in source files 2014-03-14 09:14:35 -04:00
Michael Rash
bfdbb8f260 Updated authorship and copyright information
This commit updates all authorship and copyright information to include a
standard header that references the AUTHORS and CREDITS file. This standard
header was written by the Debian legal team at the request of Franck Joncourt.
2014-03-04 17:53:10 -05:00
Michael Rash
227d0ab947 [libfko] ensure NULL is handled properly for all fko_get_* functions 2013-12-31 23:27:05 -05:00
Michael Rash
7aa6d37fff [libfko] added NULL check for fko_set_spa_data() data arg 2013-12-30 21:56:08 -05:00
Michael Rash
297d7d00fe [libfko] enc key NULL checks with fko-wrapper test support 2013-12-29 22:44:16 -05:00
Michael Rash
0c6911941b [libfko] reject negative length values
Integer lengths that are negative are never valid.  This commit also
extends the fuzzing capabilities of the test/fko-wrapper code to
validate libfko calls with negative length arguments, and one crash
scenario with a negative length for the encryption key was found (and
fixed) this way.
2013-12-29 21:05:04 -05:00
Michael Rash
0d80f72c00 Revert "[test suite] minor Test::Valgrind name typo fix"
This reverts commit 642024041534d79c897a21b2e19ef3e1ed7b2a61.
2013-10-22 20:36:30 -04:00
Michael Rash
6420240415 [test suite] minor Test::Valgrind name typo fix 2013-10-22 16:18:46 -04:00
Hank Leininger
bc907e0b24
Add unique errors for every FKO_ERROR_INVALID_DATA. Needed this to
track down mystery errors (#98).
2013-08-05 22:21:10 -04:00
Michael Rash
3756b831f5 simplified zero_free() calls in support of #93 2013-07-09 22:17:05 -04:00
Michael Rash
24c4c5e208 continued zeroing out of sensitive data buffers in support of issue #93 2013-07-08 23:00:18 -04:00
Franck Joncourt
c2e1a00154 s/GNU Public/GNU General Public/g 2013-06-30 22:21:22 +02:00
Michael Rash
382099e85a Updated copyright dates, removed NEWS file in favor of the ChangeLog 2013-06-02 14:07:01 -04:00
Michael Rash
45244114f8 [client] --key-gen bug fix to print keys to stdout 2013-05-17 21:03:16 -04:00
Michael Rash
d85c2e74ce [libfko] set ctx=NULL after fko_destroy(), add NULL check for encrypted msg pointer in fko_new_with_data() 2013-05-12 20:53:22 -04: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
bf6cc6c605 --key-gen bug fix to allow --key-len and --hmac-key-len values to apply to generated key lengths 2013-03-11 23:02:07 -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
Michael Rash
44d05a6916 interim commit for supporting multiple HMAC digest types (# 45) 2013-03-07 23:14:48 -05:00
Michael Rash
ffcb77552b Remove lib/fko.h dependency on rijndael.h 2013-02-28 21:47:43 -05:00
Michael Rash
6c2b657bfe [libfko] free dynamically allocated resources for multiple libfko fcn calls 2013-02-21 22:44:33 -05:00
Michael Rash
2b54cb94f5 memory leak bug fix for fko_new() to allow multiple calls without requiring external fko_destroy() call 2013-02-21 08:36:29 -05:00
Michael Rash
ce18de4f84 make libfko pointers constant where possible 2013-02-12 22:39:39 -05:00
Michael Rash
160a9e5565 perl FKO module HMAC compatibility 2013-01-20 14:27:27 -05:00
Michael Rash
e80a6de5f7 Memory leak bug fix discovered through the "altered HMAC test"
This commit fixes a memory leak caught with valgrind in the "altered HMAC
test":

 [+] fwknop functions (unique view):
-        9 : ???
-        4 : main
-        4 : pcap_capture
-        2 : incoming_spa
-        2 : fko_new_with_data
-        2 : fko_verify_hmac
+        7 : ???
+        2 : pcap_capture
+        2 : main
         1 : pcap_compile
-        1 : strdup
-        1 : fko_calculate_hmac
-        1 : add_salted_str

 [+] fwknop functions (with call line numbers):
-        9 : ??? (in /usr/lib/x86_64-linux-gnu/libpcap.so.1.1.1)
-        4 : main (fwknopd.c:299)
-        2 : fko_new_with_data (fko_funcs.c:220)
-        2 : pcap_capture (pcap_capture.c:226)
-        2 : incoming_spa (incoming_spa.c:378)
-        1 : add_salted_str (cipher_funcs.c:298)
-        1 : strdup (strdup.c:43)
-        1 : fko_verify_hmac (fko_hmac.c:78)
-        1 : fko_verify_hmac (fko_hmac.c:92)
-        1 : pcap_capture (pcap_capture.c:105)
+        7 : ??? (in /usr/lib/x86_64-linux-gnu/libpcap.so.1.1.1)
+        2 : main (fwknopd.c:299)
         1 : pcap_compile (in /usr/lib/x86_64-linux-gnu/libpcap.so.1.1.1)
         1 : pcap_capture (pcap_capture.c:97)
-        1 : fko_calculate_hmac (fko_hmac.c:169)
+        1 : pcap_capture (pcap_capture.c:105)
2012-08-19 10:43:30 -04:00
Michael Rash
3d9e96af56 Memory leak fix in client test mode
This commit fixes the following memory leak found with the test suite running
in valgrind mode:

HEAP SUMMARY:
    in use at exit: 217 bytes in 3 blocks
  total heap usage: 27 allocs, 24 frees, 5,260 bytes allocated

44 bytes in 1 blocks are definitely lost in loss record 1 of 3
   at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
   by 0x50CB861: strndup (strndup.c:46)
   by 0x4E3A4D4: fko_verify_hmac (fko_hmac.c:54)
   by 0x4E394DD: fko_new_with_data (fko_funcs.c:220)
   by 0x10B3A7: main (fwknop.c:408)

44 bytes in 1 blocks are definitely lost in loss record 2 of 3
   at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
   by 0x50CB801: strdup (strdup.c:43)
   by 0x4E3A3FC: fko_calculate_hmac (fko_hmac.c:162)
   by 0x4E3A552: fko_verify_hmac (fko_hmac.c:86)
   by 0x4E394DD: fko_new_with_data (fko_funcs.c:220)
   by 0x10B3A7: main (fwknop.c:408)

129 bytes in 1 blocks are definitely lost in loss record 3 of 3
   at 0x4C2B7B2: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
   by 0x4E36A03: add_salted_str (cipher_funcs.c:298)
   by 0x4E3A587: fko_verify_hmac (fko_hmac.c:75)
   by 0x4E394DD: fko_new_with_data (fko_funcs.c:220)
   by 0x10B3A7: main (fwknop.c:408)

LEAK SUMMARY:
   definitely lost: 217 bytes in 3 blocks
   indirectly lost: 0 bytes in 0 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:46:52 -04:00
Michael Rash
fd30a3491d minor variable rename LENGTH -> LEN, STRING_LENGTH -> STR_LEN 2012-07-29 21:57:05 -04:00
Michael Rash
482e6f974c added msg_hmac_len and removed additional strlen() calls 2012-07-27 21:29:26 -04:00
Michael Rash
10195cf29a [libfko] added encrypted_msg_len and replaced additional strlen() calls 2012-07-27 18:16:37 -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
6255bff95f replace strlen() calls with strnlen() and appropriate maximums 2012-07-22 23:13:39 -04:00
Michael Rash
d7c4572521 merged test suite changes from the crypto_update branch 2012-07-10 22:03:56 -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
Michael Rash
dc8a034a4d merged usage() information from master 2012-07-08 22:00:13 -04:00
Michael Rash
ba3b7d1d11 Bug fix for multi-stanza key use and replay attack detection
This commit fixes a bug where the same encryption key used for two stanzas in
the access.conf file would result in access requests that matched the second
stanza to always be treated as a replay attack.  This has been fixed for
the fwknop-2.0.1 release, and was reported by Andy Rowland.  Now the fwknopd
server computes the SHA256 digest of raw incoming payload data before
decryption, and compares this against all previous hashes.  Previous to this
commit, fwknopd would add a new hash to the replay digest list right after
the first access.conf stanza match, so when SPA packet data matched the
second access.conf stanza a matching replay digest would already be there.
2012-07-07 21:31:30 -04:00
Michael Rash
92e403a242 added initial HMAC-SHA256 support for the client side 2012-07-02 23:50:45 -04:00
Michael Rash
3095f0ee43 Added key generation support with --key-gen
Added --key-gen to allow KEY_BASE64 and HMAC_KEY_BASE64 keys to be created from
reading random data from /dev/random.  These keys can be placed within server
access.conf files and corresponding client .fwknoprc files for SPA
communications.  The HMAC key is not used yet with this commit, but that is
coming.
2012-06-27 23:06:17 -04:00
Michael Rash
4c3d2188a1 Update to make AES encryption modes selectable
This is a significant update to allow AES encryption modes to be selected on a
per-key basis.  For now, only ECB and CBC (recommended) modes are supported.
The default is ECB modes in order to maintain backwards compatibility with the
older perl version of fwknop and the Crypt::CBC CPAN module.  This will likely
be changed to use CBC mode by default because of its better security
properties.

In the access.conf file on the server side, there is a new configuration
variable "ENCRYPTION_MODE" that controls the mode for the corresponding AES
key.  On the client side, a new command line argument "--encryption-mode"
controls how the client encrypts SPA packets.
2012-01-24 20:26:21 -05:00
Michael Rash
6388e8ac7f added 'const' to function prototype vars where possible
Added the 'const' qualifier to function prototype variables where possible.
In addition, reduced some functions to file-scope with 'static' where possible.

Also made a few minor changes to remove extra whitespace, and fixed a bug
in create_fwknoprc() to ensure the new fwknoprc filehandle is closed.
2011-10-25 21:00:40 -04:00
Michael Rash
ca5f82c067 Removed legacy $Id$ tags from svn
$Id$ tags don't really mean anything to git so they have been removed from all
source files.
2011-06-18 20:53:40 -04:00