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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nheko Reborn
Olm
Commits
d8136096
Commit
d8136096
authored
8 years ago
by
Richard van der Hoff
Committed by
GitHub
8 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #33 from matrix-org/rav/pickle_length
Return the base64-encoded length of pickles
parents
8de0f1fb
a7310c58
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/pickle_encoding.c
+1
-1
1 addition, 1 deletion
src/pickle_encoding.c
tests/test_group_session.cpp
+23
-18
23 additions, 18 deletions
tests/test_group_session.cpp
tests/test_olm.cpp
+10
-6
10 additions, 6 deletions
tests/test_olm.cpp
with
34 additions
and
25 deletions
src/pickle_encoding.c
+
1
−
1
View file @
d8136096
...
...
@@ -60,7 +60,7 @@ size_t _olm_enc_output(
raw_output
,
length
);
_olm_encode_base64
(
raw_output
,
length
,
output
);
return
raw
_length
;
return
base64
_length
;
}
...
...
This diff is collapsed.
Click to expand it.
tests/test_group_session.cpp
+
23
−
18
View file @
d8136096
...
...
@@ -28,23 +28,26 @@ int main() {
size_t
pickle_length
=
olm_pickle_outbound_group_session_length
(
session
);
uint8_t
pickle1
[
pickle_length
];
olm_pickle_outbound_group_session
(
session
,
"secret_key"
,
10
,
pickle1
,
pickle_length
);
size_t
res
=
olm_pickle_outbound_group_session
(
session
,
"secret_key"
,
10
,
pickle1
,
pickle_length
);
assert_equals
(
pickle_length
,
res
);
uint8_t
pickle2
[
pickle_length
];
memcpy
(
pickle2
,
pickle1
,
pickle_length
);
uint8_t
buffer2
[
size
];
OlmOutboundGroupSession
*
session2
=
olm_outbound_group_session
(
buffer2
);
size_t
res
=
olm_unpickle_outbound_group_session
(
session2
,
"secret_key"
,
10
,
pickle2
,
pickle_length
);
res
=
olm_unpickle_outbound_group_session
(
session2
,
"secret_key"
,
10
,
pickle2
,
pickle_length
);
assert_not_equals
((
size_t
)
-
1
,
res
);
assert_equals
(
pickle_length
,
olm_pickle_outbound_group_session_length
(
session2
));
olm_pickle_outbound_group_session
(
session2
,
"secret_key"
,
10
,
pickle2
,
pickle_length
);
res
=
olm_pickle_outbound_group_session
(
session2
,
"secret_key"
,
10
,
pickle2
,
pickle_length
);
assert_equals
(
pickle_length
,
res
);
assert_equals
(
pickle1
,
pickle2
,
pickle_length
);
}
...
...
@@ -59,23 +62,25 @@ int main() {
size_t
pickle_length
=
olm_pickle_inbound_group_session_length
(
session
);
uint8_t
pickle1
[
pickle_length
];
olm_pickle_inbound_group_session
(
session
,
"secret_key"
,
10
,
pickle1
,
pickle_length
);
size_t
res
=
olm_pickle_inbound_group_session
(
session
,
"secret_key"
,
10
,
pickle1
,
pickle_length
);
assert_equals
(
pickle_length
,
res
);
uint8_t
pickle2
[
pickle_length
];
memcpy
(
pickle2
,
pickle1
,
pickle_length
);
uint8_t
buffer2
[
size
];
OlmInboundGroupSession
*
session2
=
olm_inbound_group_session
(
buffer2
);
size_t
res
=
olm_unpickle_inbound_group_session
(
session2
,
"secret_key"
,
10
,
pickle2
,
pickle_length
);
res
=
olm_unpickle_inbound_group_session
(
session2
,
"secret_key"
,
10
,
pickle2
,
pickle_length
);
assert_not_equals
((
size_t
)
-
1
,
res
);
assert_equals
(
pickle_length
,
olm_pickle_inbound_group_session_length
(
session2
));
olm_pickle_inbound_group_session
(
session2
,
"secret_key"
,
10
,
pickle2
,
pickle_length
);
res
=
olm_pickle_inbound_group_session
(
session2
,
"secret_key"
,
10
,
pickle2
,
pickle_length
);
assert_equals
(
pickle1
,
pickle2
,
pickle_length
);
}
...
...
This diff is collapsed.
Click to expand it.
tests/test_olm.cpp
+
10
−
6
View file @
d8136096
...
...
@@ -49,7 +49,9 @@ mock_random(ot_random, sizeof(ot_random));
std
::
size_t
pickle_length
=
::
olm_pickle_account_length
(
account
);
std
::
uint8_t
pickle1
[
pickle_length
];
::
olm_pickle_account
(
account
,
"secret_key"
,
10
,
pickle1
,
pickle_length
);
std
::
size_t
res
=
::
olm_pickle_account
(
account
,
"secret_key"
,
10
,
pickle1
,
pickle_length
);
assert_equals
(
pickle_length
,
res
);
std
::
uint8_t
pickle2
[
pickle_length
];
std
::
memcpy
(
pickle2
,
pickle1
,
pickle_length
);
...
...
@@ -59,10 +61,10 @@ assert_not_equals(std::size_t(-1), ::olm_unpickle_account(
account2
,
"secret_key"
,
10
,
pickle2
,
pickle_length
));
assert_equals
(
pickle_length
,
::
olm_pickle_account_length
(
account2
));
::
olm_pickle_account
(
account2
,
"secret_key"
,
10
,
pickle2
,
pickle_length
);
res
=
::
olm_pickle_account
(
account2
,
"secret_key"
,
10
,
pickle2
,
pickle_length
);
assert_equals
(
pickle_length
,
res
);
assert_equals
(
pickle1
,
pickle2
,
pickle_length
);
}
...
...
@@ -122,7 +124,9 @@ mock_random(random2, sizeof(random2));
std
::
size_t
pickle_length
=
::
olm_pickle_session_length
(
session
);
std
::
uint8_t
pickle1
[
pickle_length
];
::
olm_pickle_session
(
session
,
"secret_key"
,
10
,
pickle1
,
pickle_length
);
std
::
size_t
res
=
::
olm_pickle_session
(
session
,
"secret_key"
,
10
,
pickle1
,
pickle_length
);
assert_equals
(
pickle_length
,
res
);
std
::
uint8_t
pickle2
[
pickle_length
];
std
::
memcpy
(
pickle2
,
pickle1
,
pickle_length
);
...
...
@@ -132,10 +136,10 @@ assert_not_equals(std::size_t(-1), ::olm_unpickle_session(
session2
,
"secret_key"
,
10
,
pickle2
,
pickle_length
));
assert_equals
(
pickle_length
,
::
olm_pickle_session_length
(
session2
));
::
olm_pickle_session
(
session2
,
"secret_key"
,
10
,
pickle2
,
pickle_length
);
res
=
::
olm_pickle_session
(
session2
,
"secret_key"
,
10
,
pickle2
,
pickle_length
);
assert_equals
(
pickle_length
,
res
);
assert_equals
(
pickle1
,
pickle2
,
pickle_length
);
}
{
/** Loopback test */
...
...
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
register
or
sign in
to comment