aboutsummaryrefslogtreecommitdiff
path: root/extension/background/emscriptif.js
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2015-12-13 18:10:33 +0100
committerFlorian Dold <florian.dold@gmail.com>2015-12-13 18:10:33 +0100
commitc9180a8b3c629c009a9ac33f353737f6dc1ab871 (patch)
tree9e9d659b3500c586fa484a0bb764d524434d3470 /extension/background/emscriptif.js
parent833a2cf41d000b335b4d5b8c8b1cb67fa111d27c (diff)
Towards withdrawal in the WebExtension.
Diffstat (limited to 'extension/background/emscriptif.js')
-rw-r--r--extension/background/emscriptif.js36
1 files changed, 17 insertions, 19 deletions
diff --git a/extension/background/emscriptif.js b/extension/background/emscriptif.js
index ceed32c97..da574b877 100644
--- a/extension/background/emscriptif.js
+++ b/extension/background/emscriptif.js
@@ -18,23 +18,6 @@
"use strict";
-/* The following definition is needed to make emscripted library to remain
- 'alive' after its loading. Otherwise, the normal behaviour would be:
- loading -> look for a 'main()' -> if one is found execute it then exit,
- otherwise just exit. See https://kripken.github.io/emscripten-site/docs/getting_started/FAQ.html
- DO NOTE: this definition MUST precede the importing/loading of the emscripted
- library */
-
-/* FIXME
-getLastWindow().Module = {
-
- onRuntimeInitialized: function() {
-
- }
-
-};
-*/
-
/* According to emscripten's design, we need our emscripted library to be executed
with a 'window' object as its global scope.
Note: that holds on emscripten's functions too, that is they need to be *explicitly*
@@ -64,6 +47,8 @@ getLastWindow().Module = {
respective functions come from (the emscripted version of) TALER_* realm. */
+const PTR_SIZE = 4;
+
// shortcut to emscr's 'malloc'
function emscMalloc(size) {
var ptr = Module._malloc(size);
@@ -299,8 +284,13 @@ var GCALLrsaPrivateKeyCreate = getEmsc('GNUNET_CRYPTO_rsa_private_key_create',
['number']);
var GCALLrsaBlindingKeyCreate = getEmsc('GNUNET_CRYPTO_rsa_blinding_key_create',
+ 'number',
+ ['number']);
+
+
+var GCALLrsaBlindingKeyEncode = getEmsc('GNUNET_CRYPTO_rsa_blinding_key_encode',
'number',
- ['number']);
+ ['number', 'number']);
var GCrsaBlindingKeyFree = getEmsc('GNUNET_CRYPTO_rsa_blinding_key_free',
'void',
@@ -514,7 +504,6 @@ let d2s = getEmsc('GNUNET_STRINGS_data_to_string_alloc',
let sizeof_EddsaPrivateKey = 32;
let sizeof_EddsaPublicKey = 32;
-
function createEddsaKeyPair() {
let privPtr = GCALLeddsaKeyCreate();
let pubPtr = emscMalloc(sizeof_EddsaPublicKey);
@@ -523,3 +512,12 @@ function createEddsaKeyPair() {
let pubStr = d2s(pubPtr, sizeof_EddsaPublicKey);
return {priv: privStr, pub: pubStr};
}
+
+function createRsaBlindingKey() {
+ let blindFac = GCALLrsaBlindingKeyCreate(1024);
+ let bufPtr = emscMalloc(PTR_SIZE);
+ let size = GCALLrsaBlindingKeyEncode (blindFac, bufPtr);
+ let key = d2s(Module.getValue(bufPtr, '*'), size);
+ emscFree(bufPtr);
+ return key;
+}