Changeset 270532 in webkit
- Timestamp:
- Dec 8, 2020 2:36:49 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
r270527 r270532 1 2020-12-08 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 Truitt Savell <tsavell@apple.com> 2 12 -
trunk/Source/WebCore/ChangeLog
r270531 r270532 1 2020-12-08 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-08 Joonghun Park <jh718.park@samsung.com> 2 30 -
trunk/Source/WebCore/Modules/mediastream/RTCRtpSFrameTransform.cpp
r270518 r270532 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
r270518 r270532 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
r270518 r270532 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 auto locker = holdLock(m_keyLock); 156 return updateEncryptionKey(rawKey, keyId, ShouldUpdateKeys::Yes); 157 } 158 159 ExceptionOr<void> RTCRtpSFrameTransformer::updateEncryptionKey(const Vector<uint8_t>& rawKey, Optional<uint64_t> keyId, ShouldUpdateKeys shouldUpdateKeys) 160 { 161 ASSERT(!keyId || *keyId != std::numeric_limits<uint64_t>::max()); 162 163 ASSERT(m_keyLock.isLocked()); 164 152 165 auto saltKeyResult = computeSaltKey(rawKey); 153 166 if (saltKeyResult.hasException()) … … 164 177 return encryptionKeyResult.releaseException(); 165 178 166 auto locker = holdLock(m_keyLock); 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); 167 185 168 186 m_saltKey = saltKeyResult.releaseReturnValue(); 169 187 m_authenticationKey = authenticationKeyResult.releaseReturnValue(); 170 188 m_encryptionKey = encryptionKeyResult.releaseReturnValue(); 171 172 if (keyId)173 m_keyId = *keyId;174 189 175 190 updateAuthenticationSize(); … … 205 220 206 221 if (header->keyId != m_keyId) { 207 // FIXME: We should search for keys. 208 return Exception { NotSupportedError }; 222 if (header->keyId == std::numeric_limits<uint64_t>::max()) 223 return Exception { DataError, "Key ID is unknown" }; 224 225 auto iterator = m_keys.find(header->keyId + 1); 226 if (iterator == m_keys.end()) 227 return Exception { DataError, "Key ID is unknown" }; 228 auto result = updateEncryptionKey(iterator->value, header->keyId, ShouldUpdateKeys::No); 229 if (result.hasException()) 230 return result.releaseException(); 209 231 } 210 232 -
trunk/Source/WebCore/Modules/mediastream/RTCRtpSFrameTransformer.h
r270518 r270532 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
r270518 r270532 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
r270518 r270532 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
r270518 r270532 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.