Title: [159392] trunk
Revision
159392
Author
[email protected]
Date
2013-11-17 17:17:09 -0800 (Sun, 17 Nov 2013)

Log Message

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.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (159391 => 159392)


--- trunk/LayoutTests/ChangeLog	2013-11-18 01:12:17 UTC (rev 159391)
+++ trunk/LayoutTests/ChangeLog	2013-11-18 01:17:09 UTC (rev 159392)
@@ -1,3 +1,16 @@
+2013-11-17  Alexey Proskuryakov  <[email protected]>
+
+        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  <[email protected]>
 
         REGRESSION (r158774): Iteration over element children is broken

Modified: trunk/LayoutTests/crypto/subtle/aes-export-key.html (159391 => 159392)


--- trunk/LayoutTests/crypto/subtle/aes-export-key.html	2013-11-18 01:12:17 UTC (rev 159391)
+++ trunk/LayoutTests/crypto/subtle/aes-export-key.html	2013-11-18 01:17:09 UTC (rev 159392)
@@ -48,7 +48,7 @@
     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'");

Modified: trunk/LayoutTests/crypto/subtle/hmac-export-key.html (159391 => 159392)


--- trunk/LayoutTests/crypto/subtle/hmac-export-key.html	2013-11-18 01:12:17 UTC (rev 159391)
+++ trunk/LayoutTests/crypto/subtle/hmac-export-key.html	2013-11-18 01:17:09 UTC (rev 159392)
@@ -42,7 +42,7 @@
     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'");

Modified: trunk/LayoutTests/crypto/subtle/resources/common.js (159391 => 159392)


--- trunk/LayoutTests/crypto/subtle/resources/common.js	2013-11-18 01:12:17 UTC (rev 159391)
+++ trunk/LayoutTests/crypto/subtle/resources/common.js	2013-11-18 01:17:09 UTC (rev 159392)
@@ -54,6 +54,11 @@
     return hexBytes.join("");
 }
 
+function bytesToASCIIString(bytes)
+{
+    return String.fromCharCode.apply(null, new Uint8Array(bytes));
+}
+
 function hexStringToUint8Array(hexString)
 {
     if (hexString.length % 2 != 0)

Modified: trunk/Source/WebCore/ChangeLog (159391 => 159392)


--- trunk/Source/WebCore/ChangeLog	2013-11-18 01:12:17 UTC (rev 159391)
+++ trunk/Source/WebCore/ChangeLog	2013-11-18 01:17:09 UTC (rev 159392)
@@ -1,3 +1,13 @@
+2013-11-17  Alexey Proskuryakov  <[email protected]>
+
+        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  <[email protected]>
 
         LayoutStateMaintainer should use references where possible

Modified: trunk/Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp (159391 => 159392)


--- trunk/Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp	2013-11-18 01:12:17 UTC (rev 159391)
+++ trunk/Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp	2013-11-18 01:17:09 UTC (rev 159392)
@@ -548,7 +548,7 @@
         CString utf8String = result.utf8(StrictConversion);
         Vector<unsigned char> resultBuffer;
         resultBuffer.append(utf8String.data(), utf8String.length());
-        promiseWrapper->fulfill(result);
+        promiseWrapper->fulfill(resultBuffer);
         break;
     }
     default:
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to