aboutsummaryrefslogtreecommitdiff
path: root/src/sas.c
diff options
context:
space:
mode:
authorHubert Chathi <hubert@uhoreg.ca>2019-04-08 15:08:17 -0400
committerGitHub <noreply@github.com>2019-04-08 15:08:17 -0400
commit2a6400716c1e17b65507cd2a433192f81cd402df (patch)
treeeb034ad74fab1e337b422d387e8e9a8b62bfb098 /src/sas.c
parentfcfa5f12a4cd482973fdf03000af4a26a360dc2e (diff)
parent709687a7b56d6768831766459940b6f0bb078d85 (diff)
Merge branch 'master' into poljar/python-sas
Diffstat (limited to 'src/sas.c')
-rw-r--r--src/sas.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/sas.c b/src/sas.c
index c5be73f..b5a3131 100644
--- a/src/sas.c
+++ b/src/sas.c
@@ -139,3 +139,26 @@ size_t olm_sas_calculate_mac(
_olm_encode_base64((const uint8_t *)mac, SHA256_OUTPUT_LENGTH, (uint8_t *)mac);
return 0;
}
+
+// 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 * info, size_t info_length,
+ void * mac, size_t mac_length
+) {
+ if (mac_length < olm_sas_mac_length(sas)) {
+ sas->last_error = OLM_OUTPUT_BUFFER_TOO_SMALL;
+ return (size_t)-1;
+ }
+ uint8_t key[256];
+ _olm_crypto_hkdf_sha256(
+ sas->secret, sizeof(sas->secret),
+ NULL, 0,
+ (const uint8_t *) info, info_length,
+ key, 256
+ );
+ _olm_crypto_hmac_sha256(key, 256, input, input_length, mac);
+ _olm_encode_base64((const uint8_t *)mac, SHA256_OUTPUT_LENGTH, (uint8_t *)mac);
+ return 0;
+}