Changeset 273158 in webkit
- Timestamp:
- Feb 19, 2021 12:39:40 PM (3 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r273156 r273158 1 2021-02-19 Youenn Fablet <youenn@apple.com> 2 3 Allow to use BigInt as key identifier 4 https://bugs.webkit.org/show_bug.cgi?id=222165 5 6 Reviewed by Darin Adler. 7 8 * webrtc/sframe-keys-expected.txt: 9 * webrtc/sframe-keys.html: 10 1 11 2021-02-19 Fujii Hironori <Hironori.Fujii@sony.com> 2 12 -
trunk/LayoutTests/webrtc/sframe-keys-expected.txt
r270532 r273158 1 1 2 2 3 PASS Passing various key IDs 3 4 PASS Audio exchange with SFrame setup 4 5 PASS Add a new encryption key 5 6 PASS Add a new encryption key with key id 7 PASS Add a new encryption key with BigInt key id 6 8 -
trunk/LayoutTests/webrtc/sframe-keys.html
r270620 r273158 11 11 <script> 12 12 let sender, receiver; 13 let key1, key2, key3; 13 let key1, key2, key3, key4; 14 15 promise_test(async (test) => { 16 const key = await crypto.subtle.importKey("raw", new Uint8Array([143, 77, 43, 10, 72, 19, 37, 67, 236, 219, 24, 93, 26, 165, 91, 178]), "HKDF", false, ["deriveBits", "deriveKey"]); 17 const transform = new SFrameTransform; 18 19 await transform.setEncryptionKey(key); 20 await transform.setEncryptionKey(key, 1); 21 22 await transform.setEncryptionKey(key, BigInt('18446744073709551613')); 23 await transform.setEncryptionKey(key, BigInt('18446744073709551614')); 24 await transform.setEncryptionKey(key, BigInt('18446744073709551615')); 25 await transform.setEncryptionKey(key, BigInt('18446744073709551616')).then(assert_unreached, (e) => { 26 assert_true(e instanceof RangeError); 27 assert_equals(e.message, "Not a 64 bits integer"); 28 }); 29 }, "Passing various key IDs"); 14 30 15 31 promise_test(async (test) => { … … 17 33 key2 = await crypto.subtle.importKey("raw", new Uint8Array([144, 77, 43, 10, 72, 19, 37, 67, 236, 219, 24, 93, 26, 165, 91, 178]), "HKDF", false, ["deriveBits", "deriveKey"]); 18 34 key3 = await crypto.subtle.importKey("raw", new Uint8Array([145, 77, 43, 10, 72, 19, 37, 67, 236, 219, 24, 93, 26, 165, 91, 178]), "HKDF", false, ["deriveBits", "deriveKey"]); 35 key4 = await crypto.subtle.importKey("raw", new Uint8Array([146, 77, 43, 10, 72, 19, 37, 67, 236, 219, 24, 93, 26, 165, 91, 178]), "HKDF", false, ["deriveBits", "deriveKey"]); 19 36 20 37 const localStream = await navigator.mediaDevices.getUserMedia({audio: true}); … … 31 48 transform.setEncryptionKey(key2); 32 49 transform.setEncryptionKey(key3, 1000); 50 transform.setEncryptionKey(key4, BigInt('18446744073709551615')); 33 51 receiver = trackEvent.receiver; 34 52 receiver.transform = transform; … … 79 97 assert_true(await waitForCounterIncrease(receiver), "counter increase 2"); 80 98 }, "Add a new encryption key with key id"); 99 100 promise_test(async (test) => { 101 sender.transform.setEncryptionKey(key4, BigInt('18446744073709551613')); 102 103 if (!window.internals) 104 return; 105 106 assert_true(await waitForReceiverKeyId(receiver, 1000), "key id 3"); 107 assert_true(await waitForCounterIncrease(receiver), "counter increase 3"); 108 }, "Add a new encryption key with BigInt key id"); 81 109 </script> 82 110 </body> -
trunk/Source/WebCore/ChangeLog
r273156 r273158 1 2021-02-19 Youenn Fablet <youenn@apple.com> 2 3 Allow to use BigInt as key identifier 4 https://bugs.webkit.org/show_bug.cgi?id=222165 5 6 Reviewed by Darin Adler. 7 8 Allow to pass a BigInt as key id so as to use all of SFrame key ID 8 bytes. 9 A RangeError is thrown if BigInt is more than 64 bits. 10 11 Update the implementation to use a Vector instead of a map to keep the keys. 12 This allows to also use 0 and 2^64-1 values that HashMap reserves for its personal use. 13 14 Covered by updated test. 15 16 * Modules/mediastream/RTCRtpSFrameTransform.idl: 17 * Modules/mediastream/RTCRtpSFrameTransformer.cpp: 18 (WebCore::RTCRtpSFrameTransformer::setEncryptionKey): 19 (WebCore::RTCRtpSFrameTransformer::updateEncryptionKey): 20 (WebCore::RTCRtpSFrameTransformer::decryptFrame): 21 * Modules/mediastream/RTCRtpSFrameTransformer.h: 22 * Sources.txt: 23 * WebCore.xcodeproj/project.pbxproj: 24 * bindings/js/JSRTCRtpSFrameTransformCustom.cpp: Added. 25 (WebCore::JSRTCRtpSFrameTransform::setEncryptionKey): 26 1 27 2021-02-19 Fujii Hironori <Hironori.Fujii@sony.com> 2 28 -
trunk/Source/WebCore/Modules/mediastream/RTCRtpSFrameTransform.idl
r270883 r273158 51 51 [CallWith=ScriptExecutionContext] constructor(optional RTCRtpSFrameTransformOptions options); 52 52 53 Promise<undefined> setEncryptionKey(CryptoKey key, optional unsigned long longkeyID);53 [Custom] Promise<undefined> setEncryptionKey(CryptoKey key, optional any keyID); 54 54 // FIXME: Add support for missing methods. 55 55 // Promise<undefined> ratchetEncryptionKey(); -
trunk/Source/WebCore/Modules/mediastream/RTCRtpSFrameTransformer.cpp
r270641 r273158 150 150 ExceptionOr<void> RTCRtpSFrameTransformer::setEncryptionKey(const Vector<uint8_t>& rawKey, Optional<uint64_t> keyId) 151 151 { 152 if (keyId && *keyId == std::numeric_limits<uint64_t>::max())153 return Exception { TypeError, "Key ID is too big" };154 155 152 auto locker = holdLock(m_keyLock); 156 153 return updateEncryptionKey(rawKey, keyId, ShouldUpdateKeys::Yes); … … 159 156 ExceptionOr<void> RTCRtpSFrameTransformer::updateEncryptionKey(const Vector<uint8_t>& rawKey, Optional<uint64_t> keyId, ShouldUpdateKeys shouldUpdateKeys) 160 157 { 161 ASSERT(!keyId || *keyId != std::numeric_limits<uint64_t>::max());162 163 158 ASSERT(m_keyLock.isLocked()); 164 159 … … 177 172 return encryptionKeyResult.releaseException(); 178 173 179 if (!keyId) 180 keyId = m_keys.size(); 181 182 m_keyId = *keyId; 183 if (shouldUpdateKeys == ShouldUpdateKeys::Yes) 184 m_keys.set(*keyId + 1, rawKey); 174 if (shouldUpdateKeys == ShouldUpdateKeys::No) 175 m_keyId = *keyId; 176 else { 177 // FIXME: In case keyId is not set, it might be best to use the first non used ID. 178 if (!keyId) 179 keyId = m_keys.size(); 180 181 m_keyId = *keyId; 182 m_keys.append({ m_keyId, rawKey }); 183 } 185 184 186 185 m_saltKey = saltKeyResult.releaseReturnValue(); … … 231 230 232 231 if (header->keyId != m_keyId) { 233 if (header->keyId == std::numeric_limits<uint64_t>::max()) 232 auto position = m_keys.findMatching([keyId = header->keyId](auto& item) { return item.keyId == keyId; }); 233 if (position == notFound) 234 234 return Exception { DataError, "Key ID is unknown" }; 235 236 auto iterator = m_keys.find(header->keyId + 1); 237 if (iterator == m_keys.end()) 238 return Exception { DataError, "Key ID is unknown" }; 239 auto result = updateEncryptionKey(iterator->value, header->keyId, ShouldUpdateKeys::No); 235 auto result = updateEncryptionKey(m_keys[position].keyData, header->keyId, ShouldUpdateKeys::No); 240 236 if (result.hasException()) 241 237 return result.releaseException(); -
trunk/Source/WebCore/Modules/mediastream/RTCRtpSFrameTransformer.h
r270641 r273158 81 81 Vector<uint8_t> m_encryptionKey; 82 82 Vector<uint8_t> m_saltKey; 83 HashMap<uint64_t, Vector<uint8_t>> m_keys; 83 84 struct IdentifiedKey { 85 uint64_t keyId { 0 }; 86 Vector<uint8_t> keyData; 87 }; 88 Vector<IdentifiedKey> m_keys; 84 89 85 90 bool m_isEncrypting { false }; -
trunk/Source/WebCore/Sources.txt
r272925 r273158 595 595 bindings/js/JSPopStateEventCustom.cpp 596 596 bindings/js/JSPromiseRejectionEventCustom.cpp 597 bindings/js/JSRTCRtpSFrameTransformCustom.cpp 597 598 bindings/js/JSReadableStreamSourceCustom.cpp 598 599 bindings/js/JSRemoteDOMWindowBase.cpp -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r273143 r273158 7786 7786 417253A81354BBBC00360F2A /* MediaControlTextTrackContainerElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaControlTextTrackContainerElement.cpp; sourceTree = "<group>"; }; 7787 7787 417253A91354BBBC00360F2A /* MediaControlTextTrackContainerElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaControlTextTrackContainerElement.h; sourceTree = "<group>"; }; 7788 41733D7D25DFBFC500A136E5 /* JSRTCRtpSFrameTransformCustom.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSRTCRtpSFrameTransformCustom.cpp; sourceTree = "<group>"; }; 7788 7789 4174E91E2535DCD600FE4202 /* MediaStreamTrackAudioSourceProviderCocoa.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MediaStreamTrackAudioSourceProviderCocoa.h; sourceTree = "<group>"; }; 7789 7790 4174E9202535DCDD00FE4202 /* MediaStreamTrackAudioSourceProviderCocoa.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = MediaStreamTrackAudioSourceProviderCocoa.cpp; sourceTree = "<group>"; }; … … 27171 27172 BCE1C43F0D9830F4003B02F2 /* JSLocationCustom.cpp */, 27172 27173 4B6B5CBE216434FB00603817 /* JSPaintWorkletGlobalScopeCustom.cpp */, 27174 41733D7D25DFBFC500A136E5 /* JSRTCRtpSFrameTransformCustom.cpp */, 27173 27175 418C395D1C8F0AAB0051C8A3 /* JSReadableStreamSourceCustom.cpp */, 27174 27176 46BCBBBE2085005B00710638 /* JSRemoteDOMWindowCustom.cpp */,
Note: See TracChangeset
for help on using the changeset viewer.