- Revision
- 275535
- Author
- [email protected]
- Date
- 2021-04-06 11:10:31 -0700 (Tue, 06 Apr 2021)
Log Message
WebCrypto in Safari will not AES-GCM encrypt 0 bytes
https://bugs.webkit.org/show_bug.cgi?id=224083
<rdar://75093377>
Reviewed by Youenn Fablet.
Source/WebCore:
CommonCrypto will bail out both the encryption and decryption process if the dataOut is a null pointer.
To workaround the issue, this patch forces the dataOut to be a non-null pointer.
Test: crypto/subtle/aes-gcm-generate-key-encrypt-decrypt-null-plain-text.html
* crypto/mac/CryptoAlgorithmAES_GCMMac.cpp:
(WebCore::encryptAES_GCM):
(WebCore::decyptAES_GCM):
LayoutTests:
* crypto/subtle/aes-gcm-generate-key-encrypt-decrypt-null-plain-text-expected.txt: Added.
* crypto/subtle/aes-gcm-generate-key-encrypt-decrypt-null-plain-text.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (275534 => 275535)
--- trunk/LayoutTests/ChangeLog 2021-04-06 18:02:25 UTC (rev 275534)
+++ trunk/LayoutTests/ChangeLog 2021-04-06 18:10:31 UTC (rev 275535)
@@ -1,3 +1,14 @@
+2021-04-06 Jiewen Tan <[email protected]>
+
+ WebCrypto in Safari will not AES-GCM encrypt 0 bytes
+ https://bugs.webkit.org/show_bug.cgi?id=224083
+ <rdar://75093377>
+
+ Reviewed by Youenn Fablet.
+
+ * crypto/subtle/aes-gcm-generate-key-encrypt-decrypt-null-plain-text-expected.txt: Added.
+ * crypto/subtle/aes-gcm-generate-key-encrypt-decrypt-null-plain-text.html: Added.
+
2021-04-06 Chris Gambrell <[email protected]>
[LayoutTests] Convert http/tests/loading convert PHP to Python
Added: trunk/LayoutTests/crypto/subtle/aes-gcm-generate-key-encrypt-decrypt-null-plain-text-expected.txt (0 => 275535)
--- trunk/LayoutTests/crypto/subtle/aes-gcm-generate-key-encrypt-decrypt-null-plain-text-expected.txt (rev 0)
+++ trunk/LayoutTests/crypto/subtle/aes-gcm-generate-key-encrypt-decrypt-null-plain-text-expected.txt 2021-04-06 18:10:31 UTC (rev 275535)
@@ -0,0 +1,14 @@
+Test encrypting&decrypting using AES-GCM algorithm with a generated 256bit key
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Generating a key...
+Encrypting...
+PASS bytesToASCIIString(cipherText) is not ""
+Decrypting...
+PASS bytesToASCIIString(decryptedText) is plainText
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/crypto/subtle/aes-gcm-generate-key-encrypt-decrypt-null-plain-text.html (0 => 275535)
--- trunk/LayoutTests/crypto/subtle/aes-gcm-generate-key-encrypt-decrypt-null-plain-text.html (rev 0)
+++ trunk/LayoutTests/crypto/subtle/aes-gcm-generate-key-encrypt-decrypt-null-plain-text.html 2021-04-06 18:10:31 UTC (rev 275535)
@@ -0,0 +1,42 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test encrypting&decrypting using AES-GCM algorithm with a generated 256bit key");
+
+jsTestIsAsync = true;
+var plainText = "";
+var aesGcmParams = {
+ name: "aes-gcm",
+ iv: asciiToUint8Array("jnOw99oOZFLIEPMr"),
+}
+
+debug("Generating a key...");
+crypto.subtle.generateKey({name: "aes-gcm", length: 256}, true, ["decrypt", "encrypt"]).then(function(result) {
+ key = result;
+ debug("Encrypting...");
+ return crypto.subtle.encrypt(aesGcmParams, key, asciiToUint8Array(plainText));
+}).then(function(result) {
+ cipherText = result;
+ shouldNotBeEqualToString("bytesToASCIIString(cipherText)", plainText);
+ debug("Decrypting...");
+ return crypto.subtle.decrypt(aesGcmParams, key, cipherText);
+}).then(function(result) {
+ decryptedText = result;
+
+ shouldBe("bytesToASCIIString(decryptedText)", "plainText");
+
+ finishJSTest();
+});
+</script>
+
+<script src=""
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (275534 => 275535)
--- trunk/Source/WebCore/ChangeLog 2021-04-06 18:02:25 UTC (rev 275534)
+++ trunk/Source/WebCore/ChangeLog 2021-04-06 18:10:31 UTC (rev 275535)
@@ -1,3 +1,20 @@
+2021-04-06 Jiewen Tan <[email protected]>
+
+ WebCrypto in Safari will not AES-GCM encrypt 0 bytes
+ https://bugs.webkit.org/show_bug.cgi?id=224083
+ <rdar://75093377>
+
+ Reviewed by Youenn Fablet.
+
+ CommonCrypto will bail out both the encryption and decryption process if the dataOut is a null pointer.
+ To workaround the issue, this patch forces the dataOut to be a non-null pointer.
+
+ Test: crypto/subtle/aes-gcm-generate-key-encrypt-decrypt-null-plain-text.html
+
+ * crypto/mac/CryptoAlgorithmAES_GCMMac.cpp:
+ (WebCore::encryptAES_GCM):
+ (WebCore::decyptAES_GCM):
+
2021-04-06 Patrick Angle <[email protected]>
Web Inspector: Grid overlay areas appear offset from their actual areas when the grid container has a border set
Modified: trunk/Source/WebCore/crypto/mac/CryptoAlgorithmAES_GCMMac.cpp (275534 => 275535)
--- trunk/Source/WebCore/crypto/mac/CryptoAlgorithmAES_GCMMac.cpp 2021-04-06 18:02:25 UTC (rev 275534)
+++ trunk/Source/WebCore/crypto/mac/CryptoAlgorithmAES_GCMMac.cpp 2021-04-06 18:10:31 UTC (rev 275535)
@@ -37,7 +37,8 @@
static ExceptionOr<Vector<uint8_t>> encryptAES_GCM(const Vector<uint8_t>& iv, const Vector<uint8_t>& key, const Vector<uint8_t>& plainText, const Vector<uint8_t>& additionalData, size_t desiredTagLengthInBytes)
{
- Vector<uint8_t> cipherText(plainText.size()); // Per section 5.2.1.2: http://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf
+ // This is a wordaround for rdar://75093377. Force the buffer to be a non null pointer.
+ Vector<uint8_t> cipherText(plainText.size() + desiredTagLengthInBytes); // Per section 5.2.1.2: http://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf
Vector<uint8_t> tag(desiredTagLengthInBytes);
// tagLength is actual an input <rdar://problem/30660074>
ALLOW_DEPRECATED_DECLARATIONS_BEGIN
@@ -46,7 +47,7 @@
if (status)
return Exception { OperationError };
- cipherText.append(tag.data(), desiredTagLengthInBytes);
+ memcpy(cipherText.data() + plainText.size(), tag.data(), desiredTagLengthInBytes);
return WTFMove(cipherText);
}
@@ -53,7 +54,8 @@
static ExceptionOr<Vector<uint8_t>> decyptAES_GCM(const Vector<uint8_t>& iv, const Vector<uint8_t>& key, const Vector<uint8_t>& cipherText, const Vector<uint8_t>& additionalData, size_t desiredTagLengthInBytes)
{
- Vector<uint8_t> plainText(cipherText.size() - desiredTagLengthInBytes); // Per section 5.2.1.2: http://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf
+ // This is a wordaround for rdar://75093377. Force the buffer to be a non null pointer.
+ Vector<uint8_t> plainText(cipherText.size()); // Per section 5.2.1.2: http://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf
Vector<uint8_t> tag(desiredTagLengthInBytes);
size_t offset = cipherText.size() - desiredTagLengthInBytes;
// tagLength is actual an input <rdar://problem/30660074>
@@ -67,6 +69,8 @@
if (constantTimeMemcmp(tag.data(), cipherText.data() + offset, desiredTagLengthInBytes))
return Exception { OperationError };
+ // This is a wordaround for rdar://75093377. Force the buffer to be a non null pointer.
+ plainText.shrink(offset);
return WTFMove(plainText);
}