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
fee1748c
Commit
fee1748c
authored
8 years ago
by
Richard van der Hoff
Committed by
GitHub
8 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #16 from matrix-org/rav/fix_megolm_utf8
Fix megolm decryption of UTF-8
parents
9d16d820
1d4c13c7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
javascript/olm_inbound_group_session.js
+18
-4
18 additions, 4 deletions
javascript/olm_inbound_group_session.js
javascript/olm_outbound_group_session.js
+14
-8
14 additions, 8 deletions
javascript/olm_outbound_group_session.js
javascript/olm_post.js
+1
-1
1 addition, 1 deletion
javascript/olm_post.js
with
33 additions
and
13 deletions
javascript/olm_inbound_group_session.js
+
18
−
4
View file @
fee1748c
/* The 'length' argument to Pointer_stringify doesn't work if the input includes
* characters >= 128; we therefore need to add a NULL character to all of our
* strings. This acts as a symbolic constant to help show what we're doing.
*/
var
NULL_BYTE_PADDING_LENGTH
=
1
;
function
InboundGroupSession
()
{
function
InboundGroupSession
()
{
var
size
=
Module
[
'
_olm_inbound_group_session_size
'
]();
var
size
=
Module
[
'
_olm_inbound_group_session_size
'
]();
this
.
buf
=
malloc
(
size
);
this
.
buf
=
malloc
(
size
);
...
@@ -28,11 +34,11 @@ InboundGroupSession.prototype['pickle'] = restore_stack(function(key) {
...
@@ -28,11 +34,11 @@ InboundGroupSession.prototype['pickle'] = restore_stack(function(key) {
Module
[
'
_olm_pickle_inbound_group_session_length
'
]
Module
[
'
_olm_pickle_inbound_group_session_length
'
]
)(
this
.
ptr
);
)(
this
.
ptr
);
var
key_buffer
=
stack
(
key_array
);
var
key_buffer
=
stack
(
key_array
);
var
pickle_buffer
=
stack
(
pickle_length
);
var
pickle_buffer
=
stack
(
pickle_length
+
NULL_BYTE_PADDING_LENGTH
);
inbound_group_session_method
(
Module
[
'
_olm_pickle_inbound_group_session
'
])(
inbound_group_session_method
(
Module
[
'
_olm_pickle_inbound_group_session
'
])(
this
.
ptr
,
key_buffer
,
key_array
.
length
,
pickle_buffer
,
pickle_length
this
.
ptr
,
key_buffer
,
key_array
.
length
,
pickle_buffer
,
pickle_length
);
);
return
Pointer_stringify
(
pickle_buffer
,
pickle_length
);
return
Pointer_stringify
(
pickle_buffer
);
});
});
InboundGroupSession
.
prototype
[
'
unpickle
'
]
=
restore_stack
(
function
(
key
,
pickle
)
{
InboundGroupSession
.
prototype
[
'
unpickle
'
]
=
restore_stack
(
function
(
key
,
pickle
)
{
...
@@ -66,13 +72,21 @@ InboundGroupSession.prototype['decrypt'] = restore_stack(function(
...
@@ -66,13 +72,21 @@ InboundGroupSession.prototype['decrypt'] = restore_stack(function(
// caculating the length destroys the input buffer.
// caculating the length destroys the input buffer.
// So we copy the array to a new buffer
// So we copy the array to a new buffer
var
message_buffer
=
stack
(
message_array
);
var
message_buffer
=
stack
(
message_array
);
var
plaintext_buffer
=
stack
(
max_plaintext_length
);
var
plaintext_buffer
=
stack
(
max_plaintext_length
+
NULL_BYTE_PADDING_LENGTH
);
var
plaintext_length
=
session_method
(
Module
[
"
_olm_group_decrypt
"
])(
var
plaintext_length
=
session_method
(
Module
[
"
_olm_group_decrypt
"
])(
this
.
ptr
,
this
.
ptr
,
message_buffer
,
message_array
.
length
,
message_buffer
,
message_array
.
length
,
plaintext_buffer
,
max_plaintext_length
plaintext_buffer
,
max_plaintext_length
);
);
return
Pointer_stringify
(
plaintext_buffer
,
plaintext_length
);
// Pointer_stringify requires a null-terminated argument (the optional
// 'len' argument doesn't work for UTF-8 data).
Module
[
'
setValue
'
](
plaintext_buffer
+
plaintext_length
,
0
,
"
i8
"
);
return
Pointer_stringify
(
plaintext_buffer
);
});
});
olm_exports
[
'
InboundGroupSession
'
]
=
InboundGroupSession
;
olm_exports
[
'
InboundGroupSession
'
]
=
InboundGroupSession
;
This diff is collapsed.
Click to expand it.
javascript/olm_outbound_group_session.js
+
14
−
8
View file @
fee1748c
/* The 'length' argument to Pointer_stringify doesn't work if the input includes
* characters >= 128; we therefore need to add a NULL character to all of our
* strings. This acts as a symbolic constant to help show what we're doing.
*/
var
NULL_BYTE_PADDING_LENGTH
=
1
;
function
OutboundGroupSession
()
{
function
OutboundGroupSession
()
{
var
size
=
Module
[
'
_olm_outbound_group_session_size
'
]();
var
size
=
Module
[
'
_olm_outbound_group_session_size
'
]();
...
@@ -29,11 +35,11 @@ OutboundGroupSession.prototype['pickle'] = restore_stack(function(key) {
...
@@ -29,11 +35,11 @@ OutboundGroupSession.prototype['pickle'] = restore_stack(function(key) {
Module
[
'
_olm_pickle_outbound_group_session_length
'
]
Module
[
'
_olm_pickle_outbound_group_session_length
'
]
)(
this
.
ptr
);
)(
this
.
ptr
);
var
key_buffer
=
stack
(
key_array
);
var
key_buffer
=
stack
(
key_array
);
var
pickle_buffer
=
stack
(
pickle_length
);
var
pickle_buffer
=
stack
(
pickle_length
+
NULL_BYTE_PADDING_LENGTH
);
outbound_group_session_method
(
Module
[
'
_olm_pickle_outbound_group_session
'
])(
outbound_group_session_method
(
Module
[
'
_olm_pickle_outbound_group_session
'
])(
this
.
ptr
,
key_buffer
,
key_array
.
length
,
pickle_buffer
,
pickle_length
this
.
ptr
,
key_buffer
,
key_array
.
length
,
pickle_buffer
,
pickle_length
);
);
return
Pointer_stringify
(
pickle_buffer
,
pickle_length
);
return
Pointer_stringify
(
pickle_buffer
);
});
});
OutboundGroupSession
.
prototype
[
'
unpickle
'
]
=
restore_stack
(
function
(
key
,
pickle
)
{
OutboundGroupSession
.
prototype
[
'
unpickle
'
]
=
restore_stack
(
function
(
key
,
pickle
)
{
...
@@ -63,35 +69,35 @@ OutboundGroupSession.prototype['encrypt'] = restore_stack(function(plaintext) {
...
@@ -63,35 +69,35 @@ OutboundGroupSession.prototype['encrypt'] = restore_stack(function(plaintext) {
Module
[
'
_olm_group_encrypt_message_length
'
]
Module
[
'
_olm_group_encrypt_message_length
'
]
)(
this
.
ptr
,
plaintext_array
.
length
);
)(
this
.
ptr
,
plaintext_array
.
length
);
var
plaintext_buffer
=
stack
(
plaintext_array
);
var
plaintext_buffer
=
stack
(
plaintext_array
);
var
message_buffer
=
stack
(
message_length
);
var
message_buffer
=
stack
(
message_length
+
NULL_BYTE_PADDING_LENGTH
);
outbound_group_session_method
(
Module
[
'
_olm_group_encrypt
'
])(
outbound_group_session_method
(
Module
[
'
_olm_group_encrypt
'
])(
this
.
ptr
,
this
.
ptr
,
plaintext_buffer
,
plaintext_array
.
length
,
plaintext_buffer
,
plaintext_array
.
length
,
message_buffer
,
message_length
message_buffer
,
message_length
);
);
return
Pointer_stringify
(
message_buffer
,
message_length
);
return
Pointer_stringify
(
message_buffer
);
});
});
OutboundGroupSession
.
prototype
[
'
session_id
'
]
=
restore_stack
(
function
(
key
)
{
OutboundGroupSession
.
prototype
[
'
session_id
'
]
=
restore_stack
(
function
(
key
)
{
var
length
=
outbound_group_session_method
(
var
length
=
outbound_group_session_method
(
Module
[
'
_olm_outbound_group_session_id_length
'
]
Module
[
'
_olm_outbound_group_session_id_length
'
]
)(
this
.
ptr
);
)(
this
.
ptr
);
var
session_id
=
stack
(
length
);
var
session_id
=
stack
(
length
+
NULL_BYTE_PADDING_LENGTH
);
outbound_group_session_method
(
Module
[
'
_olm_outbound_group_session_id
'
])(
outbound_group_session_method
(
Module
[
'
_olm_outbound_group_session_id
'
])(
this
.
ptr
,
session_id
,
length
this
.
ptr
,
session_id
,
length
);
);
return
Pointer_stringify
(
session_id
,
length
);
return
Pointer_stringify
(
session_id
);
});
});
OutboundGroupSession
.
prototype
[
'
session_key
'
]
=
restore_stack
(
function
(
key
)
{
OutboundGroupSession
.
prototype
[
'
session_key
'
]
=
restore_stack
(
function
(
key
)
{
var
key_length
=
outbound_group_session_method
(
var
key_length
=
outbound_group_session_method
(
Module
[
'
_olm_outbound_group_session_key_length
'
]
Module
[
'
_olm_outbound_group_session_key_length
'
]
)(
this
.
ptr
);
)(
this
.
ptr
);
var
key
=
stack
(
key_length
);
var
key
=
stack
(
key_length
+
NULL_BYTE_PADDING_LENGTH
);
outbound_group_session_method
(
Module
[
'
_olm_outbound_group_session_key
'
])(
outbound_group_session_method
(
Module
[
'
_olm_outbound_group_session_key
'
])(
this
.
ptr
,
key
,
key_length
this
.
ptr
,
key
,
key_length
);
);
return
Pointer_stringify
(
key
,
key_length
);
return
Pointer_stringify
(
key
);
});
});
OutboundGroupSession
.
prototype
[
'
message_index
'
]
=
function
()
{
OutboundGroupSession
.
prototype
[
'
message_index
'
]
=
function
()
{
...
...
This diff is collapsed.
Click to expand it.
javascript/olm_post.js
+
1
−
1
View file @
fee1748c
...
@@ -5,7 +5,7 @@ var Pointer_stringify = Module['Pointer_stringify'];
...
@@ -5,7 +5,7 @@ var Pointer_stringify = Module['Pointer_stringify'];
var
OLM_ERROR
=
Module
[
'
_olm_error
'
]();
var
OLM_ERROR
=
Module
[
'
_olm_error
'
]();
/* The 'length' argument to Pointer_stringify doesn't work if the input includes
/* The 'length' argument to Pointer_stringify doesn't work if the input includes
* c
a
hracters >= 128; we therefore need to add a NULL character to all of our
* ch
a
racters >= 128; we therefore need to add a NULL character to all of our
* strings. This acts as a symbolic constant to help show what we're doing.
* strings. This acts as a symbolic constant to help show what we're doing.
*/
*/
var
NULL_BYTE_PADDING_LENGTH
=
1
;
var
NULL_BYTE_PADDING_LENGTH
=
1
;
...
...
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