diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/error.c | 1 | ||||
-rw-r--r-- | src/sas.c | 12 |
2 files changed, 13 insertions, 0 deletions
diff --git a/src/error.c b/src/error.c index 5147b5c..7d39637 100644 --- a/src/error.c +++ b/src/error.c @@ -32,6 +32,7 @@ static const char * ERRORS[] = { "BAD_LEGACY_ACCOUNT_PICKLE", "BAD_SIGNATURE", "OLM_INPUT_BUFFER_TOO_SMALL", + "OLM_SAS_THEIR_KEY_NOT_SET" }; const char * _olm_error_to_string(enum OlmErrorCode error) @@ -23,6 +23,7 @@ struct OlmSAS { enum OlmErrorCode last_error; struct _olm_curve25519_key_pair curve25519_key; uint8_t secret[CURVE25519_SHARED_SECRET_LENGTH]; + int their_key_set; }; const char * olm_sas_last_error( @@ -95,14 +96,25 @@ size_t olm_sas_set_their_key( } _olm_decode_base64(their_key, their_key_length, their_key); _olm_crypto_curve25519_shared_secret(&sas->curve25519_key, their_key, sas->secret); + sas->their_key_set = 1; return 0; } +int olm_sas_is_their_key_set( + OlmSAS *sas +) { + return sas->their_key_set; +} + size_t olm_sas_generate_bytes( OlmSAS * sas, const void * info, size_t info_length, void * output, size_t output_length ) { + if (!sas->their_key_set) { + sas->last_error = OLM_SAS_THEIR_KEY_NOT_SET; + return (size_t)-1; + } _olm_crypto_hkdf_sha256( sas->secret, sizeof(sas->secret), NULL, 0, |