Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
Olm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nheko Reborn
Olm
Commits
a07e27cf
Commit
a07e27cf
authored
Feb 19, 2021
by
Hubert Chathi
Browse files
Options
Downloads
Plain Diff
Merge branch 'sas-base64-fix' into 'master'
sas: Fix the base64 encoding of the MAC. See merge request matrix-org/olm!16
parents
23e04860
f46577a0
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/sas.c
+32
-0
32 additions, 0 deletions
src/sas.c
with
32 additions
and
0 deletions
src/sas.c
+
32
−
0
View file @
a07e27cf
...
...
@@ -131,6 +131,38 @@ size_t olm_sas_mac_length(
return
_olm_encode_base64_length
(
SHA256_OUTPUT_LENGTH
);
}
// A version of the calculate mac function that produces base64 strings that are
// compatible with other base64 implementations.
size_t
olm_sas_calculate_mac_fixed_base64
(
OlmSAS
*
sas
,
const
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
;
}
if
(
!
sas
->
their_key_set
)
{
sas
->
last_error
=
OLM_SAS_THEIR_KEY_NOT_SET
;
return
(
size_t
)
-
1
;
}
uint8_t
key
[
32
];
_olm_crypto_hkdf_sha256
(
sas
->
secret
,
sizeof
(
sas
->
secret
),
NULL
,
0
,
(
const
uint8_t
*
)
info
,
info_length
,
key
,
32
);
uint8_t
temp_mac
[
32
];
_olm_crypto_hmac_sha256
(
key
,
32
,
input
,
input_length
,
temp_mac
);
_olm_encode_base64
((
const
uint8_t
*
)
temp_mac
,
SHA256_OUTPUT_LENGTH
,
(
uint8_t
*
)
mac
);
return
0
;
}
size_t
olm_sas_calculate_mac
(
OlmSAS
*
sas
,
const
void
*
input
,
size_t
input_length
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment