Bug 434624: Handle "websafe" base64 characters in client keys. r=tony

This commit is contained in:
Dave Camp 2008-06-25 19:24:00 -07:00
parent 400dd5d87c
commit ad00948be1

View File

@ -258,6 +258,11 @@ PROT_UrlCryptoKeyManager.prototype.hasKey = function() {
return this.clientKey_ != null && this.wrappedKey_ != null;
}
PROT_UrlCryptoKeyManager.prototype.unUrlSafe = function(key)
{
return key.replace("-", "+").replace("_", "/");
}
/**
* Set a new key and serialize it to disk.
*
@ -273,7 +278,7 @@ PROT_UrlCryptoKeyManager.prototype.replaceKey_ = function(clientKey,
G_Debug(this, "Replacing " + this.clientKey_ + " with " + clientKey);
this.clientKey_ = clientKey;
this.clientKeyArray_ = Array.map(atob(clientKey),
this.clientKeyArray_ = Array.map(atob(this.unUrlSafe(clientKey)),
function(c) { return c.charCodeAt(0); });
this.wrappedKey_ = wrappedKey;