Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1608)

Unified Diff: chrome/browser/resources/whispernet_proxy/js/wrapper.js

Issue 870053008: 64-bit token fixes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing Whispernet test Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/whispernet_proxy/js/wrapper.js
diff --git a/chrome/browser/resources/whispernet_proxy/js/wrapper.js b/chrome/browser/resources/whispernet_proxy/js/wrapper.js
index 31c7430bb5bb7b1fd5ee37f05c5abbacbbacee8c..6bde1b3b89ddc260cb6b59cd1fb77c643ad81983 100644
--- a/chrome/browser/resources/whispernet_proxy/js/wrapper.js
+++ b/chrome/browser/resources/whispernet_proxy/js/wrapper.js
@@ -14,7 +14,7 @@ function bytesToBase64(bytes) {
var bstr = '';
for (var i = 0; i < bytes.length; ++i)
bstr += String.fromCharCode(bytes[i]);
- return btoa(bstr);
+ return btoa(bstr).replace('=', '');
}
/**
@@ -54,16 +54,22 @@ function WhisperEncoder(params, whisperNacl) {
* @param {Object} params Encode token parameters object.
*/
WhisperEncoder.prototype.encode = function(params) {
+ // Pad the token before decoding it.
+ var token = params.token.token;
+ while (token.length % 4 > 0)
+ token += '=';
+
var msg = {
type: 'encode_token',
// Trying to send the token in binary form to Nacl doesn't work correctly.
// We end up with the correct string + a bunch of extra characters. This is
// true of returning a binary string too; hence we communicate back and
// forth by converting the bytes into an array of integers.
- token: stringToArray(atob(params.token.token)),
+ token: stringToArray(atob(token)),
repetitions: params.repetitions,
use_dtmf: params.token.audible
};
+
this.whisperNacl_.send(msg);
};

Powered by Google App Engine
This is Rietveld 408576698