Changeset 279723 in webkit
- Timestamp:
- Jul 8, 2021 9:29:15 AM (13 months ago)
- Location:
- trunk
- Files:
-
- 8 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/crypto/subtle/ecdh-derive-bits-malformed-parametrs-expected.txt (modified) (1 diff)
-
LayoutTests/crypto/subtle/ecdh-derive-bits-malformed-parametrs.html (modified) (1 diff)
-
LayoutTests/imported/w3c/ChangeLog (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/WebCryptoAPI/derive_bits_keys/ecdh_bits.https.any-expected.txt (modified) (3 diffs)
-
LayoutTests/imported/w3c/web-platform-tests/WebCryptoAPI/derive_bits_keys/ecdh_bits.https.any.worker-expected.txt (modified) (3 diffs)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/crypto/algorithms/CryptoAlgorithmECDH.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r279722 r279723 1 2021-07-08 Chris Dumez <cdumez@apple.com> 2 3 [WebCrypto] deriveBits() fails if length is not a multiple of 8 for ECDH algorithm 4 https://bugs.webkit.org/show_bug.cgi?id=227796 5 6 Reviewed by Alex Christensen. 7 8 Update existing layout test due to behavior change. 9 10 * crypto/subtle/ecdh-derive-bits-malformed-parametrs-expected.txt: 11 * crypto/subtle/ecdh-derive-bits-malformed-parametrs.html: 12 1 13 2021-07-08 Myles C. Maxfield <mmaxfield@apple.com> 2 14 -
trunk/LayoutTests/crypto/subtle/ecdh-derive-bits-malformed-parametrs-expected.txt
r219663 r279723 12 12 PASS crypto.subtle.deriveBits({name: "ecdh", public: { }}, privateKey, null) rejected promise with TypeError: Type error. 13 13 PASS crypto.subtle.deriveBits({name: "ecdh", public: 1}, privateKey, null) rejected promise with TypeError: Type error. 14 PASS crypto.subtle.deriveBits({ name:"ECDH", public:publicKey }, privateKey, 1) rejected promise with OperationError: The operation failed for an operation-specific reason.15 14 PASS crypto.subtle.deriveBits({ name:"ECDH", public:publicKey }, publicKey, null) rejected promise with InvalidAccessError: CryptoKey doesn't support bits derivation. 16 15 PASS crypto.subtle.deriveBits({ name:"ECDH", public:privateKey }, privateKey, null) rejected promise with InvalidAccessError: The requested operation is not valid for the provided key. -
trunk/LayoutTests/crypto/subtle/ecdh-derive-bits-malformed-parametrs.html
r213624 r279723 56 56 shouldReject('crypto.subtle.deriveBits({name: "ecdh", public: { }}, privateKey, null)'); 57 57 shouldReject('crypto.subtle.deriveBits({name: "ecdh", public: 1}, privateKey, null)'); 58 // Wrong length59 shouldReject('crypto.subtle.deriveBits({ name:"ECDH", public:publicKey }, privateKey, 1)');60 58 // base key is public 61 59 shouldReject('crypto.subtle.deriveBits({ name:"ECDH", public:publicKey }, publicKey, null)'); -
trunk/LayoutTests/imported/w3c/ChangeLog
r279722 r279723 1 2021-07-08 Chris Dumez <cdumez@apple.com> 2 3 [WebCrypto] deriveBits() fails if length is not a multiple of 8 for ECDH algorithm 4 https://bugs.webkit.org/show_bug.cgi?id=227796 5 6 Reviewed by Alex Christensen. 7 8 Rebaseline WPT tests now that more checks are passing. 9 10 * web-platform-tests/WebCryptoAPI/derive_bits_keys/ecdh_bits.https.any-expected.txt: 11 * web-platform-tests/WebCryptoAPI/derive_bits_keys/ecdh_bits.https.any.worker-expected.txt: 12 1 13 2021-07-08 Myles C. Maxfield <mmaxfield@apple.com> 2 14 -
trunk/LayoutTests/imported/w3c/web-platform-tests/WebCryptoAPI/derive_bits_keys/ecdh_bits.https.any-expected.txt
r279688 r279723 5 5 PASS P-521 with null length 6 6 PASS P-521 short result 7 FAIL P-521 non-multiple of 8 bits assert_unreached: deriveBits failed with error OperationError: The operation failed for an operation-specific reason Reached unreachable code 7 PASS P-521 non-multiple of 8 bits 8 8 PASS P-521 missing public curve 9 9 PASS P-521 public property of algorithm is not a CryptoKey … … 19 19 PASS P-256 with null length 20 20 PASS P-256 short result 21 FAIL P-256 non-multiple of 8 bits assert_unreached: deriveBits failed with error OperationError: The operation failed for an operation-specific reason Reached unreachable code 21 PASS P-256 non-multiple of 8 bits 22 22 PASS P-256 missing public curve 23 23 PASS P-256 public property of algorithm is not a CryptoKey … … 33 33 PASS P-384 with null length 34 34 PASS P-384 short result 35 FAIL P-384 non-multiple of 8 bits assert_unreached: deriveBits failed with error OperationError: The operation failed for an operation-specific reason Reached unreachable code 35 PASS P-384 non-multiple of 8 bits 36 36 PASS P-384 missing public curve 37 37 PASS P-384 public property of algorithm is not a CryptoKey -
trunk/LayoutTests/imported/w3c/web-platform-tests/WebCryptoAPI/derive_bits_keys/ecdh_bits.https.any.worker-expected.txt
r279688 r279723 5 5 PASS P-521 with null length 6 6 PASS P-521 short result 7 FAIL P-521 non-multiple of 8 bits assert_unreached: deriveBits failed with error OperationError: The operation failed for an operation-specific reason Reached unreachable code 7 PASS P-521 non-multiple of 8 bits 8 8 PASS P-521 missing public curve 9 9 PASS P-521 public property of algorithm is not a CryptoKey … … 19 19 PASS P-256 with null length 20 20 PASS P-256 short result 21 FAIL P-256 non-multiple of 8 bits assert_unreached: deriveBits failed with error OperationError: The operation failed for an operation-specific reason Reached unreachable code 21 PASS P-256 non-multiple of 8 bits 22 22 PASS P-256 missing public curve 23 23 PASS P-256 public property of algorithm is not a CryptoKey … … 33 33 PASS P-384 with null length 34 34 PASS P-384 short result 35 FAIL P-384 non-multiple of 8 bits assert_unreached: deriveBits failed with error OperationError: The operation failed for an operation-specific reason Reached unreachable code 35 PASS P-384 non-multiple of 8 bits 36 36 PASS P-384 missing public curve 37 37 PASS P-384 public property of algorithm is not a CryptoKey -
trunk/Source/WebCore/ChangeLog
r279722 r279723 1 2021-07-08 Chris Dumez <cdumez@apple.com> 2 3 [WebCrypto] deriveBits() fails if length is not a multiple of 8 for ECDH algorithm 4 https://bugs.webkit.org/show_bug.cgi?id=227796 5 6 Reviewed by Alex Christensen. 7 8 deriveBits() fails if length is not a multiple of 8 for ECDH algorithm. This doesn't match 9 the specification or the behavior of Chrome. 10 11 No new tests, rebaselined existing tests. 12 13 * crypto/algorithms/CryptoAlgorithmECDH.cpp: 14 (WebCore::CryptoAlgorithmECDH::deriveBits): 15 1 16 2021-07-08 Myles C. Maxfield <mmaxfield@apple.com> 2 17 -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmECDH.cpp
r278253 r279723 69 69 void CryptoAlgorithmECDH::deriveBits(const CryptoAlgorithmParameters& parameters, Ref<CryptoKey>&& baseKey, size_t length, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue) 70 70 { 71 // We only accept length that is a multiple of 8.72 if (length % 8) {73 exceptionCallback(OperationError);74 return;75 }76 77 71 auto& ecParameters = downcast<CryptoAlgorithmEcdhKeyDeriveParams>(parameters); 78 72 … … 106 100 return; 107 101 } 108 if (length / 8 > (*derivedKey).size()) { 102 auto lengthInBytes = std::ceil(length / 8.); 103 if (lengthInBytes > (*derivedKey).size()) { 109 104 exceptionCallback(OperationError); 110 105 return; 111 106 } 112 (*derivedKey).shrink(length / 8);107 (*derivedKey).shrink(lengthInBytes); 113 108 callback(WTFMove(*derivedKey)); 114 109 };
Note: See TracChangeset
for help on using the changeset viewer.