Commit Graph

234 Commits (c402947e3e5eff8368ab1e458014b831fd39c779)

Author SHA1 Message Date
Jacob Barthelmeh ce1ced27dc additional sanity checks 2018-03-30 17:05:04 -06:00
Jacob Barthelmeh ae70eb7b44 initial port to pic32 2018-03-30 10:33:25 -06:00
Chris Conlon 48590f6896
Merge pull request #44 from ejohnstown/scp-submission
SCP Contribution
2018-03-29 15:11:20 -06:00
Jacob Barthelmeh 3b6b70adeb update SHA256 name 2018-03-27 14:42:06 -06:00
John Safranek b578aadc6d SCP Contribution 2018-03-26 11:09:21 -07:00
John Safranek bbbc14ea6b Bug Fixes
1. Fix an incorrect memory free when releasing a bad WOLFSSH object.
2. Pass correct context to the I/O Send Callback function.
2017-12-01 12:04:56 -08:00
dgarske 83db50f7b6 Merge pull request #40 from ejohnstown/testsuite
Test Suite
2017-10-04 15:10:36 -07:00
John Safranek 911a00ae2c Channel Close
1. Renumbered a few error codes.
2. Added an error code for stream reading when the channel is closed during the read action.
2017-09-29 16:11:04 -07:00
John Safranek 16b4a31cfb Test Suite
1. Add an automated test suite.
2. Refactor the existing test and example code to be better components for the test suite.
3. Rename some of the internal functions used by the examples and test suite.
4. Echoserver now only handles one connection at a time, has option to exit after single connection.
5. Echoserver can do the port zero trick for the test suite.
6. Some whitespace changes.
7. Added a `(void)` to a variable to hush an unused assignment warning.
2017-09-29 13:48:40 -07:00
John Safranek 65fb16ddc4 Client
1. Added support to the library for clients.
2. Added example client.
3. Added VS solutions for building client example.
4. Added ECC client keys. Renamed existing keys.
5. Since defunct server is copy of echoserver, updated it.
2017-09-25 14:45:03 -07:00
John Safranek e471635373 IDE
1. Added DLL builds.
2. Cleaned up some of the build configuration.
3. Updated the README files for building.
4. Renamed the function ProcessBuffer() with a prefix due to a conflicting name with wolfSSL.
5. Added test.h to include.am.
6. Moved the user_settings.h for wolfSSL into the wolfcrypt directory.
7. Changed the echoserver so that it binds to INADDR_ANY.
2017-09-13 15:33:23 -07:00
John Safranek 1498bc5409 IDE Support
1. Added Windows Visual Studio build solution. Includes projects for:
 * wolfSSH static library
 * echoserver
 * unit-test
 * api-test
 * 32- and 64-bit debug and release builds for all
2. Made necessary tweaks including adding some wrapper functions so the code compiles for both Linux/macOS and Windows.
3. Fixed a bug in the KDF test where the output buffer wasn't updated when SHA-256 was added.
4. Added the fallthrough attribute for GCC7.
5. Replaced all uses of `uint8_t`, `uint16_t`, and `uint32_t` with the wolfCrypt provided `byte`, `word16`, and `word32`.
6. Split the new channel function into new and init.
7. Added some ECC keys for authentication testing.
8. Moved some functions and includes around.
9. Removed the keying state machine and replaced with a flag.
10. Added rekey trigger if the client sends *CTRL-F* to echoserver.
11. Moved the sequence number increase outside `CreateMac()`. Incremented if the packet was successfully created. This way the sequence number is incremented when using AES-GCM.
12. Removed the redundant function `SendText()`.
13. Renamed the `clientId` related functions and data members to `protoId` to keep things role agnostic.
14. Changed all references of `clientKey` and `serverKey` to `keys` and `peerKeys`.
15. Updated `GenerateKeys()` to generate `keys` and `peerKeys` appropriately based on the endpoint side.
16. Added the wolfSSL style _test.h_ file to group shared example functions in one place.
17. Changed the echoserver to be similar to wolfSSL's where the code may be included without the main function in another executable.

