webrtc_m130/sdk/android/api/org/webrtc/CryptoOptions.java

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

148 lines
4.9 KiB
Java
Raw Permalink Normal View History

/*
* Copyright 2018 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
package org.webrtc;
/**
* CryptoOptions defines advanced cryptographic settings for native WebRTC.
* These settings must be passed into RTCConfiguration. WebRTC is secur by
* default and you should not need to set any of these options unless you are
* specifically looking for an additional crypto feature such as AES_GCM
* support. This class is the Java binding of native api/crypto/cryptooptions.h
*/
public final class CryptoOptions {
/**
* SRTP Related Peer Connection Options.
*/
Roll chromium_revision ccf648df91..aa68dfe997 (1365600:1366639) Change log: https://chromium.googlesource.com/chromium/src/+log/ccf648df91..aa68dfe997 Full diff: https://chromium.googlesource.com/chromium/src/+/ccf648df91..aa68dfe997 Changed dependencies * reclient_version: re_client_version:0.164.0.76480e37-gomaip..re_client_version:0.168.0.c46e68bc-gomaip * src/base: https://chromium.googlesource.com/chromium/src/base/+log/006d78d70b..68128fa0f0 * src/build: https://chromium.googlesource.com/chromium/src/build/+log/f2790bfa32..6d08a23c99 * src/buildtools: https://chromium.googlesource.com/chromium/src/buildtools/+log/0a905dcb6d..754803453c * src/buildtools/reclient: re_client_version:0.164.0.76480e37-gomaip..re_client_version:0.168.0.c46e68bc-gomaip * src/ios: https://chromium.googlesource.com/chromium/src/ios/+log/26dfb6e15c..53b28a3235 * src/testing: https://chromium.googlesource.com/chromium/src/testing/+log/3ef5641e1f..b6f87cfcfb * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/c8056c18ac..512db14abf * src/third_party/android_build_tools/error_prone/cipd: 15eqqvDTRtPu1Sy8b4WuOiqkivE9ibCjSdoOtqJYyBEC..hUxlP8GvC1xhmZ6r9xjYau2laPlzHbs_P2emx4ZL4jgC * src/third_party/android_build_tools/manifest_merger/cipd: p2c9mSgfF-HErc8CM-jOFuuMbaMK-POsiqbeG5plk2cC..qI7pOwGO6rjfncAZKTugRAPn9Qs_MdwCWpzfRuiBgGMC * src/third_party/androidx/cipd: yhwW_7P0l18P6ykZSqwXqx6HFyhPIcUGNcebIIppU-IC..k1wif7sS51pJGSFGN7FAeGWDorxgPart9E1f383TQL4C * src/third_party/boringssl/src: https://boringssl.googlesource.com/boringssl.git/+log/fa0214602c..905c3903fd * src/third_party/depot_tools: https://chromium.googlesource.com/chromium/tools/depot_tools.git/+log/c109945e72..0ab52232ff * src/third_party/kotlin_stdlib/cipd: 5lJOPRAms_Yty4OyjHlXdB_6UFqzeGHM6YuuuUZ3P9MC..zgrGgJIQ7F4H3GT_uf41Ya6Pw7BBQlC99_kJVEwfEk8C * src/third_party/libc++/src: https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libcxx.git/+log/f114473071..283f1aa1ad * src/third_party/libc++abi/src: https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libcxxabi.git/+log/829f51051c..975ef56df0 * src/third_party/libvpx/source/libvpx: https://chromium.googlesource.com/webm/libvpx.git/+log/09b3d5fc5a..906334ac1d * src/third_party/libyuv: https://chromium.googlesource.com/libyuv/libyuv.git/+log/77f3acade4..a8e59d2074 * src/third_party/perfetto: https://android.googlesource.com/platform/external/perfetto.git/+log/5361e5909e..48c5df53f4 * src/third_party/r8/d8/cipd: yEomA-IPmb_JtuiEvwgtxRHtSEaICkDY1sDko_rQGO0C..3KCj5eRYCvGGYs5i90pRaeihkzsqgUGc4OkICT8AOlIC * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/8c5814c8d2..3a202879c1 * src/tools/luci-go: git_revision:78b3b3ca47e64b3280a5dd5b83c23ce89f04d328..git_revision:ff7417442432e6669b74c02c63d61834f865aa77 * src/tools/luci-go: git_revision:78b3b3ca47e64b3280a5dd5b83c23ce89f04d328..git_revision:ff7417442432e6669b74c02c63d61834f865aa77 DEPS diff: https://chromium.googlesource.com/chromium/src/+/ccf648df91..aa68dfe997/DEPS No update to Clang. BUG=None Change-Id: Ib8b14ce25ae98d98f648e31dc64197c3578b1c92 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/365261 Reviewed-by: Harald Alvestrand <hta@webrtc.org> Commit-Queue: Jeremy Leconte <jleconte@webrtc.org> Cr-Commit-Position: refs/heads/main@{#43212}
2024-10-10 09:05:45 +02:00
@SuppressWarnings("ClassCanBeStatic")
public final class Srtp {
/**
* Enable GCM crypto suites from RFC 7714 for SRTP. GCM will only be used
* if both sides enable it
*/
private final boolean enableGcmCryptoSuites;
/**
* If set to true, the (potentially insecure) crypto cipher
* kSrtpAes128CmSha1_32 will be included in the list of supported ciphers
* during negotiation. It will only be used if both peers support it and no
* other ciphers get preferred.
*/
private final boolean enableAes128Sha1_32CryptoCipher;
/**
* If set to true, encrypted RTP header extensions as defined in RFC 6904
* will be negotiated. They will only be used if both peers support them.
*/
private final boolean enableEncryptedRtpHeaderExtensions;
private Srtp(boolean enableGcmCryptoSuites, boolean enableAes128Sha1_32CryptoCipher,
boolean enableEncryptedRtpHeaderExtensions) {
this.enableGcmCryptoSuites = enableGcmCryptoSuites;
this.enableAes128Sha1_32CryptoCipher = enableAes128Sha1_32CryptoCipher;
this.enableEncryptedRtpHeaderExtensions = enableEncryptedRtpHeaderExtensions;
}
@CalledByNative("Srtp")
public boolean getEnableGcmCryptoSuites() {
return enableGcmCryptoSuites;
}
@CalledByNative("Srtp")
public boolean getEnableAes128Sha1_32CryptoCipher() {
return enableAes128Sha1_32CryptoCipher;
}
@CalledByNative("Srtp")
public boolean getEnableEncryptedRtpHeaderExtensions() {
return enableEncryptedRtpHeaderExtensions;
}
}
/**
* Options to be used when the FrameEncryptor / FrameDecryptor APIs are used.
*/
Roll chromium_revision ccf648df91..aa68dfe997 (1365600:1366639) Change log: https://chromium.googlesource.com/chromium/src/+log/ccf648df91..aa68dfe997 Full diff: https://chromium.googlesource.com/chromium/src/+/ccf648df91..aa68dfe997 Changed dependencies * reclient_version: re_client_version:0.164.0.76480e37-gomaip..re_client_version:0.168.0.c46e68bc-gomaip * src/base: https://chromium.googlesource.com/chromium/src/base/+log/006d78d70b..68128fa0f0 * src/build: https://chromium.googlesource.com/chromium/src/build/+log/f2790bfa32..6d08a23c99 * src/buildtools: https://chromium.googlesource.com/chromium/src/buildtools/+log/0a905dcb6d..754803453c * src/buildtools/reclient: re_client_version:0.164.0.76480e37-gomaip..re_client_version:0.168.0.c46e68bc-gomaip * src/ios: https://chromium.googlesource.com/chromium/src/ios/+log/26dfb6e15c..53b28a3235 * src/testing: https://chromium.googlesource.com/chromium/src/testing/+log/3ef5641e1f..b6f87cfcfb * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/c8056c18ac..512db14abf * src/third_party/android_build_tools/error_prone/cipd: 15eqqvDTRtPu1Sy8b4WuOiqkivE9ibCjSdoOtqJYyBEC..hUxlP8GvC1xhmZ6r9xjYau2laPlzHbs_P2emx4ZL4jgC * src/third_party/android_build_tools/manifest_merger/cipd: p2c9mSgfF-HErc8CM-jOFuuMbaMK-POsiqbeG5plk2cC..qI7pOwGO6rjfncAZKTugRAPn9Qs_MdwCWpzfRuiBgGMC * src/third_party/androidx/cipd: yhwW_7P0l18P6ykZSqwXqx6HFyhPIcUGNcebIIppU-IC..k1wif7sS51pJGSFGN7FAeGWDorxgPart9E1f383TQL4C * src/third_party/boringssl/src: https://boringssl.googlesource.com/boringssl.git/+log/fa0214602c..905c3903fd * src/third_party/depot_tools: https://chromium.googlesource.com/chromium/tools/depot_tools.git/+log/c109945e72..0ab52232ff * src/third_party/kotlin_stdlib/cipd: 5lJOPRAms_Yty4OyjHlXdB_6UFqzeGHM6YuuuUZ3P9MC..zgrGgJIQ7F4H3GT_uf41Ya6Pw7BBQlC99_kJVEwfEk8C * src/third_party/libc++/src: https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libcxx.git/+log/f114473071..283f1aa1ad * src/third_party/libc++abi/src: https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libcxxabi.git/+log/829f51051c..975ef56df0 * src/third_party/libvpx/source/libvpx: https://chromium.googlesource.com/webm/libvpx.git/+log/09b3d5fc5a..906334ac1d * src/third_party/libyuv: https://chromium.googlesource.com/libyuv/libyuv.git/+log/77f3acade4..a8e59d2074 * src/third_party/perfetto: https://android.googlesource.com/platform/external/perfetto.git/+log/5361e5909e..48c5df53f4 * src/third_party/r8/d8/cipd: yEomA-IPmb_JtuiEvwgtxRHtSEaICkDY1sDko_rQGO0C..3KCj5eRYCvGGYs5i90pRaeihkzsqgUGc4OkICT8AOlIC * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/8c5814c8d2..3a202879c1 * src/tools/luci-go: git_revision:78b3b3ca47e64b3280a5dd5b83c23ce89f04d328..git_revision:ff7417442432e6669b74c02c63d61834f865aa77 * src/tools/luci-go: git_revision:78b3b3ca47e64b3280a5dd5b83c23ce89f04d328..git_revision:ff7417442432e6669b74c02c63d61834f865aa77 DEPS diff: https://chromium.googlesource.com/chromium/src/+/ccf648df91..aa68dfe997/DEPS No update to Clang. BUG=None Change-Id: Ib8b14ce25ae98d98f648e31dc64197c3578b1c92 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/365261 Reviewed-by: Harald Alvestrand <hta@webrtc.org> Commit-Queue: Jeremy Leconte <jleconte@webrtc.org> Cr-Commit-Position: refs/heads/main@{#43212}
2024-10-10 09:05:45 +02:00
@SuppressWarnings("ClassCanBeStatic")
public final class SFrame {
/**
* If set all RtpSenders must have an FrameEncryptor attached to them before
* they are allowed to send packets. All RtpReceivers must have a
* FrameDecryptor attached to them before they are able to receive packets.
*/
private final boolean requireFrameEncryption;
private SFrame(boolean requireFrameEncryption) {
this.requireFrameEncryption = requireFrameEncryption;
}
@CalledByNative("SFrame")
public boolean getRequireFrameEncryption() {
return requireFrameEncryption;
}
}
private final Srtp srtp;
private final SFrame sframe;
private CryptoOptions(boolean enableGcmCryptoSuites, boolean enableAes128Sha1_32CryptoCipher,
boolean enableEncryptedRtpHeaderExtensions, boolean requireFrameEncryption) {
this.srtp = new Srtp(
enableGcmCryptoSuites, enableAes128Sha1_32CryptoCipher, enableEncryptedRtpHeaderExtensions);
this.sframe = new SFrame(requireFrameEncryption);
}
public static Builder builder() {
return new Builder();
}
@CalledByNative
public Srtp getSrtp() {
return srtp;
}
@CalledByNative
public SFrame getSFrame() {
return sframe;
}
public static class Builder {
private boolean enableGcmCryptoSuites;
private boolean enableAes128Sha1_32CryptoCipher;
private boolean enableEncryptedRtpHeaderExtensions;
private boolean requireFrameEncryption;
private Builder() {}
public Builder setEnableGcmCryptoSuites(boolean enableGcmCryptoSuites) {
this.enableGcmCryptoSuites = enableGcmCryptoSuites;
return this;
}
public Builder setEnableAes128Sha1_32CryptoCipher(boolean enableAes128Sha1_32CryptoCipher) {
this.enableAes128Sha1_32CryptoCipher = enableAes128Sha1_32CryptoCipher;
return this;
}
public Builder setEnableEncryptedRtpHeaderExtensions(
boolean enableEncryptedRtpHeaderExtensions) {
this.enableEncryptedRtpHeaderExtensions = enableEncryptedRtpHeaderExtensions;
return this;
}
public Builder setRequireFrameEncryption(boolean requireFrameEncryption) {
this.requireFrameEncryption = requireFrameEncryption;
return this;
}
public CryptoOptions createCryptoOptions() {
return new CryptoOptions(enableGcmCryptoSuites, enableAes128Sha1_32CryptoCipher,
enableEncryptedRtpHeaderExtensions, requireFrameEncryption);
}
}
}