Skip to content

Commit

Permalink
Implement REQUIRE_AUTHENTICATED policy #154
Browse files Browse the repository at this point in the history
  • Loading branch information
claucece committed Nov 29, 2020
1 parent a66ae67 commit e587600
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/fingerprint.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ API void otrng_fingerprint_forget(const otrng_client_s *client,
/* This returns the fingerprint of the peer, not the self.
It only works properly if it's a v4 connection. */
API /*@null@*/ otrng_known_fingerprint_s *
otrng_fingerprint_get_current(const otrng_s *conn) {
otrng_fingerprint_get_current_peer(const otrng_s *conn) {
otrng_fingerprint fp;
assert(conn != NULL);

Expand Down
2 changes: 1 addition & 1 deletion src/fingerprint.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ API void otrng_fingerprint_forget(const struct otrng_client_s *client,
*
*/
API /*@null@*/ otrng_known_fingerprint_s *
otrng_fingerprint_get_current(const struct otrng_s *conn);
otrng_fingerprint_get_current_peer(const struct otrng_s *conn);

#ifdef OTRNG_FINGERPRINT_PRIVATE
#endif
Expand Down
14 changes: 14 additions & 0 deletions src/otrng.c
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,13 @@ tstatic otrng_result receive_tagged_plaintext(otrng_response_s *response,

switch (otr->running_version) {
case OTRNG_PROTOCOL_VERSION_4:
if (otr->policy_type == OTRNG_REQUIRE_AUTHENTICATED) {
otrng_known_fingerprint_s *fp_peer;
fp_peer = otrng_fingerprint_get_current_peer(otr);
if (!fp_peer || fp_peer->trusted == otrng_false) {
return OTRNG_ERROR;
}
}
if (otr->policy_type & OTRNG_WHITESPACE_START_DAKE) {
if (message_to_display_without_tag(response, msg, strlen(msg)) ==
OTRNG_ERROR) {
Expand All @@ -531,6 +538,13 @@ tstatic otrng_result receive_query_message(otrng_response_s *response,

switch (otr->running_version) {
case OTRNG_PROTOCOL_VERSION_4:
if (otr->policy_type == OTRNG_REQUIRE_AUTHENTICATED) {
otrng_known_fingerprint_s *fp_peer;
fp_peer = otrng_fingerprint_get_current_peer(otr);
if (!fp_peer || fp_peer->trusted == otrng_false) {
return OTRNG_ERROR;
}
}
return start_dake(response, otr);
case OTRNG_PROTOCOL_VERSION_3:
return otrng_v3_receive_message(&response->to_send, &response->to_display,
Expand Down

0 comments on commit e587600

Please sign in to comment.