aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorSaúl Ibarra Corretgé <s@saghul.net>2020-09-23 10:13:46 +0200
committerHubert Chathi <hubert@uhoreg.ca>2020-09-23 15:27:55 -0400
commit2ef1f6f4fc5bdc069483a527ab3a1b060c71fcad (patch)
tree40a3a0833442a59edc18378cc2aa0886eaa44b1a /include
parent4bae4134eb115859038de4e8eab11b22baf80b0c (diff)
SAS: add olm_sas_is_their_key_set
Also make olm_sas_generate_bytes fail if their key wasn't set.
Diffstat (limited to 'include')
-rw-r--r--include/olm/error.h8
-rw-r--r--include/olm/sas.h12
2 files changed, 16 insertions, 4 deletions
diff --git a/include/olm/error.h b/include/olm/error.h
index ee2187c..17e819d 100644
--- a/include/olm/error.h
+++ b/include/olm/error.h
@@ -53,10 +53,10 @@ enum OlmErrorCode {
OLM_INPUT_BUFFER_TOO_SMALL = 15,
- // Not an error code, just here to pad out the enum past 16 because
- // otherwise the compiler warns about a redunant check. If you're
- // adding an error code, replace this one!
- OLM_ERROR_NOT_INVENTED_YET = 16,
+ /**
+ * SAS doesn't have their key set.
+ */
+ OLM_SAS_THEIR_KEY_NOT_SET = 16,
/* remember to update the list of string constants in error.c when updating
* this list. */
diff --git a/include/olm/sas.h b/include/olm/sas.h
index ee44eff..4a5e751 100644
--- a/include/olm/sas.h
+++ b/include/olm/sas.h
@@ -105,6 +105,15 @@ size_t olm_sas_set_their_key(
void * their_key, size_t their_key_length
);
+/** Checks if their key was set.
+ *
+ * @param[in] sas the SAS object.
+ *
+ */
+int olm_sas_is_their_key_set(
+ OlmSAS *sas
+);
+
/** Generate bytes to use for the short authentication string.
*
* @param[in] sas the SAS object.
@@ -114,6 +123,9 @@ size_t olm_sas_set_their_key(
* @param[out] output the output buffer.
* @param[in] output_length the size of the output buffer. For hex-based SAS
* as in the Matrix spec, this will be 5.
+ *
+ * @return `olm_error()` on failure. If their key wasn't set then
+ * `olm_sas_last_error()` will be `SAS_THEIR_KEY_NOT_SET`.
*/
size_t olm_sas_generate_bytes(
OlmSAS * sas,