public static byte[] createUseSRTPExtension(UseSRTPData useSRTPData) throws IOException { if (useSRTPData == null) { throw new IllegalArgumentException("'useSRTPData' cannot be null"); } ByteArrayOutputStream buf = new ByteArrayOutputStream(); // SRTPProtectionProfiles TlsUtils.writeUint16ArrayWithUint16Length(useSRTPData.getProtectionProfiles(), buf); // srtp_mki TlsUtils.writeOpaque8(useSRTPData.getMki(), buf); return buf.toByteArray(); }
public static byte[] createUseSRTPExtension(UseSRTPData useSRTPData) throws IOException { if (useSRTPData == null) { throw new IllegalArgumentException("'useSRTPData' cannot be null"); } ByteArrayOutputStream buf = new ByteArrayOutputStream(); // SRTPProtectionProfiles TlsUtils.writeUint16ArrayWithUint16Length(useSRTPData.getProtectionProfiles(), buf); // srtp_mki TlsUtils.writeOpaque8(useSRTPData.getMki(), buf); return buf.toByteArray(); }
SRTPParameters srtpParams = SRTPParameters.getSrtpParametersForProfile(serverSrtpData.getProtectionProfiles()[0]); final int keyLen = srtpParams.getCipherKeyLength(); final int saltLen = srtpParams.getCipherSaltLength();
SRTPParameters srtpParams = SRTPParameters.getSrtpParametersForProfile(serverSrtpData.getProtectionProfiles()[0]); final int keyLen = srtpParams.getCipherKeyLength(); final int saltLen = srtpParams.getCipherSaltLength();
@SuppressWarnings("rawtypes") @Override public void processClientExtensions(Hashtable newClientExtensions) throws IOException { super.processClientExtensions(newClientExtensions); // set to some reasonable default value int chosenProfile = SRTPProtectionProfile.SRTP_AES128_CM_HMAC_SHA1_80; UseSRTPData clientSrtpData = TlsSRTPUtils.getUseSRTPExtension(newClientExtensions); for (int profile : clientSrtpData.getProtectionProfiles()) { switch (profile) { case SRTPProtectionProfile.SRTP_AES128_CM_HMAC_SHA1_32: case SRTPProtectionProfile.SRTP_AES128_CM_HMAC_SHA1_80: case SRTPProtectionProfile.SRTP_NULL_HMAC_SHA1_32: case SRTPProtectionProfile.SRTP_NULL_HMAC_SHA1_80: chosenProfile = profile; break; default: } } // server chooses a mutually supported SRTP protection profile // http://tools.ietf.org/html/draft-ietf-avt-dtls-srtp-07#section-4.1.2 int[] protectionProfiles = { chosenProfile }; // server agrees to use the MKI offered by the client serverSrtpData = new UseSRTPData(protectionProfiles, clientSrtpData.getMki()); }
@SuppressWarnings("rawtypes") @Override public void processClientExtensions(Hashtable newClientExtensions) throws IOException { super.processClientExtensions(newClientExtensions); // set to some reasonable default value int chosenProfile = SRTPProtectionProfile.SRTP_AES128_CM_HMAC_SHA1_80; UseSRTPData clientSrtpData = TlsSRTPUtils.getUseSRTPExtension(newClientExtensions); for (int profile : clientSrtpData.getProtectionProfiles()) { switch (profile) { case SRTPProtectionProfile.SRTP_AES128_CM_HMAC_SHA1_32: case SRTPProtectionProfile.SRTP_AES128_CM_HMAC_SHA1_80: case SRTPProtectionProfile.SRTP_NULL_HMAC_SHA1_32: case SRTPProtectionProfile.SRTP_NULL_HMAC_SHA1_80: chosenProfile = profile; break; default: } } // server chooses a mutually supported SRTP protection profile // http://tools.ietf.org/html/draft-ietf-avt-dtls-srtp-07#section-4.1.2 int[] protectionProfiles = { chosenProfile }; // server agrees to use the MKI offered by the client serverSrtpData = new UseSRTPData(protectionProfiles, clientSrtpData.getMki()); }
useSRTPData.getProtectionProfiles());
int[] protectionProfiles = useSRTPData.getProtectionProfiles(); int chosenProtectionProfile = (protectionProfiles.length == 1)
int chosenProtectionProfile = DtlsControlImpl.chooseSRTPProtectionProfile( useSRTPData.getProtectionProfiles());