clear out random arrays

This commit is contained in:
Hubert Chathi 2021-12-10 16:15:22 -05:00
parent c23ce70fc6
commit 8519ce0269
2 changed files with 32 additions and 12 deletions

View file

@ -67,9 +67,14 @@ OutboundGroupSession.prototype['create'] = restore_stack(function() {
Module['_olm_init_outbound_group_session_random_length']
)(this.ptr);
var random = random_stack(random_length);
outbound_group_session_method(Module['_olm_init_outbound_group_session'])(
this.ptr, random, random_length
);
try {
outbound_group_session_method(Module['_olm_init_outbound_group_session'])(
this.ptr, random, random_length
);
} finally {
// clear the random buffer
bzero(random, random_length);
}
});
OutboundGroupSession.prototype['encrypt'] = function(plaintext) {

View file

@ -73,9 +73,14 @@ Account.prototype['create'] = restore_stack(function() {
Module['_olm_create_account_random_length']
)(this.ptr);
var random = random_stack(random_length);
account_method(Module['_olm_create_account'])(
this.ptr, random, random_length
);
try {
account_method(Module['_olm_create_account'])(
this.ptr, random, random_length
);
} finally {
// clear the random buffer
bzero(random, random_length);
}
});
Account.prototype['identity_keys'] = restore_stack(function() {
@ -140,9 +145,14 @@ Account.prototype['generate_one_time_keys'] = restore_stack(function(
Module['_olm_account_generate_one_time_keys_random_length']
)(this.ptr, number_of_keys);
var random = random_stack(random_length);
account_method(Module['_olm_account_generate_one_time_keys'])(
this.ptr, number_of_keys, random, random_length
);
try {
account_method(Module['_olm_account_generate_one_time_keys'])(
this.ptr, number_of_keys, random, random_length
);
} finally {
// clear the random buffer
bzero(random, random_length);
}
});
Account.prototype['remove_one_time_keys'] = restore_stack(function(session) {
@ -156,9 +166,14 @@ Account.prototype['generate_fallback_key'] = restore_stack(function() {
Module['_olm_account_generate_fallback_key_random_length']
)(this.ptr);
var random = random_stack(random_length);
account_method(Module['_olm_account_generate_fallback_key'])(
this.ptr, random, random_length
);
try {
account_method(Module['_olm_account_generate_fallback_key'])(
this.ptr, random, random_length
);
} finally {
// clear the random buffer
bzero(random, random_length);
}
});
Account.prototype['fallback_key'] = restore_stack(function() {