Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
matrix-org
Olm
Commits
3148157e
Commit
3148157e
authored
Apr 02, 2019
by
Hubert Chathi
Browse files
add support for an incorrect KDF that snuck into Riot 1.0
parent
d5c0eb9d
Changes
3
Hide whitespace changes
Inline
Side-by-side
include/olm/sas.h
View file @
3148157e
...
...
@@ -147,6 +147,14 @@ size_t olm_sas_calculate_mac(
void
*
mac
,
size_t
mac_length
);
// 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
);
/** @} */
// end of SAS group
#ifdef __cplusplus
...
...
javascript/olm_sas.js
View file @
3148157e
...
...
@@ -75,3 +75,19 @@ SAS.prototype['calculate_mac'] = restore_stack(function(input, info) {
);
return
Pointer_stringify
(
mac_buffer
);
});
SAS
.
prototype
[
'
calculate_mac_long_kdf
'
]
=
restore_stack
(
function
(
input
,
info
)
{
var
input_array
=
array_from_string
(
input
);
var
input_buffer
=
stack
(
input_array
);
var
info_array
=
array_from_string
(
info
);
var
info_buffer
=
stack
(
info_array
);
var
mac_length
=
sas_method
(
Module
[
'
_olm_sas_mac_length
'
])(
this
.
ptr
);
var
mac_buffer
=
stack
(
mac_length
+
NULL_BYTE_PADDING_LENGTH
);
sas_method
(
Module
[
'
_olm_sas_calculate_mac_long_kdf
'
])(
this
.
ptr
,
input_buffer
,
input_array
.
length
,
info_buffer
,
info_array
.
length
,
mac_buffer
,
mac_length
);
return
Pointer_stringify
(
mac_buffer
);
});
src/sas.c
View file @
3148157e
...
...
@@ -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
;
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment