aboutsummaryrefslogtreecommitdiff
path: root/javascript/olm_outbound_group_session.js
diff options
context:
space:
mode:
authorHubert Chathi <hubert@uhoreg.ca>2018-10-16 17:50:34 -0400
committerHubert Chathi <hubert@uhoreg.ca>2018-10-16 17:50:34 -0400
commit93f764200ef47cf6ad683216c21d98b438897ead (patch)
treead69f3ece758a8012424967d1cff1f86bd2a5f28 /javascript/olm_outbound_group_session.js
parent09dc3b602599c1d7305adb183e4d402665d79a8f (diff)
zero buffers in the JavaScript bindings
Diffstat (limited to 'javascript/olm_outbound_group_session.js')
-rw-r--r--javascript/olm_outbound_group_session.js34
1 files changed, 26 insertions, 8 deletions
diff --git a/javascript/olm_outbound_group_session.js b/javascript/olm_outbound_group_session.js
index e232883..f1ccd3d 100644
--- a/javascript/olm_outbound_group_session.js
+++ b/javascript/olm_outbound_group_session.js
@@ -29,9 +29,17 @@ OutboundGroupSession.prototype['pickle'] = restore_stack(function(key) {
)(this.ptr);
var key_buffer = stack(key_array);
var pickle_buffer = stack(pickle_length + NULL_BYTE_PADDING_LENGTH);
- outbound_group_session_method(Module['_olm_pickle_outbound_group_session'])(
- this.ptr, key_buffer, key_array.length, pickle_buffer, pickle_length
- );
+ try {
+ outbound_group_session_method(Module['_olm_pickle_outbound_group_session'])(
+ this.ptr, key_buffer, key_array.length, pickle_buffer, pickle_length
+ );
+ } finally {
+ // clear out copies of the pickle key
+ bzero(key_buffer, key_array.length)
+ for (var i = 0; i < key_array.length; i++) {
+ key_array[i] = 0;
+ }
+ }
return Pointer_stringify(pickle_buffer);
});
@@ -40,10 +48,18 @@ OutboundGroupSession.prototype['unpickle'] = restore_stack(function(key, pickle)
var key_buffer = stack(key_array);
var pickle_array = array_from_string(pickle);
var pickle_buffer = stack(pickle_array);
- outbound_group_session_method(Module['_olm_unpickle_outbound_group_session'])(
- this.ptr, key_buffer, key_array.length, pickle_buffer,
- pickle_array.length
- );
+ try {
+ outbound_group_session_method(Module['_olm_unpickle_outbound_group_session'])(
+ this.ptr, key_buffer, key_array.length, pickle_buffer,
+ pickle_array.length
+ );
+ } finally {
+ // clear out copies of the pickle key
+ bzero(key_buffer, key_array.length)
+ for (var i = 0; i < key_array.length; i++) {
+ key_array[i] = 0;
+ }
+ }
});
OutboundGroupSession.prototype['create'] = restore_stack(function() {
@@ -116,7 +132,9 @@ OutboundGroupSession.prototype['session_key'] = restore_stack(function() {
outbound_group_session_method(Module['_olm_outbound_group_session_key'])(
this.ptr, key, key_length
);
- return Pointer_stringify(key);
+ var key_str = Pointer_stringify(key);
+ bzero(key, key_length); // clear out our copy of the key
+ return key_str;
});
OutboundGroupSession.prototype['message_index'] = function() {