Title: [215721] trunk
Revision
215721
Author
jiewen_...@apple.com
Date
2017-04-24 22:10:00 -0700 (Mon, 24 Apr 2017)

Log Message

LayoutTests crypto/subtle/ecdsa-generate-key-sign-verify-p384.html and crypto/subtle/ecdsa-generate-key-sign-verify-p256.html are flaky failures
https://bugs.webkit.org/show_bug.cgi?id=171059
<rdar://problem/31734958>

Reviewed by Brent Fulgham.

Source/WebCore:

Covered by existing tests.

* crypto/mac/CryptoAlgorithmECDSAMac.cpp:
(WebCore::signECDSA):
Enhance ways to convert the DER signatures produced from CommonCrypto to r||s.

LayoutTests:

* TestExpectations:
Remove test expectations.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (215720 => 215721)


--- trunk/LayoutTests/ChangeLog	2017-04-25 05:09:10 UTC (rev 215720)
+++ trunk/LayoutTests/ChangeLog	2017-04-25 05:10:00 UTC (rev 215721)
@@ -1,3 +1,14 @@
+2017-04-24  Jiewen Tan  <jiewen_...@apple.com>
+
+        LayoutTests crypto/subtle/ecdsa-generate-key-sign-verify-p384.html and crypto/subtle/ecdsa-generate-key-sign-verify-p256.html are flaky failures
+        https://bugs.webkit.org/show_bug.cgi?id=171059
+        <rdar://problem/31734958>
+
+        Reviewed by Brent Fulgham.
+
+        * TestExpectations:
+        Remove test expectations.
+
 2017-04-24  Manuel Rego Casasnovas  <r...@igalia.com>
 
         [selectors4] :focus-within should use the flat tree

Modified: trunk/LayoutTests/TestExpectations (215720 => 215721)


--- trunk/LayoutTests/TestExpectations	2017-04-25 05:09:10 UTC (rev 215720)
+++ trunk/LayoutTests/TestExpectations	2017-04-25 05:10:00 UTC (rev 215721)
@@ -1287,9 +1287,4 @@
 
 webkit.org/b/171031 imported/w3c/web-platform-tests/XMLHttpRequest/getallresponseheaders-cl.htm [ Failure ]
 
-webkit.org/b/171059 crypto/subtle/ecdsa-generate-key-sign-verify-p384.html [ Pass Failure ]
-webkit.org/b/171059 crypto/subtle/ecdsa-generate-key-sign-verify-p256.html [ Pass Failure ]
-
-webkit.org/b/170921 imported/w3c/web-platform-tests/WebCryptoAPI/sign_verify/ecdsa.worker.html [ Pass Failure ]
-
 webkit.org/b/170701 webrtc/datachannel/bufferedAmountLowThreshold.html [ Pass Failure ]

Modified: trunk/Source/WebCore/ChangeLog (215720 => 215721)


--- trunk/Source/WebCore/ChangeLog	2017-04-25 05:09:10 UTC (rev 215720)
+++ trunk/Source/WebCore/ChangeLog	2017-04-25 05:10:00 UTC (rev 215721)
@@ -1,3 +1,17 @@
+2017-04-24  Jiewen Tan  <jiewen_...@apple.com>
+
+        LayoutTests crypto/subtle/ecdsa-generate-key-sign-verify-p384.html and crypto/subtle/ecdsa-generate-key-sign-verify-p256.html are flaky failures
+        https://bugs.webkit.org/show_bug.cgi?id=171059
+        <rdar://problem/31734958>
+
+        Reviewed by Brent Fulgham.
+
+        Covered by existing tests.
+
+        * crypto/mac/CryptoAlgorithmECDSAMac.cpp:
+        (WebCore::signECDSA):
+        Enhance ways to convert the DER signatures produced from CommonCrypto to r||s.
+
 2017-04-24  Manuel Rego Casasnovas  <r...@igalia.com>
 
         [selectors4] :focus-within should use the flat tree

Modified: trunk/Source/WebCore/crypto/mac/CryptoAlgorithmECDSAMac.cpp (215720 => 215721)


--- trunk/Source/WebCore/crypto/mac/CryptoAlgorithmECDSAMac.cpp	2017-04-25 05:09:10 UTC (rev 215720)
+++ trunk/Source/WebCore/crypto/mac/CryptoAlgorithmECDSAMac.cpp	2017-04-25 05:10:00 UTC (rev 215721)
@@ -84,17 +84,34 @@
     // convert the DER binary into r + s
     Vector<uint8_t> newSignature;
     newSignature.reserveCapacity(keyLengthInBytes * 2);
-    size_t offset = 4;
-    if (signature[offset] == InitialOctet)
-        offset += 1;
-    ASSERT_WITH_SECURITY_IMPLICATION(signature.size() > offset + keyLengthInBytes);
-    newSignature.append(signature.data() + offset, keyLengthInBytes);
-    offset += keyLengthInBytes + 2;
-    if (signature[offset] == InitialOctet)
-        offset += 1;
-    ASSERT_WITH_SECURITY_IMPLICATION(signature.size() >= offset + keyLengthInBytes);
-    newSignature.append(signature.data() + offset, keyLengthInBytes);
+    size_t offset = 3; // skip tag, length, tag
 
+    // If r < keyLengthInBytes, fill the head of r with 0s.
+    size_t bytesToCopy = keyLengthInBytes;
+    if (signature[offset] < keyLengthInBytes) {
+        newSignature.resize(keyLengthInBytes - signature[offset]);
+        memset(newSignature.data(), InitialOctet, keyLengthInBytes - signature[offset]);
+        bytesToCopy = signature[offset];
+    } else if (signature[offset] > keyLengthInBytes) // Otherwise skip the leading 0s of r.
+        offset += signature[offset] - keyLengthInBytes;
+    offset++; // skip length
+    ASSERT_WITH_SECURITY_IMPLICATION(signature.size() > offset + bytesToCopy);
+    newSignature.append(signature.data() + offset, bytesToCopy);
+    offset += bytesToCopy + 1; // skip r, tag
+
+    // If s < keyLengthInBytes, fill the head of s with 0s.
+    bytesToCopy = keyLengthInBytes;
+    if (signature[offset] < keyLengthInBytes) {
+        size_t pos = newSignature.size();
+        newSignature.resize(pos + keyLengthInBytes - signature[offset]);
+        memset(newSignature.data() + pos, InitialOctet, keyLengthInBytes - signature[offset]);
+        bytesToCopy = signature[offset];
+    } else if (signature[offset] > keyLengthInBytes) // Otherwise skip the leading 0s of s.
+        offset += signature[offset] - keyLengthInBytes;
+    offset++; // skip length
+    ASSERT_WITH_SECURITY_IMPLICATION(signature.size() >= offset + bytesToCopy);
+    newSignature.append(signature.data() + offset, bytesToCopy);
+
     return WTFMove(newSignature);
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to