Commit 106eb707 authored by ap@apple.com's avatar ap@apple.com

JWK crypto key export result is a DOM string instead of an array buffer

https://bugs.webkit.org/show_bug.cgi?id=124473

Reviewed by Sam Weinig.

Source/WebCore: 

* bindings/js/JSSubtleCryptoCustom.cpp: (WebCore::JSSubtleCrypto::exportKey):
Fix it.

LayoutTests: 

* crypto/subtle/aes-export-key.html:
* crypto/subtle/hmac-export-key.html:

* crypto/subtle/resources/common.js: (bytesToASCIIString): Added a function that
converts an ArrayBuffer to a string, assuming it's all ASCII.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@159392 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent f8d77f33
2013-11-17 Alexey Proskuryakov <ap@apple.com>
JWK crypto key export result is a DOM string instead of an array buffer
https://bugs.webkit.org/show_bug.cgi?id=124473
Reviewed by Sam Weinig.
* crypto/subtle/aes-export-key.html:
* crypto/subtle/hmac-export-key.html:
* crypto/subtle/resources/common.js: (bytesToASCIIString): Added a function that
converts an ArrayBuffer to a string, assuming it's all ASCII.
2013-11-17 Antti Koivisto <antti@apple.com>
REGRESSION (r158774): Iteration over element children is broken
......
......@@ -48,7 +48,7 @@ crypto.subtle.importKey("jwk", jwkKeyAsArrayBuffer, "AES-CBC", extractable, ['en
debug("Exporting the key as JWK...");
return crypto.subtle.exportKey("jwk", key);
}).then(function(result) {
exportedJWK = JSON.parse(result);
exportedJWK = JSON.parse(bytesToASCIIString(result));
shouldBe("exportedJWK.kty", "'oct'");
shouldBe("exportedJWK.k", "'jnOw99oOZFLIEPMrgJB55WL46tJSLGt7'");
shouldBe("exportedJWK.alg", "'A192CBC'");
......
......@@ -42,7 +42,7 @@ crypto.subtle.importKey("jwk", jwkKeyAsArrayBuffer, { name: "HMAC", hash: "SHA-2
debug("Exporting the key as JWK...");
return crypto.subtle.exportKey("jwk", key);
}).then(function(result) {
exportedJWK = JSON.parse(result);
exportedJWK = JSON.parse(bytesToASCIIString(result));
shouldBe("exportedJWK.kty", "'oct'");
shouldBe("exportedJWK.k", "'ahjkn-_387fgnsibf23qsvahjkn-_387fgnsibf23qs'");
shouldBe("exportedJWK.alg", "'HS256'");
......
......@@ -54,6 +54,11 @@ function bytesToHexString(bytes)
return hexBytes.join("");
}
function bytesToASCIIString(bytes)
{
return String.fromCharCode.apply(null, new Uint8Array(bytes));
}
function hexStringToUint8Array(hexString)
{
if (hexString.length % 2 != 0)
......
2013-11-17 Alexey Proskuryakov <ap@apple.com>
JWK crypto key export result is a DOM string instead of an array buffer
https://bugs.webkit.org/show_bug.cgi?id=124473
Reviewed by Sam Weinig.
* bindings/js/JSSubtleCryptoCustom.cpp: (WebCore::JSSubtleCrypto::exportKey):
Fix it.
2013-11-17 Sam Weinig <sam@webkit.org>
LayoutStateMaintainer should use references where possible
......
......@@ -548,7 +548,7 @@ JSValue JSSubtleCrypto::exportKey(JSC::ExecState* exec)
CString utf8String = result.utf8(StrictConversion);
Vector<unsigned char> resultBuffer;
resultBuffer.append(utf8String.data(), utf8String.length());
promiseWrapper->fulfill(result);
promiseWrapper->fulfill(resultBuffer);
break;
}
default:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment