From 0757e6df409c3a625dd4d1c186d4a990ec1ca172 Mon Sep 17 00:00:00 2001
From: Hubert Chathi <hubert@uhoreg.ca>
Date: Tue, 14 May 2019 12:53:19 -0400
Subject: [PATCH] add comment about input buffers being overwritten

also make some params const where possible
---
 include/olm/sas.h | 10 ++++++----
 src/sas.c         |  4 ++--
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/include/olm/sas.h b/include/olm/sas.h
index 9d2ae3e..ee44eff 100644
--- a/include/olm/sas.h
+++ b/include/olm/sas.h
@@ -59,7 +59,8 @@ size_t olm_create_sas_random_length(
 /** Creates a new SAS object.
  *
  * @param[in] sas the SAS object to create, initialized by `olm_sas()`.
- * @param[in] random array of random bytes.
+ * @param[in] random array of random bytes.  The contents of the buffer may be
+ *     overwritten.
  * @param[in] random_length the number of random bytes provided.  Must be at
  *    least `olm_create_sas_random_length()`.
  *
@@ -92,7 +93,8 @@ size_t olm_sas_get_pubkey(
 /** Sets the public key of other user.
  *
  * @param[in] sas the SAS object.
- * @param[in] their_key the other user's public key.
+ * @param[in] their_key the other user's public key.  The contents of the
+ *     buffer will be overwritten.
  * @param[in] their_key_length the size of the `their_key` buffer.
  *
  * @return `olm_error()` on failure.  If the `their_key` buffer is too small,
@@ -142,7 +144,7 @@ size_t olm_sas_mac_length(
  */
 size_t olm_sas_calculate_mac(
     OlmSAS * sas,
-    void * input, size_t input_length,
+    const void * input, size_t input_length,
     const void * info, size_t info_length,
     void * mac, size_t mac_length
 );
@@ -150,7 +152,7 @@ size_t olm_sas_calculate_mac(
 // for compatibility with an old version of Riot
 size_t olm_sas_calculate_mac_long_kdf(
     OlmSAS * sas,
-    void * input, size_t input_length,
+    const void * input, size_t input_length,
     const void * info, size_t info_length,
     void * mac, size_t mac_length
 );
diff --git a/src/sas.c b/src/sas.c
index b5a3131..76e4576 100644
--- a/src/sas.c
+++ b/src/sas.c
@@ -120,7 +120,7 @@ size_t olm_sas_mac_length(
 
 size_t olm_sas_calculate_mac(
     OlmSAS * sas,
-    void * input, size_t input_length,
+    const void * input, size_t input_length,
     const void * info, size_t info_length,
     void * mac, size_t mac_length
 ) {
@@ -143,7 +143,7 @@ size_t olm_sas_calculate_mac(
 // for compatibility with an old version of Riot
 size_t olm_sas_calculate_mac_long_kdf(
     OlmSAS * sas,
-    void * input, size_t input_length,
+    const void * input, size_t input_length,
     const void * info, size_t info_length,
     void * mac, size_t mac_length
 ) {
-- 
GitLab