27 Commits

Author SHA1 Message Date
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
Damien Stuart
9d821548e7 Fixed bug where libfko would segfault if fko_get_spa_data() was called before fko_spa_data_final() was called (and successful). Added include of time.h in fko.h.
git-svn-id: file:///home/mbr/svn/fwknop/trunk@306 510a4753-2344-4c79-9c09-4d669213fbeb
2010-12-05 14:57:01 +00:00
Damien Stuart
0f6ca00ac4 Updated the GPL blurb at the top of the source files. Added some missing copyright statements (Thanks to Franck Joncourt).
git-svn-id: file:///home/mbr/svn/fwknop/trunk@300 510a4753-2344-4c79-9c09-4d669213fbeb
2010-11-13 03:04:36 +00:00
Damien Stuart
9282a0fd29 Changed to fix possible double-free bug under some circumstances.
git-svn-id: file:///home/mbr/svn/fwknop/trunk@210 510a4753-2344-4c79-9c09-4d669213fbeb
2010-03-14 03:45:03 +00:00
Damien Stuart
d0373a5b33 Fixed libfko so gpgme engine is gpg by default. Added functions to libfko to set/get path to gpgme engine. Fixed some memory leaks. Reworkd the get_user_pw routine. Added code in fwknopd to put back the "hQ" string on the front of incoming GPG-encypted message data. Removed the previously add pretty-print routine to configure. Updated configure to check for path to gpg executable. Updated docs accordingly.
git-svn-id: file:///home/mbr/svn/fwknop/trunk@205 510a4753-2344-4c79-9c09-4d669213fbeb
2010-02-06 03:43:54 +00:00
Damien Stuart
8c1261ca39 Fixed memory leak issue in libfko when fko_new_with_data() was called with a bad key. Added autoconf checks for gdbm with fallback to ndbm for server builds. Added digest cache capability using gdbm (in ndbm compatibility mode) or ndbm for replay detection.
git-svn-id: file:///home/mbr/svn/fwknop/trunk@153 510a4753-2344-4c79-9c09-4d669213fbeb
2009-10-16 02:23:02 +00:00
Damien Stuart
53b7fae8bb Major rearrangement. Renamed directories: "fko" to "lib", "src" to "client". Added "common" and "server" directories. Setup autoconf to allow disabling the server and/or client builds.
git-svn-id: file:///home/mbr/svn/fwknop/trunk@127 510a4753-2344-4c79-9c09-4d669213fbeb
2009-08-09 15:43:16 +00:00
Damien Stuart
1cdf9fd548 Re-arrangement of source tree.
git-svn-id: file:///home/mbr/svn/fwknop/trunk@14 510a4753-2344-4c79-9c09-4d669213fbeb
2008-12-24 22:02:12 +00:00
Damien Stuart
a82c361e28 Another major re-write of the fwknop library.
git-svn-id: file:///home/mbr/svn/fwknop/trunk@13 510a4753-2344-4c79-9c09-4d669213fbeb
2008-12-24 04:31:45 +00:00