diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2014-08-22 18:22:13 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2014-08-22 18:22:13 +0700 |
commit | 91443f862f00e62fe69a28e4afee7c00c1c264bd (patch) | |
tree | bd81f549a40d72ae82ecaddf6714c9285ca0de87 /crypto/src/crypto/tls/UseSrtpData.cs | |
parent | More TLS porting from Java API (diff) | |
download | BouncyCastle.NET-ed25519-91443f862f00e62fe69a28e4afee7c00c1c264bd.tar.xz |
More TLS porting from Java API
Diffstat (limited to '')
-rw-r--r-- | crypto/src/crypto/tls/UseSrtpData.cs | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/crypto/src/crypto/tls/UseSrtpData.cs b/crypto/src/crypto/tls/UseSrtpData.cs new file mode 100644 index 000000000..fe8f8accb --- /dev/null +++ b/crypto/src/crypto/tls/UseSrtpData.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections; +using System.IO; + +namespace Org.BouncyCastle.Crypto.Tls +{ + /** + * RFC 5764 4.1.1 + */ + public class UseSrtpData + { + protected readonly int[] mProtectionProfiles; + protected readonly byte[] mMki; + + /** + * @param protectionProfiles see {@link SrtpProtectionProfile} for valid constants. + * @param mki valid lengths from 0 to 255. + */ + public UseSrtpData(int[] protectionProfiles, byte[] mki) + { + if (protectionProfiles == null || protectionProfiles.Length < 1 + || protectionProfiles.Length >= (1 << 15)) + { + throw new ArgumentException("must have length from 1 to (2^15 - 1)", "protectionProfiles"); + } + + if (mki == null) + { + mki = TlsUtilities.EmptyBytes; + } + else if (mki.Length > 255) + { + throw new ArgumentException("cannot be longer than 255 bytes", "mki"); + } + + this.mProtectionProfiles = protectionProfiles; + this.mMki = mki; + } + + /** + * @return see {@link SrtpProtectionProfile} for valid constants. + */ + public virtual int[] ProtectionProfiles + { + get { return mProtectionProfiles; } + } + + /** + * @return valid lengths from 0 to 255. + */ + public virtual byte[] Mki + { + get { return mMki; } + } + } +} |