olm_sas_set_their_key: Fail early on invalid base64.

This commit is contained in:
Denis Kasak 2021-05-17 16:55:30 +02:00
parent e82f2601b0
commit 2f35e0bc61

View file

@ -95,7 +95,13 @@ size_t olm_sas_set_their_key(
sas->last_error = OLM_INPUT_BUFFER_TOO_SMALL; sas->last_error = OLM_INPUT_BUFFER_TOO_SMALL;
return (size_t)-1; return (size_t)-1;
} }
_olm_decode_base64(their_key, their_key_length, their_key);
size_t ret = _olm_decode_base64(their_key, their_key_length, their_key);
if (ret == (size_t)-1) {
sas->last_error = OLM_INVALID_BASE64;
return (size_t)-1;
}
_olm_crypto_curve25519_shared_secret(&sas->curve25519_key, their_key, sas->secret); _olm_crypto_curve25519_shared_secret(&sas->curve25519_key, their_key, sas->secret);
sas->their_key_set = 1; sas->their_key_set = 1;
return 0; return 0;