|
15 | 15 | import org.webrtc.FrameCryptor; |
16 | 16 | import org.webrtc.FrameCryptorAlgorithm; |
17 | 17 | import org.webrtc.FrameCryptorFactory; |
| 18 | +import org.webrtc.FrameCryptorKeyDerivationAlgorithm; |
18 | 19 | import org.webrtc.FrameCryptorKeyProvider; |
19 | 20 | import org.webrtc.RtpReceiver; |
20 | 21 | import org.webrtc.RtpSender; |
@@ -92,6 +93,17 @@ private FrameCryptorAlgorithm frameCryptorAlgorithmFromInt(int algorithm) { |
92 | 93 | } |
93 | 94 | } |
94 | 95 |
|
| 96 | + private FrameCryptorKeyDerivationAlgorithm keyDerivationAlgorithmFromInt(int algorithm) { |
| 97 | + switch (algorithm) { |
| 98 | + case 0: |
| 99 | + return FrameCryptorKeyDerivationAlgorithm.PBKDF2; |
| 100 | + case 1: |
| 101 | + return FrameCryptorKeyDerivationAlgorithm.HKDF; |
| 102 | + default: |
| 103 | + return FrameCryptorKeyDerivationAlgorithm.PBKDF2; |
| 104 | + } |
| 105 | + } |
| 106 | + |
95 | 107 | public String frameCryptorFactoryCreateFrameCryptor(ReadableMap params) { |
96 | 108 | String keyProviderId = params.getString("keyProviderId"); |
97 | 109 | FrameCryptorKeyProvider keyProvider = keyProviders.get(keyProviderId); |
@@ -238,13 +250,17 @@ public String frameCryptorFactoryCreateKeyProvider(ReadableMap keyProviderOption |
238 | 250 | int keyRingSize = (int) keyProviderOptions.getInt("keyRingSize"); |
239 | 251 | boolean discardFrameWhenCryptorNotReady = |
240 | 252 | (boolean) keyProviderOptions.getBoolean("discardFrameWhenCryptorNotReady"); |
| 253 | + int keyDerivationAlgorithm = keyProviderOptions.hasKey("keyDerivationAlgorithm") |
| 254 | + ? keyProviderOptions.getInt("keyDerivationAlgorithm") |
| 255 | + : 0; |
241 | 256 | FrameCryptorKeyProvider keyProvider = FrameCryptorFactory.createFrameCryptorKeyProvider(sharedKey, |
242 | 257 | ratchetSalt, |
243 | 258 | ratchetWindowSize, |
244 | 259 | uncryptedMagicBytes, |
245 | 260 | failureTolerance, |
246 | 261 | keyRingSize, |
247 | | - discardFrameWhenCryptorNotReady); |
| 262 | + discardFrameWhenCryptorNotReady, |
| 263 | + keyDerivationAlgorithmFromInt(keyDerivationAlgorithm)); |
248 | 264 | keyProviders.put(keyProviderId, keyProvider); |
249 | 265 | return keyProviderId; |
250 | 266 | } |
|
0 commit comments