Changeset 270507 in webkit
- Timestamp:
- Dec 7, 2020 9:22:32 AM (20 months ago)
- Location:
- trunk
- Files:
-
- 2 added
- 9 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/webrtc/sframe-keys-expected.txt (added)
-
LayoutTests/webrtc/sframe-keys.html (added)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/Modules/mediastream/RTCRtpSFrameTransform.cpp (modified) (1 diff)
-
Source/WebCore/Modules/mediastream/RTCRtpSFrameTransform.h (modified) (1 diff)
-
Source/WebCore/Modules/mediastream/RTCRtpSFrameTransformer.cpp (modified) (3 diffs)
-
Source/WebCore/Modules/mediastream/RTCRtpSFrameTransformer.h (modified) (4 diffs)
-
Source/WebCore/testing/Internals.cpp (modified) (1 diff)
-
Source/WebCore/testing/Internals.h (modified) (1 diff)
-
Source/WebCore/testing/Internals.idl (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r270506 r270507 1 2020-12-07 Youenn Fablet <youenn@apple.com> 2 3 Allow RTCRtpSFrameTransform to handle multiple keys 4 https://bugs.webkit.org/show_bug.cgi?id=219598 5 6 Reviewed by Eric Carlson. 7 8 * webrtc/sframe-keys-expected.txt: Added. 9 * webrtc/sframe-keys.html: Added. 10 1 11 2020-12-07 Youenn Fablet <youenn@apple.com> 2 12 -
trunk/Source/WebCore/ChangeLog
r270506 r270507 1 2020-12-07 Youenn Fablet <youenn@apple.com> 2 3 Allow RTCRtpSFrameTransform to handle multiple keys 4 https://bugs.webkit.org/show_bug.cgi?id=219598 5 6 Reviewed by Eric Carlson. 7 8 Keep a map of ID to Key material when setEncryptionKey is called. 9 Use that map on decryption side to get key material from key ID. 10 Add internals API to validate key retrieval is done correctly. 11 If setEncryptionKey key ID is not set, we use the map size which allows to use 0, 1, 2 and so on... 12 13 Test: webrtc/sframe-keys.html 14 15 * Modules/mediastream/RTCRtpSFrameTransform.cpp: 16 (WebCore::RTCRtpSFrameTransform::keyIdForTesting const): 17 * Modules/mediastream/RTCRtpSFrameTransform.h: 18 * Modules/mediastream/RTCRtpSFrameTransformer.cpp: 19 (WebCore::RTCRtpSFrameTransformer::setEncryptionKey): 20 (WebCore::RTCRtpSFrameTransformer::updateEncryptionKey): 21 (WebCore::RTCRtpSFrameTransformer::decryptFrame): 22 * Modules/mediastream/RTCRtpSFrameTransformer.h: 23 (WebCore::RTCRtpSFrameTransformer::keyId const): 24 * testing/Internals.cpp: 25 (WebCore::Internals::sframeKeyId): 26 * testing/Internals.h: 27 * testing/Internals.idl: 28 1 29 2020-12-07 Youenn Fablet <youenn@apple.com> 2 30 -
trunk/Source/WebCore/Modules/mediastream/RTCRtpSFrameTransform.cpp
r270506 r270507 81 81 } 82 82 83 uint64_t RTCRtpSFrameTransform::keyIdForTesting() const 84 { 85 return m_transformer->keyId(); 86 } 87 83 88 bool RTCRtpSFrameTransform::isAttached() const 84 89 { -
trunk/Source/WebCore/Modules/mediastream/RTCRtpSFrameTransform.h
r270506 r270507 61 61 62 62 WEBCORE_EXPORT uint64_t counterForTesting() const; 63 WEBCORE_EXPORT uint64_t keyIdForTesting() const; 63 64 64 65 ExceptionOr<RefPtr<ReadableStream>> readable(); -
trunk/Source/WebCore/Modules/mediastream/RTCRtpSFrameTransformer.cpp
r270506 r270507 150 150 ExceptionOr<void> RTCRtpSFrameTransformer::setEncryptionKey(const Vector<uint8_t>& rawKey, Optional<uint64_t> keyId) 151 151 { 152 auto locker = holdLock(m_keyLock); 153 return updateEncryptionKey(rawKey, keyId, ShouldUpdateKeys::Yes); 154 } 155 156 ExceptionOr<void> RTCRtpSFrameTransformer::updateEncryptionKey(const Vector<uint8_t>& rawKey, Optional<uint64_t> keyId, ShouldUpdateKeys shouldUpdateKeys) 157 { 158 ASSERT(m_keyLock.isLocked()); 159 152 160 auto saltKeyResult = computeSaltKey(rawKey); 153 161 if (saltKeyResult.hasException()) … … 164 172 return encryptionKeyResult.releaseException(); 165 173 166 auto locker = holdLock(m_keyLock); 174 if (!keyId) 175 keyId = m_keys.size(); 176 177 m_keyId = *keyId; 178 if (shouldUpdateKeys == ShouldUpdateKeys::Yes) 179 m_keys.set(*keyId, rawKey); 167 180 168 181 m_saltKey = saltKeyResult.releaseReturnValue(); 169 182 m_authenticationKey = authenticationKeyResult.releaseReturnValue(); 170 183 m_encryptionKey = encryptionKeyResult.releaseReturnValue(); 171 172 if (keyId)173 m_keyId = *keyId;174 184 175 185 updateAuthenticationSize(); … … 205 215 206 216 if (header->keyId != m_keyId) { 207 // FIXME: We should search for keys. 208 return Exception { NotSupportedError }; 217 auto iterator = m_keys.find(header->keyId); 218 if (iterator == m_keys.end()) 219 return Exception { DataError, "Key ID is unknown" }; 220 auto result = updateEncryptionKey(iterator->value, iterator->key, ShouldUpdateKeys::No); 221 if (result.hasException()) 222 return result.releaseException(); 209 223 } 210 224 -
trunk/Source/WebCore/Modules/mediastream/RTCRtpSFrameTransformer.h
r270506 r270507 29 29 30 30 #include "ExceptionOr.h" 31 #include <wtf/HashMap.h> 31 32 #include <wtf/Lock.h> 32 33 #include <wtf/ThreadSafeRefCounted.h> … … 53 54 const Vector<uint8_t>& saltKey() const { return m_saltKey; } 54 55 56 uint64_t keyId() const { return m_keyId; } 55 57 uint64_t counter() const { return m_counter; } 56 58 void setCounter(uint64_t counter) { m_counter = counter; } … … 61 63 ExceptionOr<Vector<uint8_t>> decryptFrame(const uint8_t*, size_t); 62 64 ExceptionOr<Vector<uint8_t>> encryptFrame(const uint8_t*, size_t); 65 66 enum class ShouldUpdateKeys { No, Yes }; 67 ExceptionOr<void> updateEncryptionKey(const Vector<uint8_t>& rawKey, Optional<uint64_t>, ShouldUpdateKeys = ShouldUpdateKeys::Yes); 63 68 64 69 ExceptionOr<Vector<uint8_t>> computeSaltKey(const Vector<uint8_t>&); … … 76 81 Vector<uint8_t> m_encryptionKey; 77 82 Vector<uint8_t> m_saltKey; 83 HashMap<uint64_t, Vector<uint8_t>> m_keys; 78 84 79 85 bool m_isEncrypting { false }; -
trunk/Source/WebCore/testing/Internals.cpp
r270256 r270507 1582 1582 } 1583 1583 1584 uint64_t Internals::sframeKeyId(const RTCRtpSFrameTransform& transform) 1585 { 1586 return transform.keyIdForTesting(); 1587 } 1588 1584 1589 void Internals::setEnableWebRTCEncryption(bool value) 1585 1590 { -
trunk/Source/WebCore/testing/Internals.h
r270256 r270507 611 611 void setWebRTCVP9VTBSupport(bool); 612 612 uint64_t sframeCounter(const RTCRtpSFrameTransform&); 613 uint64_t sframeKeyId(const RTCRtpSFrameTransform&); 613 614 void setEnableWebRTCEncryption(bool); 614 615 void setUseDTLS10(bool); -
trunk/Source/WebCore/testing/Internals.idl
r270256 r270507 804 804 [Conditional=WEB_RTC] undefined setWebRTCVP9VTBSupport(boolean allowed); 805 805 [Conditional=WEB_RTC] unsigned long long sframeCounter(RTCRtpSFrameTransform transform); 806 [Conditional=WEB_RTC] unsigned long long sframeKeyId(RTCRtpSFrameTransform transform); 806 807 807 808 [Conditional=MEDIA_STREAM] undefined setMockAudioTrackChannelNumber(MediaStreamTrack track, unsigned short count);
Note: See TracChangeset
for help on using the changeset viewer.