aboutsummaryrefslogtreecommitdiff
path: root/javascript/olm_pk.js
diff options
context:
space:
mode:
Diffstat (limited to 'javascript/olm_pk.js')
-rw-r--r--javascript/olm_pk.js26
1 files changed, 13 insertions, 13 deletions
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.