Skip to content

Commit

Permalink
Merge pull request #461 from lf-lang/auth-patch
Browse files Browse the repository at this point in the history
Better error messages when HMAC authentication is attempted by federates when RTI does not support it
  • Loading branch information
edwardalee authored Jul 7, 2024
2 parents 8fe0436 + bee7145 commit 4abce72
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions core/federated/RTI/rti_remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -1198,6 +1198,9 @@ static int32_t receive_and_check_fed_id_message(int* socket_id, struct sockaddr_
// If the connection is a peer-to-peer connection between two
// federates, reject the connection with the WRONG_SERVER error.
send_reject(socket_id, WRONG_SERVER);
} else if (buffer[0] == MSG_TYPE_FED_NONCE) {
send_reject(socket_id, RTI_NOT_EXECUTED_WITH_AUTH);
lf_print_error("RTI not executed with HMAC authentication option using -a or --auth.");
} else {
send_reject(socket_id, UNEXPECTED_MESSAGE);
}
Expand Down
3 changes: 3 additions & 0 deletions core/federated/federate.c
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,9 @@ static int perform_hmac_authentication() {
if (received[0] == MSG_TYPE_FAILED) {
lf_print_error("RTI has failed.");
return -1;
} else if (received[0] == MSG_TYPE_REJECT && received[1] == RTI_NOT_EXECUTED_WITH_AUTH) {
lf_print_error("RTI is not executed with HMAC option.");
return -1;
} else {
lf_print_error("Received unexpected response %u from the RTI (see net_common.h).", received[0]);
return -1;
Expand Down
3 changes: 3 additions & 0 deletions include/core/federated/network/net_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -696,4 +696,7 @@ THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/** HMAC authentication failed. */
#define HMAC_DOES_NOT_MATCH 6

/** RTI not executed using -a or --auth option. */
#define RTI_NOT_EXECUTED_WITH_AUTH 7

#endif /* NET_COMMON_H */

0 comments on commit 4abce72

Please sign in to comment.