aboutsummaryrefslogtreecommitdiff
path: root/javascript
diff options
context:
space:
mode:
Diffstat (limited to 'javascript')
-rw-r--r--javascript/olm_inbound_group_session.js12
-rw-r--r--javascript/olm_outbound_group_session.js10
-rw-r--r--javascript/olm_pk.js26
-rw-r--r--javascript/olm_post.js26
-rw-r--r--javascript/olm_sas.js8
5 files changed, 41 insertions, 41 deletions
diff --git a/javascript/olm_inbound_group_session.js b/javascript/olm_inbound_group_session.js
index dd8e493..423d2b1 100644
--- a/javascript/olm_inbound_group_session.js
+++ b/javascript/olm_inbound_group_session.js
@@ -8,7 +8,7 @@ function inbound_group_session_method(wrapped) {
return function() {
var result = wrapped.apply(this, arguments);
if (result === OLM_ERROR) {
- var message = Pointer_stringify(
+ var message = UTF8ToString(
Module['_olm_inbound_group_session_last_error'](arguments[0])
);
throw new Error("OLM." + message);
@@ -40,7 +40,7 @@ InboundGroupSession.prototype['pickle'] = restore_stack(function(key) {
key_array[i] = 0;
}
}
- return Pointer_stringify(pickle_buffer);
+ return UTF8ToString(pickle_buffer, pickle_length);
});
InboundGroupSession.prototype['unpickle'] = restore_stack(function(key, pickle) {
@@ -132,7 +132,7 @@ InboundGroupSession.prototype['decrypt'] = restore_stack(function(
);
return {
- "plaintext": UTF8ToString(plaintext_buffer),
+ "plaintext": UTF8ToString(plaintext_buffer, plaintext_length),
"message_index": getValue(message_index, "i32")
}
} finally {
@@ -141,7 +141,7 @@ InboundGroupSession.prototype['decrypt'] = restore_stack(function(
}
if (plaintext_buffer !== undefined) {
// don't leave a copy of the plaintext in the heap.
- bzero(plaintext_buffer, plaintext_length + NULL_BYTE_PADDING_LENGTH);
+ bzero(plaintext_buffer, plaintext_length);
free(plaintext_buffer);
}
}
@@ -155,7 +155,7 @@ InboundGroupSession.prototype['session_id'] = restore_stack(function() {
inbound_group_session_method(Module['_olm_inbound_group_session_id'])(
this.ptr, session_id, length
);
- return Pointer_stringify(session_id);
+ return UTF8ToString(session_id, length);
});
InboundGroupSession.prototype['first_known_index'] = restore_stack(function() {
@@ -172,7 +172,7 @@ InboundGroupSession.prototype['export_session'] = restore_stack(function(message
outbound_group_session_method(Module['_olm_export_inbound_group_session'])(
this.ptr, key, key_length, message_index
);
- var key_str = Pointer_stringify(key);
+ var key_str = UTF8ToString(key, key_length);
bzero(key, key_length); // clear out a copy of the key
return key_str;
});
diff --git a/javascript/olm_outbound_group_session.js b/javascript/olm_outbound_group_session.js
index f1ccd3d..e4852c1 100644
--- a/javascript/olm_outbound_group_session.js
+++ b/javascript/olm_outbound_group_session.js
@@ -8,7 +8,7 @@ function outbound_group_session_method(wrapped) {
return function() {
var result = wrapped.apply(this, arguments);
if (result === OLM_ERROR) {
- var message = Pointer_stringify(
+ var message = UTF8ToString(
Module['_olm_outbound_group_session_last_error'](arguments[0])
);
throw new Error("OLM." + message);
@@ -40,7 +40,7 @@ OutboundGroupSession.prototype['pickle'] = restore_stack(function(key) {
key_array[i] = 0;
}
}
- return Pointer_stringify(pickle_buffer);
+ return UTF8ToString(pickle_buffer, pickle_length);
});
OutboundGroupSession.prototype['unpickle'] = restore_stack(function(key, pickle) {
@@ -100,7 +100,7 @@ OutboundGroupSession.prototype['encrypt'] = function(plaintext) {
0, "i8"
);
- return UTF8ToString(message_buffer);
+ return UTF8ToString(message_buffer, message_length);
} finally {
if (plaintext_buffer !== undefined) {
// don't leave a copy of the plaintext in the heap.
@@ -121,7 +121,7 @@ OutboundGroupSession.prototype['session_id'] = restore_stack(function() {
outbound_group_session_method(Module['_olm_outbound_group_session_id'])(
this.ptr, session_id, length
);
- return Pointer_stringify(session_id);
+ return UTF8ToString(session_id, length);
});
OutboundGroupSession.prototype['session_key'] = restore_stack(function() {
@@ -132,7 +132,7 @@ OutboundGroupSession.prototype['session_key'] = restore_stack(function() {
outbound_group_session_method(Module['_olm_outbound_group_session_key'])(
this.ptr, key, key_length
);
- var key_str = Pointer_stringify(key);
+ var key_str = UTF8ToString(key, key_length);
bzero(key, key_length); // clear out our copy of the key
return key_str;
});
diff --git a/javascript/olm_pk.js b/javascript/olm_pk.js
index 2cbe44d..4690b90 100644
--- a/javascript/olm_pk.js
+++ b/javascript/olm_pk.js
@@ -8,7 +8,7 @@ function pk_encryption_method(wrapped) {
return function() {
var result = wrapped.apply(this, arguments);
if (result === OLM_ERROR) {
- var message = Pointer_stringify(
+ var message = UTF8ToString(
Module['_olm_pk_encryption_last_error'](arguments[0])
);
throw new Error("OLM." + message);
@@ -77,9 +77,9 @@ PkEncryption.prototype['encrypt'] = restore_stack(function(
0, "i8"
);
return {
- "ciphertext": UTF8ToString(ciphertext_buffer),
- "mac": Pointer_stringify(mac_buffer),
- "ephemeral": Pointer_stringify(ephemeral_buffer)
+ "ciphertext": UTF8ToString(ciphertext_buffer, ciphertext_length),
+ "mac": UTF8ToString(mac_buffer, mac_length),
+ "ephemeral": UTF8ToString(ephemeral_buffer, ephemeral_length)
};
} finally {
if (random !== undefined) {
@@ -108,7 +108,7 @@ function pk_decryption_method(wrapped) {
return function() {
var result = wrapped.apply(this, arguments);
if (result === OLM_ERROR) {
- var message = Pointer_stringify(
+ var message = UTF8ToString(
Module['_olm_pk_decryption_last_error'](arguments[0])
);
throw new Error("OLM." + message);
@@ -140,7 +140,7 @@ PkDecryption.prototype['init_with_private_key'] = restore_stack(function (privat
// clear out our copy of the private key
bzero(private_key_buffer, private_key.length);
}
- return Pointer_stringify(pubkey_buffer);
+ return UTF8ToString(pubkey_buffer, pubkey_length);
});
PkDecryption.prototype['generate_key'] = restore_stack(function () {
@@ -162,7 +162,7 @@ PkDecryption.prototype['generate_key'] = restore_stack(function () {
// clear out the random buffer (= private key)
bzero(random_buffer, random_length);
}
- return Pointer_stringify(pubkey_buffer);
+ return UTF8ToString(pubkey_buffer, pubkey_length);
});
PkDecryption.prototype['get_private_key'] = restore_stack(function () {
@@ -202,7 +202,7 @@ PkDecryption.prototype['pickle'] = restore_stack(function (key) {
key_array[i] = 0;
}
}
- return Pointer_stringify(pickle_buffer);
+ return UTF8ToString(pickle_buffer, pickle_length);
});
PkDecryption.prototype['unpickle'] = restore_stack(function (key, pickle) {
@@ -226,7 +226,7 @@ PkDecryption.prototype['unpickle'] = restore_stack(function (key, pickle) {
key_array[i] = 0;
}
}
- return Pointer_stringify(ephemeral_buffer);
+ return UTF8ToString(ephemeral_buffer, ephemeral_length);
});
PkDecryption.prototype['decrypt'] = restore_stack(function (
@@ -259,7 +259,7 @@ PkDecryption.prototype['decrypt'] = restore_stack(function (
plaintext_buffer + plaintext_length,
0, "i8"
);
- return UTF8ToString(plaintext_buffer);
+ return UTF8ToString(plaintext_buffer, plaintext_length);
} finally {
if (plaintext_buffer !== undefined) {
// don't leave a copy of the plaintext in the heap.
@@ -283,7 +283,7 @@ function pk_signing_method(wrapped) {
return function() {
var result = wrapped.apply(this, arguments);
if (result === OLM_ERROR) {
- var message = Pointer_stringify(
+ var message = UTF8ToString(
Module['_olm_pk_signing_last_error'](arguments[0])
);
throw new Error("OLM." + message);
@@ -315,7 +315,7 @@ PkSigning.prototype['init_with_seed'] = restore_stack(function (seed) {
// clear out our copy of the seed
bzero(seed_buffer, seed.length);
}
- return Pointer_stringify(pubkey_buffer);
+ return UTF8ToString(pubkey_buffer, pubkey_length);
});
PkSigning.prototype['generate_seed'] = restore_stack(function () {
@@ -351,7 +351,7 @@ PkSigning.prototype['sign'] = restore_stack(function (message) {
message_buffer, message_length,
sig_buffer, sig_length
);
- return Pointer_stringify(sig_buffer);
+ return UTF8ToString(sig_buffer, sig_length);
} finally {
if (message_buffer !== undefined) {
// don't leave a copy of the plaintext in the heap.
diff --git a/javascript/olm_post.js b/javascript/olm_post.js
index a3a3ef4..ad058d9 100644
--- a/javascript/olm_post.js
+++ b/javascript/olm_post.js
@@ -49,7 +49,7 @@ function account_method(wrapped) {
return function() {
var result = wrapped.apply(this, arguments);
if (result === OLM_ERROR) {
- var message = Pointer_stringify(
+ var message = UTF8ToString(
Module['_olm_account_last_error'](arguments[0])
);
throw new Error("OLM." + message);
@@ -81,7 +81,7 @@ Account.prototype['identity_keys'] = restore_stack(function() {
account_method(Module['_olm_account_identity_keys'])(
this.ptr, keys, keys_length
);
- return Pointer_stringify(keys);
+ return UTF8ToString(keys, keys_length);
});
Account.prototype['sign'] = restore_stack(function(message) {
@@ -104,7 +104,7 @@ Account.prototype['sign'] = restore_stack(function(message) {
message_array[i] = 0;
}
}
- return Pointer_stringify(signature_buffer);
+ return UTF8ToString(signature_buffer, signature_length);
});
Account.prototype['one_time_keys'] = restore_stack(function() {
@@ -115,7 +115,7 @@ Account.prototype['one_time_keys'] = restore_stack(function() {
account_method(Module['_olm_account_one_time_keys'])(
this.ptr, keys, keys_length
);
- return Pointer_stringify(keys);
+ return UTF8ToString(keys, keys_length);
});
Account.prototype['mark_keys_as_published'] = restore_stack(function() {
@@ -164,7 +164,7 @@ Account.prototype['pickle'] = restore_stack(function(key) {
key_array[i] = 0;
}
}
- return Pointer_stringify(pickle_buffer);
+ return UTF8ToString(pickle_buffer, pickle_length);
});
Account.prototype['unpickle'] = restore_stack(function(key, pickle) {
@@ -196,7 +196,7 @@ function session_method(wrapped) {
return function() {
var result = wrapped.apply(this, arguments);
if (result === OLM_ERROR) {
- var message = Pointer_stringify(
+ var message = UTF8ToString(
Module['_olm_session_last_error'](arguments[0])
);
throw new Error("OLM." + message);
@@ -228,7 +228,7 @@ Session.prototype['pickle'] = restore_stack(function(key) {
key_array[i] = 0;
}
}
- return Pointer_stringify(pickle_buffer);
+ return UTF8ToString(pickle_buffer, pickle_length);
});
Session.prototype['unpickle'] = restore_stack(function(key, pickle) {
@@ -320,7 +320,7 @@ Session.prototype['session_id'] = restore_stack(function() {
session_method(Module['_olm_session_id'])(
this.ptr, id_buffer, id_length
);
- return Pointer_stringify(id_buffer);
+ return UTF8ToString(id_buffer, id_length);
});
Session.prototype['has_received_message'] = function() {
@@ -396,7 +396,7 @@ Session.prototype['encrypt'] = restore_stack(function(
return {
"type": message_type,
- "body": UTF8ToString(message_buffer),
+ "body": UTF8ToString(message_buffer, message_length),
};
} finally {
if (random !== undefined) {
@@ -445,14 +445,14 @@ Session.prototype['decrypt'] = restore_stack(function(
0, "i8"
);
- return UTF8ToString(plaintext_buffer);
+ return UTF8ToString(plaintext_buffer, plaintext_length);
} finally {
if (message_buffer !== undefined) {
free(message_buffer);
}
if (plaintext_buffer !== undefined) {
// don't leave a copy of the plaintext in the heap.
- bzero(plaintext_buffer, max_plaintext_length + NULL_BYTE_PADDING_LENGTH);
+ bzero(plaintext_buffer, max_plaintext_length);
free(plaintext_buffer);
}
}
@@ -469,7 +469,7 @@ function utility_method(wrapped) {
return function() {
var result = wrapped.apply(this, arguments);
if (result === OLM_ERROR) {
- var message = Pointer_stringify(
+ var message = UTF8ToString(
Module['_olm_utility_last_error'](arguments[0])
);
throw new Error("OLM." + message);
@@ -501,7 +501,7 @@ Utility.prototype['sha256'] = restore_stack(function(input) {
input_array[i] = 0;
}
}
- return Pointer_stringify(output_buffer);
+ return UTF8ToString(output_buffer, output_length);
});
Utility.prototype['ed25519_verify'] = restore_stack(function(
diff --git a/javascript/olm_sas.js b/javascript/olm_sas.js
index a2f82ee..5cf3fb0 100644
--- a/javascript/olm_sas.js
+++ b/javascript/olm_sas.js
@@ -12,7 +12,7 @@ function sas_method(wrapped) {
return function() {
var result = wrapped.apply(this, arguments);
if (result === OLM_ERROR) {
- var message = Pointer_stringify(
+ var message = UTF8ToString(
Module['_olm_sas_last_error'](arguments[0])
);
throw new Error("OLM." + message);
@@ -30,7 +30,7 @@ SAS.prototype['get_pubkey'] = restore_stack(function() {
var pubkey_length = sas_method(Module['_olm_sas_pubkey_length'])(this.ptr);
var pubkey_buffer = stack(pubkey_length + NULL_BYTE_PADDING_LENGTH);
sas_method(Module['_olm_sas_get_pubkey'])(this.ptr, pubkey_buffer, pubkey_length);
- return Pointer_stringify(pubkey_buffer);
+ return UTF8ToString(pubkey_buffer, pubkey_length);
});
SAS.prototype['set_their_key'] = restore_stack(function(their_key) {
@@ -73,7 +73,7 @@ SAS.prototype['calculate_mac'] = restore_stack(function(input, info) {
info_buffer, info_array.length,
mac_buffer, mac_length
);
- return Pointer_stringify(mac_buffer);
+ return UTF8ToString(mac_buffer, mac_length);
});
SAS.prototype['calculate_mac_long_kdf'] = restore_stack(function(input, info) {
@@ -89,5 +89,5 @@ SAS.prototype['calculate_mac_long_kdf'] = restore_stack(function(input, info) {
info_buffer, info_array.length,
mac_buffer, mac_length
);
- return Pointer_stringify(mac_buffer);
+ return UTF8ToString(mac_buffer, mac_length);
});