Note:
This commit is a squash of more than a dozen commits. IDE support was added to the client branch, but the client branch is on hold. There were many changes in the client branch that are needed going forward. The code at the head of the client branch was copied over to the IDE branch, and the client code either deleted or removed from the build.
2017-09-12 14:42:23 -07:00
John Safranek 1d594eba1f ECC (#35)
* Renamed the server key files to indicate they are rsa keys.
* Add ecc key files for the server.
* Move ProcessBuffer from ssh.c to internal.c.
* Remove #includes for headers from files that are not used.
* Added support for KEX algorithms: ecdh-sha2-nistp256, ecdh-sha2-nistp384, ecdh-sha2-nistp521
* Updated readme
* Added support for the public key algorithm ecdsa-sha2-nistp256.
* Added support for public key algorithms ecdsa-sha2-nistp384 and ecdsa-sha2-nistp521.
* The Key Algorithm list for the KEX picks a single value to offer based on the private key used.
* Added private keys on curves nistp384 and nistp521. The curve nistp256 is used as the default.
* Added the new ecc keys to include.am
2017-07-14 12:24:38 -07:00
John Safranek b86bb31cdd 1. Added in the code needed for AES-GCM.
2. Deleted the unused wolfSSH_worker() prototype.
2017-07-11 08:56:21 -07:00
John Safranek be57ef6b95 1. Bump the version numbers.
2. Remove some unused option strings and constants. They may be
   distracting.
2017-07-06 16:24:18 -07:00
John Safranek 26642bfa2c Remove the TEST_GEX build option. The DHGEX key agreement is the
first desired algo for the server.
2017-06-12 12:24:57 -07:00
John Safranek da126bfa48 Refactor the KEX init code to delay the start of calculating the KEX
hash until the KEXINIT from the client is received.
2017-06-12 12:24:57 -07:00
John Safranek 97e27cb7be DH-GEX
Filled out the message handling for the DH-GEX additional messages. To use
the DH-GEX, one needs to add the flag TEST_GEX. It is still a WIP. The
handshake state machine needs a change and the start of the hash calculation
needs to wait until receiving the client's KEX INIT message and the hash
type for the handshake signature can be resolved.
2017-06-12 12:24:57 -07:00
John Safranek 1a81d66f78 Framing in DH-GEX. 2017-06-12 12:24:57 -07:00
John Safranek 4319cb069c Unified Hashing
1. Added support for the wc_Hash wrappers. Need to keep track of the
   hash being used.
2. Assumed SHA1 only, and modified everything to use the hash wrappers.
2017-06-12 12:24:57 -07:00
John Safranek fcf0e5c55d SHA-256 Hash Support
1. Expanded GenerateKey() to obey the hash type.
2. Added cases for SHA-256 to the KDF test.
2017-06-12 12:24:57 -07:00
John Safranek 3cb286b600 Fix bug where client initiated rekeying failed. 2017-06-12 11:58:39 -07:00
dgarske 687d13a349 Merge pull request #28 from ejohnstown/string-clean
Update a few debugging strings were copied and pasted.
2017-06-12 11:17:38 -07:00
dgarske 7eb1dad6ef Merge pull request #27 from ejohnstown/fix-getstring
Fix GetString
2017-06-12 11:17:17 -07:00
dgarske a0d40e0cd1 Merge pull request #26 from ejohnstown/banner-config
Update the banner
2017-06-12 11:16:11 -07:00
John Safranek 95a435055f Update a few debugging strings were copied and pasted. 2017-06-12 10:17:54 -07:00
John Safranek ff14fbaef8 In GetString() added a check for the size of the destination buffer. 2017-05-30 14:38:15 -07:00
John Safranek a4285571f4 Update the banner
1. Add the banner to the WOLFSSH_CTX.
2. Moved the canned banner to be a debug option.
3. Default the banner to NULL of zero length.
4. Use the banner stored in the WOLFSSH_CTX.
5. Add an accessor to set the banner to a C string.
2017-05-30 14:25:41 -07:00
John Safranek 3d79d4ffa3 Global Request Message
1. Added parsing of the Global Request message. Will log the request
   name string.
2. Send global request failure response if reply is requested.
(This was an issue with a particular SSH client.)
2016-11-11 12:00:22 -08:00
John Safranek c2480eb46c Add function to send Channel Success and Failure to the client when
receiving Channel Request messages, when requested.
2016-10-25 14:14:05 -07:00
John Safranek 6af24baf38 Fixed a missed set of wolfCrypt functions whose return values weren't getting checked. 2016-10-24 15:24:04 -07:00
John Safranek b76f376381 scan-build fix. clear a whole buffer before filling it before checking
with ConstantCompare().
2016-10-24 15:08:58 -07:00
John Safranek c802b331bd Check all return codes on wolfCrypt functions. 2016-10-24 15:03:54 -07:00
John Safranek c183000b93 1. Manage case where Client KEX Init arrives in same recv() as the
client version string.
2. Shrink the receive buffer after reading the client version
   string.
3. Resize the buffer correctly when needed data is already in the input
   buffer and grab the remainder as expected.
2016-10-24 13:42:58 -07:00
John Safranek ccc1101612 Fix where the result of sending a channel close was getting replaced
with success.
2016-10-23 16:14:17 -07:00
John Safranek bc9eff91d6 1. Rename function ProcessReply(), conflicts when linking against
wolfSSL not using cryptonly mode.
2. Send server version before expecting client version.
2016-10-23 15:43:08 -07:00
John Safranek 5b07c8cb1d 1. Parse the Channel EOF message.
2. Parse the Channel Close message, and reply with a Channel Close.
2016-10-23 14:46:34 -07:00
John Safranek 184b2218d4 Rekeying Update
1. Add the Trigger Rekeying function.
2. Fixing the keying state machine.
3. Modify echoserver for rekeying.
2016-10-21 13:40:35 -07:00
John Safranek 41ec11e6ab Rekeying Update
1. Flushing out the keying state machine, taking it out of the accept
   state machine.
2. Changed the HandshakeInfo record to be something that can be
   recreated post-initial connection for rekeying.
3. Fixed the name of a previously unused size variable.
4. Moved some constants around.
2016-10-16 20:25:24 -07:00
John Safranek c564550999 Automatic Session Rekeying
1. Add stub rekey trigger function.
2. Add new default highwater callback that calls the rekey trigger
   function.
3. Rename the highwater level as "mark" rather than "count".
4. Add a flag to call the highwater callback once, cleared when the
   txCount is cleared when sending new keys message to peer.
5. Add new state machine for key exchange.
6. Start massaging the accept state machine for new KEX machine.
7. Update some default sizes, and replace magic numbers with named
   constants.
8. Scale back the accept state machine to add in the KEX state
   machine.
9. Capture the client version string and the server's KEX init message
   for rekeying.
10. Add compiler flag to allow "none" as a user auth method.
2016-10-16 15:16:24 -07:00
John Safranek b3ee5cd381 Send channel window adjust update when the receive buffer
has processed at least half of its available space. By
default, the receive window is 1MB, and the window size is
increased every 512kB.
2016-10-16 12:11:50 -07:00
John Safranek b6cda842e8 add function to notify peer of window size adjustment 2016-10-14 12:45:09 -07:00
John Safranek d9808cec31 tweak the peerWindowSz updating and logging 2016-10-14 12:45:09 -07:00
John Safranek da4b19524d RSA Private Key Generation Wrapper Function
1. Implemented the RSA key generation wrapper function.
2. Rearrange the unit test code.
3. Added RSA key generation wrapper function to unit test.
4. Removed certificate load from echoserver.
5. Not using certificates, removed the functions and storage.
6. Removed unused certificate files.
7. Renamed certs directory as keys.
8. Removed the example server from the build for now.
9. Created new server key with the RSA key generation function.
10. Add IDs for public keys for keygen use.
11. Whitespace cleanup.
2016-10-13 10:02:03 -07:00
John Safranek 04e361a558 1. fix scan-build warning on ConstantCompare
2. fix visibility label typos
2016-10-07 10:04:04 -07:00
John Safranek 6561da9ce2 Updates to the data highwater marks for a callback. 2016-10-04 09:55:09 -07:00
John Safranek 7c8801409c Move the WOLFSSH and WOLFSSH_CTX initializer and free functions from
ssh.c to internal.c.
2016-10-04 09:55:09 -07:00
John Safranek 73e4e58795 1. Regroup the session keys into a separate structure.
2. Separate sets of keys for client and server.
3. Store generated keys in handshake info record.
4. Copy session keys over when sending and receiving the
   New Keys message.
2016-10-04 09:55:09 -07:00
John Safranek 30c4a32611 1. Add accessors for session data high water mark.
2. Check transmit and receive against high water mark and log.
2016-10-04 09:55:09 -07:00
JacobBarthelmeh 1039cb9d43 Merge pull request #13 from ejohnstown/more-cleanup
More Cleanup
2016-07-22 10:31:34 -06:00
John Safranek c8da16cbe8 use the proper memcpy alias for wolfSSH 2016-07-22 09:30:02 -07:00
John Safranek 2e1744265b more return code checking 2016-07-21 20:07:29 -07:00
John Safranek f865ad2487 move the primitive data decoders, use them more 2016-07-20 19:57:54 -07:00
John Safranek 1a278fe713 update copyright dates and licensing to GPLv3 2016-07-19 13:44:02 -07:00
John Safranek bebe452d12 removed goto from processing the public key authentication 2016-07-19 11:03:37 -07:00
John Safranek 4041ecf408 Updated many functions with better error checking. 2016-07-18 21:21:42 -07:00
John Safranek 1e77d1595b 1. Sending data to a channel needs to use the peer channel ID.
2. Added a default peer channel ID for transmits.
3. Refactor the SendChannelData and SendChannelOpenConf functions.
2016-07-18 14:19:20 -07:00
John Safranek 79c8a503c4 1. Added some more return code checking and returning.
2. Look up channels in the channel list when processing
channel based messages rather than assuming the first
channel in the list.
2016-07-15 14:51:09 -07:00
John Safranek 1389df80bc initial multi-channel support 2016-07-14 22:46:06 -07:00
John Safranek 9ebcd5c44a fix trying to decrypt messages where the body fits in with the length block 2016-07-14 15:42:23 -07:00
John Safranek 525a8858c5 Add return code when the peer window is too small on a send. Echoserver wasn't properly checking the return code on the stream receive. 2016-07-14 14:47:30 -07:00
John Safranek a2c5e8e793 React to invalid username with a regular auth failure, nothing fancy. Fancy was causing a crash. 2016-07-14 13:53:23 -07:00
John Safranek 0994a1816d fix a couple initialization issues found in scan-build 2016-07-13 23:53:13 -07:00
John Safranek cf2cb5f67b deleted extra print statements 2016-07-13 15:11:33 -07:00
John Safranek 4dc3c56a88 fixing RSA public key user auth, failover to password 2016-07-13 15:11:33 -07:00
John Safranek a1e07e3161 1. Added extra debugging logs to the user authentication.
2. Reject invalid user names.
3. Fix the readme with regards to the public key log in testing.
2016-07-13 15:11:33 -07:00
John Safranek de477fcc14 remove stray peerMacSz printf 2016-06-22 14:48:26 -06:00
John Safranek 84b1fd3d0e added HMAC-SHA2-256 2016-06-22 11:26:18 -06:00
John Safranek 15023f54b6 verify the correct public key type and signature type during auth 2016-06-17 15:54:24 -07:00
John Safranek 89d92bb886 refactor userauth 2016-06-17 14:23:20 -07:00
John Safranek a275ac59f0 1. Flushed out the authentication callback.
2. Added public key authentication.
2016-06-17 14:23:20 -07:00
John Safranek a744dcc540 refactor DoPacket to pass the correct data pointer and data index update 2016-06-17 14:23:20 -07:00
John Safranek 911ac8c433 1. Adding parsing of publickey authentication data.
2. Changed logging of authentication requests.
3. Reply to "none" authentication types with a failure that
   has the supported auth type list.
4. Fixed bug where passing payload to the DoUserAuthRequest wasn't
   getting the correct payload length.
5. Reordered a couple utility functions.
2016-06-17 14:20:59 -07:00
dgarske 8e3e5a1bf5 Merge pull request #3 from ejohnstown/fixes1
Fixes1
2016-06-17 11:29:01 -07:00
John Safranek 49be153c61 verify the mac even if the decrypt fails 2016-04-15 10:25:04 -07:00
John Safranek bda5870fc5 more checking of return codes 2016-04-06 15:48:37 -07:00
John Safranek 5eb8b8111a Use wolfssl/wolfcrypt instead of cyassl/ctaocrypt, add wc_ prefix to wolfcrypt function calls. 2016-04-05 15:42:38 -07:00
John Safranek 59590e28f3 scan-build fixes:
1. Disconnect string was unused in non-debug builds.
2. Check return code from decrypting the length block.
2016-04-04 09:32:49 -07:00
John Safranek 0386a3c50f move shared inline functions to misc file. add configure option to disable inline functions. 2016-04-01 14:40:22 -07:00
John Safranek 1566cf82a0 added parameter checks to GenerateKey and an option to print out the session secrets for debugging 2016-04-01 10:42:18 -07:00
John Safranek 564506c038 Make KDF publically accessable. Add KDF test using keys from two successful connections. 2016-03-31 12:10:44 -07:00
John Safranek 4982638781 add ForceZero() and ConstantCompare() to the code 2015-12-09 16:01:23 -08:00
John Safranek 793a19857f update copyright banner on sources 2015-12-08 13:45:20 -08:00
John Safranek f9fa42e244 1. added in the stream receive function
2. example uses the new receive function
2015-01-14 10:53:33 -08:00
John Safranek b548720a9a 1. added in the stream send function
2. example uses the new send function
3. added in window size update receipt
4. tweaked the accept state machine to actually finish
2015-01-07 13:49:01 -08:00
John Safranek 6975448d1b 1. Fix debug output for DoChannelOpen().
2. Added support for the Channel Request messge.
3. Added support for the Channel Data message.
4. Example server works like a very crude echo server.
2014-12-29 16:43:09 -08:00
John Safranek dab2b248d5 1. Update the accept state machine to account for all the recent
messages.
2. Add sending the open channel confirmation.
3. Starting to refine the logging.
2014-12-29 15:11:04 -08:00
John Safranek 4351b91ddf Starting adding the encrypted bytes tx/rx counters 2014-12-29 09:19:36 -08:00
John Safranek f60895000a Begin refactoring the packet parsing. 2014-12-26 11:28:30 -08:00
John Safranek 0455fe43dd 1. Commented out some of the distracting debugging output.
2. Accepts the none client authentication.
3. Starts to parse the channel open message.
4. Starting to handle channels.
2014-12-24 14:36:06 -08:00
John Safranek 38e51c45c8 1. Framing in the user authentication messages.
2. Removed some outdated/incorrect comments.
3. Removed some of the debugging output clutter.
4. Fixed bug when trying to add multiple messages to a single packet.
2014-12-19 10:59:45 -08:00
John Safranek 89e6d77e10 Updates to wolfSSH_accept()
1. Moved SendNewKeys() to SendKexDhReply() so both messages are sent
in the same packet.
2. Accept state machine checks return codes on Send functions.
3. Added a couple new states for some of the Send functions.
2014-12-18 16:01:32 -08:00
John Safranek d0c6768d5d fix bug with skipping received unimplemented messages 2014-12-18 15:17:07 -08:00
John Safranek 62d916d016 update buffer index when receiving the service request 2014-12-18 14:57:42 -08:00
John Safranek 4a0f5de683 removed some of the excess logging 2014-12-18 14:47:53 -08:00
John Safranek 9776e237fa SendServerVersion should have returned success not fail 2014-12-18 14:25:54 -08:00
John Safranek adcf881278 fix bug in DoPacket when simplifying payloadSz 2014-12-18 13:58:13 -08:00
John Safranek 10844bfc51 make sure code lines stay within 80 col standard 2014-12-17 15:54:33 -08:00
John Safranek b1e32737c2 Framing in the service request messages 2014-12-16 19:09:40 -08:00
John Safranek 6c49caf9ab Added packet encryption and adding MAC 2014-12-16 13:17:18 -08:00
John Safranek 2ae2d6dcdf 1. Fixed bug with GenerateKey() that didn't take into account secret padding.
2. Fixed bug in DoPacket() that didn't increment the peer's packet sequence.
3. Fixed bug in Decrypt() where the AesCbcDecrypt case dropped through into error.
4. Refactoring the accept state machine.
5. Separating client and server block and MAC sizes.
6. Added client MAC checking.
7. Fixed bug where algorithm picking preferred server order over client.
8. Fixed bug where the algorithm list matching was checking out of bounds.
2014-12-10 21:01:22 -08:00
John Safranek 71bcd94c5f 1. Starting to add in the Decryption and MAC Verification.
2. Fixed bug in getting the entire packet from the socket.
2014-12-08 21:59:21 -08:00
John Safranek 1c902a641e encode signature without CyaSSL's compatibility layer, using wolfCrypt only 2014-12-05 17:37:39 -08:00
John Safranek 156c3bd7a5 tweak to hide the disconnect reason string output 2014-12-05 14:51:20 -08:00
John Safranek bf0133c740 added decode/encode support for base messages 2014-12-05 12:17:27 -08:00
John Safranek 2d959d7bea 1. Generates the session keys.
2. Starting to tie into the bulk encryption and MAC.
2014-09-12 21:00:16 -07:00
John Safranek 917c6a84c4 Clean up build warnings under Linux 2014-08-14 11:46:23 -07:00
John Safranek c142bc305c fix the exchange hash signing issue 2014-09-03 22:48:50 -07:00
John Safranek 852016d8c5 finally calculates the hash correctly, but isn't signing correctly. :/ 2014-09-03 13:50:23 -07:00
John Safranek ad17306d96 correctly builds the packet, hash still wrong 2014-09-02 23:21:17 -07:00
John Safranek 8be65978bb 1. Added compile flag to show the shared master secret.
2. Fixed bug where the client DH e-value wasn't being used.
2014-09-02 11:52:08 -07:00
John Safranek 6be28d3437 fix buffer overflow when generating keys 2014-09-02 11:38:18 -07:00
John Safranek c82b4bb3d8 server sends KexDhReply 2014-09-01 19:11:38 -07:00
John Safranek 21db2e1036 almost have KexDhAgree completed 2014-08-31 23:56:27 -07:00
John Safranek a9ecef7352 90% of KEXDH done 2014-08-28 14:10:02 -07:00
John Safranek b72c16f8e9 Creates and sends the server KEXINIT msg 2014-08-26 15:43:59 -07:00
John Safranek cfb7b90b32 Fill in the server's KEX Init message payload 2014-08-25 09:58:54 -07:00
John Safranek 67bb1cdbdc 1. Adding the packet building and send functions.
2. Fix RNG initializer.
2014-08-23 23:07:12 -07:00
John Safranek 5fb59b3006 Rename function SendBuffer() as SendBuffered() to match wolfSSL. 2014-08-21 14:41:05 -07:00
John Safranek a430fc7e27 Update the MAC and Block size based on the algo IDs. 2014-08-20 16:56:16 -07:00
John Safranek 9bb2576136 Parse out the KEX algo lists. 2014-08-20 11:47:42 -07:00
John Safranek 1c0ff7b151 Decode the KEX Init bits from the peer. 2014-08-18 20:41:53 -07:00
John Safranek 7e2674c29a 1. Added test certificate and private key.
2. Added code to load single certificate and private key from buffers.
2014-08-15 14:20:42 -07:00
John Safranek f4b1908b17 Refactor the constants. 2014-08-15 11:37:00 -07:00
John Safranek e6bfa8c131 1. Removed the peerId from handshake record. It'll be added to the key
hash directly.
2. Framing in the private key and certificate loading functions.
2014-08-14 22:34:55 -07:00
John Safranek 0feaaab922 Moved the handshake data into its own structure so it can be freed when
the handshake completes.
2014-08-13 19:31:59 -07:00
John Safranek f07f623ad6 Modified the input and output buffers, made them members of the
session object, rather than pointers.
2014-08-12 17:21:13 -07:00
John Safranek 8cb5fea384 1. Added a description comment to each C and H file.
2. Updated the FSF address in the comments.
2014-08-11 16:19:11 -07:00
John Safranek 490fd75fa9 1. Moved error number to string conversion to internal.c
2. Removed file error.c
3. Added error code accessor for WOLFSSH objects.
4. Added error string accesor for WOLFSSH objects.
5. Cleaned up the I/O callback prototypes.
2014-08-11 14:29:06 -07:00
John Safranek a96a764bc0 Moved functions to internal.c that belong there. 2014-08-11 14:03:00 -07:00
John Safranek b331ff9cba fixed buffer issue on receive 2014-07-31 11:28:14 -07:00
John Safranek 1d2e1af069 filling in code 2014-07-28 07:12:54 -07:00
John Safranek 1945b2dddd added the Buffer 2014-07-07 17:36:57 -07:00
John Safranek 997013f210 Adding code 2014-07-01 17:27:29 -07:00