X-Git-Url: https://www.tinc-vpn.org/git/browse?p=tinc;a=blobdiff_plain;f=src%2Fprotocol_auth.c;h=87ba30a3e919e5fb1660994bb6b39f0368614bd0;hp=385e54366dbd1bb4bad446446df0687503baf576;hb=6685f2c8afc4775c3656dccc5a37286c01c0e854;hpb=8794274a30d535d49636fec825a0afbf30d8010d diff --git a/src/protocol_auth.c b/src/protocol_auth.c index 385e5436..87ba30a3 100644 --- a/src/protocol_auth.c +++ b/src/protocol_auth.c @@ -215,7 +215,12 @@ bool send_metakey(connection_t *c) { /* Copy random data to the buffer */ - RAND_bytes((unsigned char *)c->outkey, len); + if (1 != RAND_bytes((unsigned char *)c->outkey, len)) { + int err = ERR_get_error(); + logger(LOG_ERR, "Failed to generate meta key (%s)", "SEND_METAKEY", ERR_error_string(err, NULL)); + return false; + } + /* The message we send must be smaller than the modulus of the RSA key. By definition, for a key of k bits, the following formula holds: @@ -391,7 +396,11 @@ bool send_challenge(connection_t *c) { /* Copy random data to the buffer */ - RAND_bytes((unsigned char *)c->hischallenge, len); + if (1 != RAND_bytes((unsigned char *)c->hischallenge, len)) { + int err = ERR_get_error(); + logger(LOG_ERR, "Failed to generate challenge (%s)", "SEND_CHALLENGE", ERR_error_string(err, NULL)); + return false; // Do not send predictable challenges, let connection attempt fail. + } /* Convert to hex */