123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253 |
- #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
- using System;
- using System.Collections;
- using System.IO;
- using System.Text;
- using Org.BouncyCastle.Asn1;
- using Org.BouncyCastle.Asn1.Nist;
- using Org.BouncyCastle.Asn1.Pkcs;
- using Org.BouncyCastle.Asn1.X509;
- using Org.BouncyCastle.Crypto.Digests;
- using Org.BouncyCastle.Crypto.Macs;
- using Org.BouncyCastle.Crypto.Parameters;
- using Org.BouncyCastle.Security;
- using Org.BouncyCastle.Utilities;
- using Org.BouncyCastle.Utilities.Date;
- using Org.BouncyCastle.Utilities.IO;
- namespace Org.BouncyCastle.Crypto.Tls
- {
- /// <remarks>Some helper functions for MicroTLS.</remarks>
- public abstract class TlsUtilities
- {
- public static readonly byte[] EmptyBytes = new byte[0];
- public static readonly short[] EmptyShorts = new short[0];
- public static readonly int[] EmptyInts = new int[0];
- public static readonly long[] EmptyLongs = new long[0];
- public static void CheckUint8(int i)
- {
- if (!IsValidUint8(i))
- throw new TlsFatalAlert(AlertDescription.internal_error);
- }
- public static void CheckUint8(long i)
- {
- if (!IsValidUint8(i))
- throw new TlsFatalAlert(AlertDescription.internal_error);
- }
- public static void CheckUint16(int i)
- {
- if (!IsValidUint16(i))
- throw new TlsFatalAlert(AlertDescription.internal_error);
- }
- public static void CheckUint16(long i)
- {
- if (!IsValidUint16(i))
- throw new TlsFatalAlert(AlertDescription.internal_error);
- }
- public static void CheckUint24(int i)
- {
- if (!IsValidUint24(i))
- throw new TlsFatalAlert(AlertDescription.internal_error);
- }
- public static void CheckUint24(long i)
- {
- if (!IsValidUint24(i))
- throw new TlsFatalAlert(AlertDescription.internal_error);
- }
- public static void CheckUint32(long i)
- {
- if (!IsValidUint32(i))
- throw new TlsFatalAlert(AlertDescription.internal_error);
- }
- public static void CheckUint48(long i)
- {
- if (!IsValidUint48(i))
- throw new TlsFatalAlert(AlertDescription.internal_error);
- }
- public static void CheckUint64(long i)
- {
- if (!IsValidUint64(i))
- throw new TlsFatalAlert(AlertDescription.internal_error);
- }
- public static bool IsValidUint8(int i)
- {
- return (i & 0xFF) == i;
- }
- public static bool IsValidUint8(long i)
- {
- return (i & 0xFFL) == i;
- }
- public static bool IsValidUint16(int i)
- {
- return (i & 0xFFFF) == i;
- }
- public static bool IsValidUint16(long i)
- {
- return (i & 0xFFFFL) == i;
- }
- public static bool IsValidUint24(int i)
- {
- return (i & 0xFFFFFF) == i;
- }
- public static bool IsValidUint24(long i)
- {
- return (i & 0xFFFFFFL) == i;
- }
- public static bool IsValidUint32(long i)
- {
- return (i & 0xFFFFFFFFL) == i;
- }
- public static bool IsValidUint48(long i)
- {
- return (i & 0xFFFFFFFFFFFFL) == i;
- }
- public static bool IsValidUint64(long i)
- {
- return true;
- }
- public static bool IsSsl(TlsContext context)
- {
- return context.ServerVersion.IsSsl;
- }
- public static bool IsTlsV11(ProtocolVersion version)
- {
- return ProtocolVersion.TLSv11.IsEqualOrEarlierVersionOf(version.GetEquivalentTLSVersion());
- }
- public static bool IsTlsV11(TlsContext context)
- {
- return IsTlsV11(context.ServerVersion);
- }
- public static bool IsTlsV12(ProtocolVersion version)
- {
- return ProtocolVersion.TLSv12.IsEqualOrEarlierVersionOf(version.GetEquivalentTLSVersion());
- }
- public static bool IsTlsV12(TlsContext context)
- {
- return IsTlsV12(context.ServerVersion);
- }
- public static void WriteUint8(byte i, Stream output)
- {
- output.WriteByte(i);
- }
- public static void WriteUint8(byte i, byte[] buf, int offset)
- {
- buf[offset] = i;
- }
- public static void WriteUint16(int i, Stream output)
- {
- output.WriteByte((byte)(i >> 8));
- output.WriteByte((byte)i);
- }
- public static void WriteUint16(int i, byte[] buf, int offset)
- {
- buf[offset] = (byte)(i >> 8);
- buf[offset + 1] = (byte)i;
- }
- public static void WriteUint24(int i, Stream output)
- {
- output.WriteByte((byte)(i >> 16));
- output.WriteByte((byte)(i >> 8));
- output.WriteByte((byte)i);
- }
- public static void WriteUint24(int i, byte[] buf, int offset)
- {
- buf[offset] = (byte)(i >> 16);
- buf[offset + 1] = (byte)(i >> 8);
- buf[offset + 2] = (byte)i;
- }
- public static void WriteUint32(long i, Stream output)
- {
- output.WriteByte((byte)(i >> 24));
- output.WriteByte((byte)(i >> 16));
- output.WriteByte((byte)(i >> 8));
- output.WriteByte((byte)i);
- }
- public static void WriteUint32(long i, byte[] buf, int offset)
- {
- buf[offset] = (byte)(i >> 24);
- buf[offset + 1] = (byte)(i >> 16);
- buf[offset + 2] = (byte)(i >> 8);
- buf[offset + 3] = (byte)i;
- }
- public static void WriteUint48(long i, Stream output)
- {
- output.WriteByte((byte)(i >> 40));
- output.WriteByte((byte)(i >> 32));
- output.WriteByte((byte)(i >> 24));
- output.WriteByte((byte)(i >> 16));
- output.WriteByte((byte)(i >> 8));
- output.WriteByte((byte)i);
- }
- public static void WriteUint48(long i, byte[] buf, int offset)
- {
- buf[offset] = (byte)(i >> 40);
- buf[offset + 1] = (byte)(i >> 32);
- buf[offset + 2] = (byte)(i >> 24);
- buf[offset + 3] = (byte)(i >> 16);
- buf[offset + 4] = (byte)(i >> 8);
- buf[offset + 5] = (byte)i;
- }
- public static void WriteUint64(long i, Stream output)
- {
- output.WriteByte((byte)(i >> 56));
- output.WriteByte((byte)(i >> 48));
- output.WriteByte((byte)(i >> 40));
- output.WriteByte((byte)(i >> 32));
- output.WriteByte((byte)(i >> 24));
- output.WriteByte((byte)(i >> 16));
- output.WriteByte((byte)(i >> 8));
- output.WriteByte((byte)i);
- }
- public static void WriteUint64(long i, byte[] buf, int offset)
- {
- buf[offset] = (byte)(i >> 56);
- buf[offset + 1] = (byte)(i >> 48);
- buf[offset + 2] = (byte)(i >> 40);
- buf[offset + 3] = (byte)(i >> 32);
- buf[offset + 4] = (byte)(i >> 24);
- buf[offset + 5] = (byte)(i >> 16);
- buf[offset + 6] = (byte)(i >> 8);
- buf[offset + 7] = (byte)i;
- }
- public static void WriteOpaque8(byte[] buf, Stream output)
- {
- WriteUint8((byte)buf.Length, output);
- output.Write(buf, 0, buf.Length);
- }
- public static void WriteOpaque16(byte[] buf, Stream output)
- {
- WriteUint16(buf.Length, output);
- output.Write(buf, 0, buf.Length);
- }
- public static void WriteOpaque24(byte[] buf, Stream output)
- {
- WriteUint24(buf.Length, output);
- output.Write(buf, 0, buf.Length);
- }
- public static void WriteUint8Array(byte[] uints, Stream output)
- {
- output.Write(uints, 0, uints.Length);
- }
- public static void WriteUint8Array(byte[] uints, byte[] buf, int offset)
- {
- for (int i = 0; i < uints.Length; ++i)
- {
- WriteUint8(uints[i], buf, offset);
- ++offset;
- }
- }
- public static void WriteUint8ArrayWithUint8Length(byte[] uints, Stream output)
- {
- CheckUint8(uints.Length);
- WriteUint8((byte)uints.Length, output);
- WriteUint8Array(uints, output);
- }
- public static void WriteUint8ArrayWithUint8Length(byte[] uints, byte[] buf, int offset)
- {
- CheckUint8(uints.Length);
- WriteUint8((byte)uints.Length, buf, offset);
- WriteUint8Array(uints, buf, offset + 1);
- }
- public static void WriteUint16Array(int[] uints, Stream output)
- {
- for (int i = 0; i < uints.Length; ++i)
- {
- WriteUint16(uints[i], output);
- }
- }
- public static void WriteUint16Array(int[] uints, byte[] buf, int offset)
- {
- for (int i = 0; i < uints.Length; ++i)
- {
- WriteUint16(uints[i], buf, offset);
- offset += 2;
- }
- }
- public static void WriteUint16ArrayWithUint16Length(int[] uints, Stream output)
- {
- int length = 2 * uints.Length;
- CheckUint16(length);
- WriteUint16(length, output);
- WriteUint16Array(uints, output);
- }
- public static void WriteUint16ArrayWithUint16Length(int[] uints, byte[] buf, int offset)
- {
- int length = 2 * uints.Length;
- CheckUint16(length);
- WriteUint16(length, buf, offset);
- WriteUint16Array(uints, buf, offset + 2);
- }
- public static byte[] EncodeOpaque8(byte[] buf)
- {
- CheckUint8(buf.Length);
- return Arrays.Prepend(buf, (byte)buf.Length);
- }
- public static byte[] EncodeUint8ArrayWithUint8Length(byte[] uints)
- {
- byte[] result = new byte[1 + uints.Length];
- WriteUint8ArrayWithUint8Length(uints, result, 0);
- return result;
- }
- public static byte[] EncodeUint16ArrayWithUint16Length(int[] uints)
- {
- int length = 2 * uints.Length;
- byte[] result = new byte[2 + length];
- WriteUint16ArrayWithUint16Length(uints, result, 0);
- return result;
- }
- public static byte ReadUint8(Stream input)
- {
- int i = input.ReadByte();
- if (i < 0)
- throw new EndOfStreamException();
- return (byte)i;
- }
- public static byte ReadUint8(byte[] buf, int offset)
- {
- return buf[offset];
- }
- public static int ReadUint16(Stream input)
- {
- int i1 = input.ReadByte();
- int i2 = input.ReadByte();
- if (i2 < 0)
- throw new EndOfStreamException();
- return (i1 << 8) | i2;
- }
- public static int ReadUint16(byte[] buf, int offset)
- {
- uint n = (uint)buf[offset] << 8;
- n |= (uint)buf[++offset];
- return (int)n;
- }
- public static int ReadUint24(Stream input)
- {
- int i1 = input.ReadByte();
- int i2 = input.ReadByte();
- int i3 = input.ReadByte();
- if (i3 < 0)
- throw new EndOfStreamException();
- return (i1 << 16) | (i2 << 8) | i3;
- }
- public static int ReadUint24(byte[] buf, int offset)
- {
- uint n = (uint)buf[offset] << 16;
- n |= (uint)buf[++offset] << 8;
- n |= (uint)buf[++offset];
- return (int)n;
- }
- public static long ReadUint32(Stream input)
- {
- int i1 = input.ReadByte();
- int i2 = input.ReadByte();
- int i3 = input.ReadByte();
- int i4 = input.ReadByte();
- if (i4 < 0)
- throw new EndOfStreamException();
- return (long)(uint)((i1 << 24) | (i2 << 16) | (i3 << 8) | i4);
- }
- public static long ReadUint32(byte[] buf, int offset)
- {
- uint n = (uint)buf[offset] << 24;
- n |= (uint)buf[++offset] << 16;
- n |= (uint)buf[++offset] << 8;
- n |= (uint)buf[++offset];
- return (long)n;
- }
- public static long ReadUint48(Stream input)
- {
- int hi = ReadUint24(input);
- int lo = ReadUint24(input);
- return ((long)(hi & 0xffffffffL) << 24) | (long)(lo & 0xffffffffL);
- }
- public static long ReadUint48(byte[] buf, int offset)
- {
- int hi = ReadUint24(buf, offset);
- int lo = ReadUint24(buf, offset + 3);
- return ((long)(hi & 0xffffffffL) << 24) | (long)(lo & 0xffffffffL);
- }
- public static byte[] ReadAllOrNothing(int length, Stream input)
- {
- if (length < 1)
- return EmptyBytes;
- byte[] buf = new byte[length];
- int read = Streams.ReadFully(input, buf);
- if (read == 0)
- return null;
- if (read != length)
- throw new EndOfStreamException();
- return buf;
- }
- public static byte[] ReadFully(int length, Stream input)
- {
- if (length < 1)
- return EmptyBytes;
- byte[] buf = new byte[length];
- if (length != Streams.ReadFully(input, buf))
- throw new EndOfStreamException();
- return buf;
- }
- public static void ReadFully(byte[] buf, Stream input)
- {
- if (Streams.ReadFully(input, buf, 0, buf.Length) < buf.Length)
- throw new EndOfStreamException();
- }
- public static byte[] ReadOpaque8(Stream input)
- {
- byte length = ReadUint8(input);
- byte[] bytes = new byte[length];
- ReadFully(bytes, input);
- return bytes;
- }
- public static byte[] ReadOpaque16(Stream input)
- {
- int length = ReadUint16(input);
- byte[] bytes = new byte[length];
- ReadFully(bytes, input);
- return bytes;
- }
- public static byte[] ReadOpaque24(Stream input)
- {
- int length = ReadUint24(input);
- return ReadFully(length, input);
- }
- public static byte[] ReadUint8Array(int count, Stream input)
- {
- byte[] uints = new byte[count];
- for (int i = 0; i < count; ++i)
- {
- uints[i] = ReadUint8(input);
- }
- return uints;
- }
- public static int[] ReadUint16Array(int count, Stream input)
- {
- int[] uints = new int[count];
- for (int i = 0; i < count; ++i)
- {
- uints[i] = ReadUint16(input);
- }
- return uints;
- }
- public static ProtocolVersion ReadVersion(byte[] buf, int offset)
- {
- return ProtocolVersion.Get(buf[offset], buf[offset + 1]);
- }
- public static ProtocolVersion ReadVersion(Stream input)
- {
- int i1 = input.ReadByte();
- int i2 = input.ReadByte();
- if (i2 < 0)
- throw new EndOfStreamException();
- return ProtocolVersion.Get(i1, i2);
- }
- public static int ReadVersionRaw(byte[] buf, int offset)
- {
- return (buf[offset] << 8) | buf[offset + 1];
- }
- public static int ReadVersionRaw(Stream input)
- {
- int i1 = input.ReadByte();
- int i2 = input.ReadByte();
- if (i2 < 0)
- throw new EndOfStreamException();
- return (i1 << 8) | i2;
- }
- public static Asn1Object ReadAsn1Object(byte[] encoding)
- {
- MemoryStream input = new MemoryStream(encoding, false);
- Asn1InputStream asn1 = new Asn1InputStream(input, encoding.Length);
- Asn1Object result = asn1.ReadObject();
- if (null == result)
- throw new TlsFatalAlert(AlertDescription.decode_error);
- if (input.Position != input.Length)
- throw new TlsFatalAlert(AlertDescription.decode_error);
- return result;
- }
- public static Asn1Object ReadDerObject(byte[] encoding)
- {
- /*
- * NOTE: The current ASN.1 parsing code can't enforce DER-only parsing, but since DER is
- * canonical, we can check it by re-encoding the result and comparing to the original.
- */
- Asn1Object result = ReadAsn1Object(encoding);
- byte[] check = result.GetEncoded(Asn1Encodable.Der);
- if (!Arrays.AreEqual(check, encoding))
- throw new TlsFatalAlert(AlertDescription.decode_error);
- return result;
- }
- public static void WriteGmtUnixTime(byte[] buf, int offset)
- {
- int t = (int)(DateTimeUtilities.CurrentUnixMs() / 1000L);
- buf[offset] = (byte)(t >> 24);
- buf[offset + 1] = (byte)(t >> 16);
- buf[offset + 2] = (byte)(t >> 8);
- buf[offset + 3] = (byte)t;
- }
- public static void WriteVersion(ProtocolVersion version, Stream output)
- {
- output.WriteByte((byte)version.MajorVersion);
- output.WriteByte((byte)version.MinorVersion);
- }
- public static void WriteVersion(ProtocolVersion version, byte[] buf, int offset)
- {
- buf[offset] = (byte)version.MajorVersion;
- buf[offset + 1] = (byte)version.MinorVersion;
- }
- public static IList GetDefaultDssSignatureAlgorithms()
- {
- return VectorOfOne(new SignatureAndHashAlgorithm(HashAlgorithm.sha1, SignatureAlgorithm.dsa));
- }
- public static IList GetDefaultECDsaSignatureAlgorithms()
- {
- return VectorOfOne(new SignatureAndHashAlgorithm(HashAlgorithm.sha1, SignatureAlgorithm.ecdsa));
- }
- public static IList GetDefaultRsaSignatureAlgorithms()
- {
- return VectorOfOne(new SignatureAndHashAlgorithm(HashAlgorithm.sha1, SignatureAlgorithm.rsa));
- }
- public static byte[] GetExtensionData(IDictionary extensions, int extensionType)
- {
- return extensions == null ? null : (byte[])extensions[extensionType];
- }
- public static IList GetDefaultSupportedSignatureAlgorithms()
- {
- byte[] hashAlgorithms = new byte[]{ HashAlgorithm.sha1, HashAlgorithm.sha224, HashAlgorithm.sha256,
- HashAlgorithm.sha384, HashAlgorithm.sha512 };
- byte[] signatureAlgorithms = new byte[]{ SignatureAlgorithm.rsa, SignatureAlgorithm.dsa,
- SignatureAlgorithm.ecdsa };
- IList result = Org.BouncyCastle.Utilities.Platform.CreateArrayList();
- for (int i = 0; i < signatureAlgorithms.Length; ++i)
- {
- for (int j = 0; j < hashAlgorithms.Length; ++j)
- {
- result.Add(new SignatureAndHashAlgorithm(hashAlgorithms[j], signatureAlgorithms[i]));
- }
- }
- return result;
- }
- public static SignatureAndHashAlgorithm GetSignatureAndHashAlgorithm(TlsContext context,
- TlsSignerCredentials signerCredentials)
- {
- SignatureAndHashAlgorithm signatureAndHashAlgorithm = null;
- if (IsTlsV12(context))
- {
- signatureAndHashAlgorithm = signerCredentials.SignatureAndHashAlgorithm;
- if (signatureAndHashAlgorithm == null)
- throw new TlsFatalAlert(AlertDescription.internal_error);
- }
- return signatureAndHashAlgorithm;
- }
- public static bool HasExpectedEmptyExtensionData(IDictionary extensions, int extensionType,
- byte alertDescription)
- {
- byte[] extension_data = GetExtensionData(extensions, extensionType);
- if (extension_data == null)
- return false;
- if (extension_data.Length != 0)
- throw new TlsFatalAlert(alertDescription);
- return true;
- }
- public static TlsSession ImportSession(byte[] sessionID, SessionParameters sessionParameters)
- {
- return new TlsSessionImpl(sessionID, sessionParameters);
- }
- public static bool IsSignatureAlgorithmsExtensionAllowed(ProtocolVersion clientVersion)
- {
- return ProtocolVersion.TLSv12.IsEqualOrEarlierVersionOf(clientVersion.GetEquivalentTLSVersion());
- }
- /**
- * Add a 'signature_algorithms' extension to existing extensions.
- *
- * @param extensions A {@link Hashtable} to add the extension to.
- * @param supportedSignatureAlgorithms {@link Vector} containing at least 1 {@link SignatureAndHashAlgorithm}.
- * @throws IOException
- */
- public static void AddSignatureAlgorithmsExtension(IDictionary extensions, IList supportedSignatureAlgorithms)
- {
- extensions[ExtensionType.signature_algorithms] = CreateSignatureAlgorithmsExtension(supportedSignatureAlgorithms);
- }
- /**
- * Get a 'signature_algorithms' extension from extensions.
- *
- * @param extensions A {@link Hashtable} to get the extension from, if it is present.
- * @return A {@link Vector} containing at least 1 {@link SignatureAndHashAlgorithm}, or null.
- * @throws IOException
- */
- public static IList GetSignatureAlgorithmsExtension(IDictionary extensions)
- {
- byte[] extensionData = GetExtensionData(extensions, ExtensionType.signature_algorithms);
- return extensionData == null ? null : ReadSignatureAlgorithmsExtension(extensionData);
- }
- /**
- * Create a 'signature_algorithms' extension value.
- *
- * @param supportedSignatureAlgorithms A {@link Vector} containing at least 1 {@link SignatureAndHashAlgorithm}.
- * @return A byte array suitable for use as an extension value.
- * @throws IOException
- */
- public static byte[] CreateSignatureAlgorithmsExtension(IList supportedSignatureAlgorithms)
- {
- MemoryStream buf = new MemoryStream();
- // supported_signature_algorithms
- EncodeSupportedSignatureAlgorithms(supportedSignatureAlgorithms, false, buf);
- return buf.ToArray();
- }
- /**
- * Read 'signature_algorithms' extension data.
- *
- * @param extensionData The extension data.
- * @return A {@link Vector} containing at least 1 {@link SignatureAndHashAlgorithm}.
- * @throws IOException
- */
- public static IList ReadSignatureAlgorithmsExtension(byte[] extensionData)
- {
- if (extensionData == null)
- throw new ArgumentNullException("extensionData");
- MemoryStream buf = new MemoryStream(extensionData, false);
- // supported_signature_algorithms
- IList supported_signature_algorithms = ParseSupportedSignatureAlgorithms(false, buf);
- TlsProtocol.AssertEmpty(buf);
- return supported_signature_algorithms;
- }
- public static void EncodeSupportedSignatureAlgorithms(IList supportedSignatureAlgorithms, bool allowAnonymous,
- Stream output)
- {
- if (supportedSignatureAlgorithms == null)
- throw new ArgumentNullException("supportedSignatureAlgorithms");
- if (supportedSignatureAlgorithms.Count < 1 || supportedSignatureAlgorithms.Count >= (1 << 15))
- throw new ArgumentException("must have length from 1 to (2^15 - 1)", "supportedSignatureAlgorithms");
- // supported_signature_algorithms
- int length = 2 * supportedSignatureAlgorithms.Count;
- CheckUint16(length);
- WriteUint16(length, output);
- foreach (SignatureAndHashAlgorithm entry in supportedSignatureAlgorithms)
- {
- if (!allowAnonymous && entry.Signature == SignatureAlgorithm.anonymous)
- {
- /*
- * RFC 5246 7.4.1.4.1 The "anonymous" value is meaningless in this context but used
- * in Section 7.4.3. It MUST NOT appear in this extension.
- */
- throw new ArgumentException(
- "SignatureAlgorithm.anonymous MUST NOT appear in the signature_algorithms extension");
- }
- entry.Encode(output);
- }
- }
- public static IList ParseSupportedSignatureAlgorithms(bool allowAnonymous, Stream input)
- {
- // supported_signature_algorithms
- int length = ReadUint16(input);
- if (length < 2 || (length & 1) != 0)
- throw new TlsFatalAlert(AlertDescription.decode_error);
- int count = length / 2;
- IList supportedSignatureAlgorithms = Org.BouncyCastle.Utilities.Platform.CreateArrayList(count);
- for (int i = 0; i < count; ++i)
- {
- SignatureAndHashAlgorithm entry = SignatureAndHashAlgorithm.Parse(input);
- if (!allowAnonymous && entry.Signature == SignatureAlgorithm.anonymous)
- {
- /*
- * RFC 5246 7.4.1.4.1 The "anonymous" value is meaningless in this context but used
- * in Section 7.4.3. It MUST NOT appear in this extension.
- */
- throw new TlsFatalAlert(AlertDescription.illegal_parameter);
- }
- supportedSignatureAlgorithms.Add(entry);
- }
- return supportedSignatureAlgorithms;
- }
- public static void VerifySupportedSignatureAlgorithm(IList supportedSignatureAlgorithms, SignatureAndHashAlgorithm signatureAlgorithm)
- {
- if (supportedSignatureAlgorithms == null)
- throw new ArgumentNullException("supportedSignatureAlgorithms");
- if (supportedSignatureAlgorithms.Count < 1 || supportedSignatureAlgorithms.Count >= (1 << 15))
- throw new ArgumentException("must have length from 1 to (2^15 - 1)", "supportedSignatureAlgorithms");
- if (signatureAlgorithm == null)
- throw new ArgumentNullException("signatureAlgorithm");
- if (signatureAlgorithm.Signature != SignatureAlgorithm.anonymous)
- {
- foreach (SignatureAndHashAlgorithm entry in supportedSignatureAlgorithms)
- {
- if (entry.Hash == signatureAlgorithm.Hash && entry.Signature == signatureAlgorithm.Signature)
- return;
- }
- }
- throw new TlsFatalAlert(AlertDescription.illegal_parameter);
- }
- public static byte[] PRF(TlsContext context, byte[] secret, string asciiLabel, byte[] seed, int size)
- {
- ProtocolVersion version = context.ServerVersion;
- if (version.IsSsl)
- throw new InvalidOperationException("No PRF available for SSLv3 session");
- byte[] label = Strings.ToByteArray(asciiLabel);
- byte[] labelSeed = Concat(label, seed);
- int prfAlgorithm = context.SecurityParameters.PrfAlgorithm;
- if (prfAlgorithm == PrfAlgorithm.tls_prf_legacy)
- return PRF_legacy(secret, label, labelSeed, size);
- IDigest prfDigest = CreatePrfHash(prfAlgorithm);
- byte[] buf = new byte[size];
- HMacHash(prfDigest, secret, labelSeed, buf);
- return buf;
- }
- public static byte[] PRF_legacy(byte[] secret, string asciiLabel, byte[] seed, int size)
- {
- byte[] label = Strings.ToByteArray(asciiLabel);
- byte[] labelSeed = Concat(label, seed);
- return PRF_legacy(secret, label, labelSeed, size);
- }
- internal static byte[] PRF_legacy(byte[] secret, byte[] label, byte[] labelSeed, int size)
- {
- int s_half = (secret.Length + 1) / 2;
- byte[] s1 = new byte[s_half];
- byte[] s2 = new byte[s_half];
- Array.Copy(secret, 0, s1, 0, s_half);
- Array.Copy(secret, secret.Length - s_half, s2, 0, s_half);
- byte[] b1 = new byte[size];
- byte[] b2 = new byte[size];
- HMacHash(CreateHash(HashAlgorithm.md5), s1, labelSeed, b1);
- HMacHash(CreateHash(HashAlgorithm.sha1), s2, labelSeed, b2);
- for (int i = 0; i < size; i++)
- {
- b1[i] ^= b2[i];
- }
- return b1;
- }
- internal static byte[] Concat(byte[] a, byte[] b)
- {
- byte[] c = new byte[a.Length + b.Length];
- Array.Copy(a, 0, c, 0, a.Length);
- Array.Copy(b, 0, c, a.Length, b.Length);
- return c;
- }
- internal static void HMacHash(IDigest digest, byte[] secret, byte[] seed, byte[] output)
- {
- HMac mac = new HMac(digest);
- mac.Init(new KeyParameter(secret));
- byte[] a = seed;
- int size = digest.GetDigestSize();
- int iterations = (output.Length + size - 1) / size;
- byte[] buf = new byte[mac.GetMacSize()];
- byte[] buf2 = new byte[mac.GetMacSize()];
- for (int i = 0; i < iterations; i++)
- {
- mac.BlockUpdate(a, 0, a.Length);
- mac.DoFinal(buf, 0);
- a = buf;
- mac.BlockUpdate(a, 0, a.Length);
- mac.BlockUpdate(seed, 0, seed.Length);
- mac.DoFinal(buf2, 0);
- Array.Copy(buf2, 0, output, (size * i), System.Math.Min(size, output.Length - (size * i)));
- }
- }
- internal static void ValidateKeyUsage(X509CertificateStructure c, int keyUsageBits)
- {
- X509Extensions exts = c.TbsCertificate.Extensions;
- if (exts != null)
- {
- X509Extension ext = exts.GetExtension(X509Extensions.KeyUsage);
- if (ext != null)
- {
- DerBitString ku = KeyUsage.GetInstance(ext);
- int bits = ku.GetBytes()[0];
- if ((bits & keyUsageBits) != keyUsageBits)
- throw new TlsFatalAlert(AlertDescription.certificate_unknown);
- }
- }
- }
- internal static byte[] CalculateKeyBlock(TlsContext context, int size)
- {
- SecurityParameters securityParameters = context.SecurityParameters;
- byte[] master_secret = securityParameters.MasterSecret;
- byte[] seed = Concat(securityParameters.ServerRandom, securityParameters.ClientRandom);
- if (IsSsl(context))
- return CalculateKeyBlock_Ssl(master_secret, seed, size);
- return PRF(context, master_secret, ExporterLabel.key_expansion, seed, size);
- }
- internal static byte[] CalculateKeyBlock_Ssl(byte[] master_secret, byte[] random, int size)
- {
- IDigest md5 = CreateHash(HashAlgorithm.md5);
- IDigest sha1 = CreateHash(HashAlgorithm.sha1);
- int md5Size = md5.GetDigestSize();
- byte[] shatmp = new byte[sha1.GetDigestSize()];
- byte[] tmp = new byte[size + md5Size];
- int i = 0, pos = 0;
- while (pos < size)
- {
- byte[] ssl3Const = SSL3_CONST[i];
- sha1.BlockUpdate(ssl3Const, 0, ssl3Const.Length);
- sha1.BlockUpdate(master_secret, 0, master_secret.Length);
- sha1.BlockUpdate(random, 0, random.Length);
- sha1.DoFinal(shatmp, 0);
- md5.BlockUpdate(master_secret, 0, master_secret.Length);
- md5.BlockUpdate(shatmp, 0, shatmp.Length);
- md5.DoFinal(tmp, pos);
- pos += md5Size;
- ++i;
- }
- return Arrays.CopyOfRange(tmp, 0, size);
- }
- internal static byte[] CalculateMasterSecret(TlsContext context, byte[] pre_master_secret)
- {
- SecurityParameters securityParameters = context.SecurityParameters;
- byte[] seed = securityParameters.extendedMasterSecret
- ? securityParameters.SessionHash
- : Concat(securityParameters.ClientRandom, securityParameters.ServerRandom);
- if (IsSsl(context))
- return CalculateMasterSecret_Ssl(pre_master_secret, seed);
- string asciiLabel = securityParameters.extendedMasterSecret
- ? ExporterLabel.extended_master_secret
- : ExporterLabel.master_secret;
- return PRF(context, pre_master_secret, asciiLabel, seed, 48);
- }
- internal static byte[] CalculateMasterSecret_Ssl(byte[] pre_master_secret, byte[] random)
- {
- IDigest md5 = CreateHash(HashAlgorithm.md5);
- IDigest sha1 = CreateHash(HashAlgorithm.sha1);
- int md5Size = md5.GetDigestSize();
- byte[] shatmp = new byte[sha1.GetDigestSize()];
- byte[] rval = new byte[md5Size * 3];
- int pos = 0;
- for (int i = 0; i < 3; ++i)
- {
- byte[] ssl3Const = SSL3_CONST[i];
- sha1.BlockUpdate(ssl3Const, 0, ssl3Const.Length);
- sha1.BlockUpdate(pre_master_secret, 0, pre_master_secret.Length);
- sha1.BlockUpdate(random, 0, random.Length);
- sha1.DoFinal(shatmp, 0);
- md5.BlockUpdate(pre_master_secret, 0, pre_master_secret.Length);
- md5.BlockUpdate(shatmp, 0, shatmp.Length);
- md5.DoFinal(rval, pos);
- pos += md5Size;
- }
- return rval;
- }
- internal static byte[] CalculateVerifyData(TlsContext context, string asciiLabel, byte[] handshakeHash)
- {
- if (IsSsl(context))
- return handshakeHash;
- SecurityParameters securityParameters = context.SecurityParameters;
- byte[] master_secret = securityParameters.MasterSecret;
- int verify_data_length = securityParameters.VerifyDataLength;
- return PRF(context, master_secret, asciiLabel, handshakeHash, verify_data_length);
- }
- public static IDigest CreateHash(byte hashAlgorithm)
- {
- switch (hashAlgorithm)
- {
- case HashAlgorithm.md5:
- return new MD5Digest();
- case HashAlgorithm.sha1:
- return new Sha1Digest();
- case HashAlgorithm.sha224:
- return new Sha224Digest();
- case HashAlgorithm.sha256:
- return new Sha256Digest();
- case HashAlgorithm.sha384:
- return new Sha384Digest();
- case HashAlgorithm.sha512:
- return new Sha512Digest();
- default:
- throw new ArgumentException("unknown HashAlgorithm", "hashAlgorithm");
- }
- }
- public static IDigest CreateHash(SignatureAndHashAlgorithm signatureAndHashAlgorithm)
- {
- return signatureAndHashAlgorithm == null
- ? new CombinedHash()
- : CreateHash(signatureAndHashAlgorithm.Hash);
- }
- public static IDigest CloneHash(byte hashAlgorithm, IDigest hash)
- {
- switch (hashAlgorithm)
- {
- case HashAlgorithm.md5:
- return new MD5Digest((MD5Digest)hash);
- case HashAlgorithm.sha1:
- return new Sha1Digest((Sha1Digest)hash);
- case HashAlgorithm.sha224:
- return new Sha224Digest((Sha224Digest)hash);
- case HashAlgorithm.sha256:
- return new Sha256Digest((Sha256Digest)hash);
- case HashAlgorithm.sha384:
- return new Sha384Digest((Sha384Digest)hash);
- case HashAlgorithm.sha512:
- return new Sha512Digest((Sha512Digest)hash);
- default:
- throw new ArgumentException("unknown HashAlgorithm", "hashAlgorithm");
- }
- }
- public static IDigest CreatePrfHash(int prfAlgorithm)
- {
- switch (prfAlgorithm)
- {
- case PrfAlgorithm.tls_prf_legacy:
- return new CombinedHash();
- default:
- return CreateHash(GetHashAlgorithmForPrfAlgorithm(prfAlgorithm));
- }
- }
- public static IDigest ClonePrfHash(int prfAlgorithm, IDigest hash)
- {
- switch (prfAlgorithm)
- {
- case PrfAlgorithm.tls_prf_legacy:
- return new CombinedHash((CombinedHash)hash);
- default:
- return CloneHash(GetHashAlgorithmForPrfAlgorithm(prfAlgorithm), hash);
- }
- }
- public static byte GetHashAlgorithmForPrfAlgorithm(int prfAlgorithm)
- {
- switch (prfAlgorithm)
- {
- case PrfAlgorithm.tls_prf_legacy:
- throw new ArgumentException("legacy PRF not a valid algorithm", "prfAlgorithm");
- case PrfAlgorithm.tls_prf_sha256:
- return HashAlgorithm.sha256;
- case PrfAlgorithm.tls_prf_sha384:
- return HashAlgorithm.sha384;
- default:
- throw new ArgumentException("unknown PrfAlgorithm", "prfAlgorithm");
- }
- }
- public static DerObjectIdentifier GetOidForHashAlgorithm(byte hashAlgorithm)
- {
- switch (hashAlgorithm)
- {
- case HashAlgorithm.md5:
- return PkcsObjectIdentifiers.MD5;
- case HashAlgorithm.sha1:
- return X509ObjectIdentifiers.IdSha1;
- case HashAlgorithm.sha224:
- return NistObjectIdentifiers.IdSha224;
- case HashAlgorithm.sha256:
- return NistObjectIdentifiers.IdSha256;
- case HashAlgorithm.sha384:
- return NistObjectIdentifiers.IdSha384;
- case HashAlgorithm.sha512:
- return NistObjectIdentifiers.IdSha512;
- default:
- throw new ArgumentException("unknown HashAlgorithm", "hashAlgorithm");
- }
- }
- internal static short GetClientCertificateType(Certificate clientCertificate, Certificate serverCertificate)
- {
- if (clientCertificate.IsEmpty)
- return -1;
- X509CertificateStructure x509Cert = clientCertificate.GetCertificateAt(0);
- SubjectPublicKeyInfo keyInfo = x509Cert.SubjectPublicKeyInfo;
- try
- {
- AsymmetricKeyParameter publicKey = PublicKeyFactory.CreateKey(keyInfo);
- if (publicKey.IsPrivate)
- throw new TlsFatalAlert(AlertDescription.internal_error);
- /*
- * TODO RFC 5246 7.4.6. The certificates MUST be signed using an acceptable hash/
- * signature algorithm pair, as described in Section 7.4.4. Note that this relaxes the
- * constraints on certificate-signing algorithms found in prior versions of TLS.
- */
- /*
- * RFC 5246 7.4.6. Client Certificate
- */
- /*
- * RSA public key; the certificate MUST allow the key to be used for signing with the
- * signature scheme and hash algorithm that will be employed in the certificate verify
- * message.
- */
- if (publicKey is RsaKeyParameters)
- {
- ValidateKeyUsage(x509Cert, KeyUsage.DigitalSignature);
- return ClientCertificateType.rsa_sign;
- }
- /*
- * DSA public key; the certificate MUST allow the key to be used for signing with the
- * hash algorithm that will be employed in the certificate verify message.
- */
- if (publicKey is DsaPublicKeyParameters)
- {
- ValidateKeyUsage(x509Cert, KeyUsage.DigitalSignature);
- return ClientCertificateType.dss_sign;
- }
- /*
- * ECDSA-capable public key; the certificate MUST allow the key to be used for signing
- * with the hash algorithm that will be employed in the certificate verify message; the
- * public key MUST use a curve and point format supported by the server.
- */
- if (publicKey is ECPublicKeyParameters)
- {
- ValidateKeyUsage(x509Cert, KeyUsage.DigitalSignature);
- // TODO Check the curve and point format
- return ClientCertificateType.ecdsa_sign;
- }
- // TODO Add support for ClientCertificateType.*_fixed_*
- throw new TlsFatalAlert(AlertDescription.unsupported_certificate);
- }
- catch (Exception e)
- {
- throw new TlsFatalAlert(AlertDescription.unsupported_certificate, e);
- }
- }
- internal static void TrackHashAlgorithms(TlsHandshakeHash handshakeHash, IList supportedSignatureAlgorithms)
- {
- if (supportedSignatureAlgorithms != null)
- {
- foreach (SignatureAndHashAlgorithm signatureAndHashAlgorithm in supportedSignatureAlgorithms)
- {
- byte hashAlgorithm = signatureAndHashAlgorithm.Hash;
- // TODO Support values in the "Reserved for Private Use" range
- if (!HashAlgorithm.IsPrivate(hashAlgorithm))
- {
- handshakeHash.TrackHashAlgorithm(hashAlgorithm);
- }
- }
- }
- }
- public static bool HasSigningCapability(byte clientCertificateType)
- {
- switch (clientCertificateType)
- {
- case ClientCertificateType.dss_sign:
- case ClientCertificateType.ecdsa_sign:
- case ClientCertificateType.rsa_sign:
- return true;
- default:
- return false;
- }
- }
- public static TlsSigner CreateTlsSigner(byte clientCertificateType)
- {
- switch (clientCertificateType)
- {
- case ClientCertificateType.dss_sign:
- return new TlsDssSigner();
- case ClientCertificateType.ecdsa_sign:
- return new TlsECDsaSigner();
- case ClientCertificateType.rsa_sign:
- return new TlsRsaSigner();
- default:
- throw new ArgumentException("not a type with signing capability", "clientCertificateType");
- }
- }
- internal static readonly byte[] SSL_CLIENT = {0x43, 0x4C, 0x4E, 0x54};
- internal static readonly byte[] SSL_SERVER = {0x53, 0x52, 0x56, 0x52};
- // SSL3 magic mix constants ("A", "BB", "CCC", ...)
- internal static readonly byte[][] SSL3_CONST = GenSsl3Const();
- private static byte[][] GenSsl3Const()
- {
- int n = 10;
- byte[][] arr = new byte[n][];
- for (int i = 0; i < n; i++)
- {
- byte[] b = new byte[i + 1];
- Arrays.Fill(b, (byte)('A' + i));
- arr[i] = b;
- }
- return arr;
- }
- private static IList VectorOfOne(object obj)
- {
- IList v = Org.BouncyCastle.Utilities.Platform.CreateArrayList(1);
- v.Add(obj);
- return v;
- }
- public static int GetCipherType(int ciphersuite)
- {
- switch (GetEncryptionAlgorithm(ciphersuite))
- {
- case EncryptionAlgorithm.AES_128_CCM:
- case EncryptionAlgorithm.AES_128_CCM_8:
- case EncryptionAlgorithm.AES_128_GCM:
- case EncryptionAlgorithm.AES_128_OCB_TAGLEN96:
- case EncryptionAlgorithm.AES_256_CCM:
- case EncryptionAlgorithm.AES_256_CCM_8:
- case EncryptionAlgorithm.AES_256_GCM:
- case EncryptionAlgorithm.AES_256_OCB_TAGLEN96:
- case EncryptionAlgorithm.CAMELLIA_128_GCM:
- case EncryptionAlgorithm.CAMELLIA_256_GCM:
- case EncryptionAlgorithm.CHACHA20_POLY1305:
- return CipherType.aead;
- case EncryptionAlgorithm.RC2_CBC_40:
- case EncryptionAlgorithm.IDEA_CBC:
- case EncryptionAlgorithm.DES40_CBC:
- case EncryptionAlgorithm.DES_CBC:
- case EncryptionAlgorithm.cls_3DES_EDE_CBC:
- case EncryptionAlgorithm.AES_128_CBC:
- case EncryptionAlgorithm.AES_256_CBC:
- case EncryptionAlgorithm.CAMELLIA_128_CBC:
- case EncryptionAlgorithm.CAMELLIA_256_CBC:
- case EncryptionAlgorithm.SEED_CBC:
- return CipherType.block;
- case EncryptionAlgorithm.RC4_40:
- case EncryptionAlgorithm.RC4_128:
- return CipherType.stream;
- default:
- throw new TlsFatalAlert(AlertDescription.internal_error);
- }
- }
- public static int GetEncryptionAlgorithm(int ciphersuite)
- {
- switch (ciphersuite)
- {
- case CipherSuite.TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA:
- case CipherSuite.TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA:
- case CipherSuite.TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA:
- case CipherSuite.TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA:
- case CipherSuite.TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA:
- case CipherSuite.TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA:
- case CipherSuite.TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA:
- case CipherSuite.TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA:
- case CipherSuite.TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA:
- case CipherSuite.TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA:
- case CipherSuite.TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA:
- case CipherSuite.TLS_PSK_WITH_3DES_EDE_CBC_SHA:
- case CipherSuite.TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA:
- case CipherSuite.TLS_RSA_WITH_3DES_EDE_CBC_SHA:
- case CipherSuite.TLS_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA:
- case CipherSuite.TLS_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA:
- case CipherSuite.TLS_SRP_SHA_WITH_3DES_EDE_CBC_SHA:
- return EncryptionAlgorithm.cls_3DES_EDE_CBC;
- case CipherSuite.TLS_DH_DSS_WITH_AES_128_CBC_SHA:
- case CipherSuite.TLS_DH_DSS_WITH_AES_128_CBC_SHA256:
- case CipherSuite.TLS_DH_RSA_WITH_AES_128_CBC_SHA:
- case CipherSuite.TLS_DH_RSA_WITH_AES_128_CBC_SHA256:
- case CipherSuite.TLS_DHE_DSS_WITH_AES_128_CBC_SHA:
- case CipherSuite.TLS_DHE_DSS_WITH_AES_128_CBC_SHA256:
- case CipherSuite.TLS_DHE_PSK_WITH_AES_128_CBC_SHA:
- case CipherSuite.TLS_DHE_PSK_WITH_AES_128_CBC_SHA256:
- case CipherSuite.TLS_DHE_RSA_WITH_AES_128_CBC_SHA:
- case CipherSuite.TLS_DHE_RSA_WITH_AES_128_CBC_SHA256:
- case CipherSuite.TLS_ECDH_anon_WITH_AES_128_CBC_SHA:
- case CipherSuite.TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA:
- case CipherSuite.TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256:
- case CipherSuite.TLS_ECDH_RSA_WITH_AES_128_CBC_SHA:
- case CipherSuite.TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256:
- case CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA:
- case CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256:
- case CipherSuite.TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA:
- case CipherSuite.TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256:
- case CipherSuite.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA:
- case CipherSuite.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256:
- case CipherSuite.TLS_PSK_WITH_AES_128_CBC_SHA:
- case CipherSuite.TLS_PSK_WITH_AES_128_CBC_SHA256:
- case CipherSuite.TLS_RSA_PSK_WITH_AES_128_CBC_SHA:
- case CipherSuite.TLS_RSA_PSK_WITH_AES_128_CBC_SHA256:
- case CipherSuite.TLS_RSA_WITH_AES_128_CBC_SHA:
- case CipherSuite.TLS_RSA_WITH_AES_128_CBC_SHA256:
- case CipherSuite.TLS_SRP_SHA_DSS_WITH_AES_128_CBC_SHA:
- case CipherSuite.TLS_SRP_SHA_RSA_WITH_AES_128_CBC_SHA:
- case CipherSuite.TLS_SRP_SHA_WITH_AES_128_CBC_SHA:
- return EncryptionAlgorithm.AES_128_CBC;
- case CipherSuite.TLS_DHE_PSK_WITH_AES_128_CCM:
- case CipherSuite.TLS_DHE_RSA_WITH_AES_128_CCM:
- case CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_CCM:
- case CipherSuite.TLS_PSK_WITH_AES_128_CCM:
- case CipherSuite.TLS_RSA_WITH_AES_128_CCM:
- return EncryptionAlgorithm.AES_128_CCM;
- case CipherSuite.TLS_DHE_RSA_WITH_AES_128_CCM_8:
- case CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8:
- case CipherSuite.TLS_PSK_DHE_WITH_AES_128_CCM_8:
- case CipherSuite.TLS_PSK_WITH_AES_128_CCM_8:
- case CipherSuite.TLS_RSA_WITH_AES_128_CCM_8:
- return EncryptionAlgorithm.AES_128_CCM_8;
- case CipherSuite.TLS_DH_DSS_WITH_AES_128_GCM_SHA256:
- case CipherSuite.TLS_DH_RSA_WITH_AES_128_GCM_SHA256:
- case CipherSuite.TLS_DHE_DSS_WITH_AES_128_GCM_SHA256:
- case CipherSuite.TLS_DHE_PSK_WITH_AES_128_GCM_SHA256:
- case CipherSuite.TLS_DHE_RSA_WITH_AES_128_GCM_SHA256:
- case CipherSuite.TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256:
- case CipherSuite.TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256:
- case CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256:
- case CipherSuite.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256:
- case CipherSuite.TLS_PSK_WITH_AES_128_GCM_SHA256:
- case CipherSuite.TLS_RSA_PSK_WITH_AES_128_GCM_SHA256:
- case CipherSuite.TLS_RSA_WITH_AES_128_GCM_SHA256:
- return EncryptionAlgorithm.AES_128_GCM;
- case CipherSuite.DRAFT_TLS_DHE_PSK_WITH_AES_128_OCB:
- case CipherSuite.DRAFT_TLS_DHE_RSA_WITH_AES_128_OCB:
- case CipherSuite.DRAFT_TLS_ECDHE_ECDSA_WITH_AES_128_OCB:
- case CipherSuite.DRAFT_TLS_ECDHE_PSK_WITH_AES_128_OCB:
- case CipherSuite.DRAFT_TLS_ECDHE_RSA_WITH_AES_128_OCB:
- case CipherSuite.DRAFT_TLS_PSK_WITH_AES_128_OCB:
- return EncryptionAlgorithm.AES_128_OCB_TAGLEN96;
- case CipherSuite.TLS_DH_DSS_WITH_AES_256_CBC_SHA:
- case CipherSuite.TLS_DH_DSS_WITH_AES_256_CBC_SHA256:
- case CipherSuite.TLS_DH_RSA_WITH_AES_256_CBC_SHA:
- case CipherSuite.TLS_DH_RSA_WITH_AES_256_CBC_SHA256:
- case CipherSuite.TLS_DHE_DSS_WITH_AES_256_CBC_SHA:
- case CipherSuite.TLS_DHE_DSS_WITH_AES_256_CBC_SHA256:
- case CipherSuite.TLS_DHE_PSK_WITH_AES_256_CBC_SHA:
- case CipherSuite.TLS_DHE_PSK_WITH_AES_256_CBC_SHA384:
- case CipherSuite.TLS_DHE_RSA_WITH_AES_256_CBC_SHA:
- case CipherSuite.TLS_DHE_RSA_WITH_AES_256_CBC_SHA256:
- case CipherSuite.TLS_ECDH_anon_WITH_AES_256_CBC_SHA:
- case CipherSuite.TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA:
- case CipherSuite.TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384:
- case CipherSuite.TLS_ECDH_RSA_WITH_AES_256_CBC_SHA:
- case CipherSuite.TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384:
- case CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA:
- case CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384:
- case CipherSuite.TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA:
- case CipherSuite.TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384:
- case CipherSuite.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA:
- case CipherSuite.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384:
- case CipherSuite.TLS_PSK_WITH_AES_256_CBC_SHA:
- case CipherSuite.TLS_PSK_WITH_AES_256_CBC_SHA384:
- case CipherSuite.TLS_RSA_PSK_WITH_AES_256_CBC_SHA:
- case CipherSuite.TLS_RSA_PSK_WITH_AES_256_CBC_SHA384:
- case CipherSuite.TLS_RSA_WITH_AES_256_CBC_SHA:
- case CipherSuite.TLS_RSA_WITH_AES_256_CBC_SHA256:
- case CipherSuite.TLS_SRP_SHA_DSS_WITH_AES_256_CBC_SHA:
- case CipherSuite.TLS_SRP_SHA_RSA_WITH_AES_256_CBC_SHA:
- case CipherSuite.TLS_SRP_SHA_WITH_AES_256_CBC_SHA:
- return EncryptionAlgorithm.AES_256_CBC;
- case CipherSuite.TLS_DHE_PSK_WITH_AES_256_CCM:
- case CipherSuite.TLS_DHE_RSA_WITH_AES_256_CCM:
- case CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_256_CCM:
- case CipherSuite.TLS_PSK_WITH_AES_256_CCM:
- case CipherSuite.TLS_RSA_WITH_AES_256_CCM:
- return EncryptionAlgorithm.AES_256_CCM;
- case CipherSuite.TLS_DHE_RSA_WITH_AES_256_CCM_8:
- case CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8:
- case CipherSuite.TLS_PSK_DHE_WITH_AES_256_CCM_8:
- case CipherSuite.TLS_PSK_WITH_AES_256_CCM_8:
- case CipherSuite.TLS_RSA_WITH_AES_256_CCM_8:
- return EncryptionAlgorithm.AES_256_CCM_8;
- case CipherSuite.TLS_DH_DSS_WITH_AES_256_GCM_SHA384:
- case CipherSuite.TLS_DH_RSA_WITH_AES_256_GCM_SHA384:
- case CipherSuite.TLS_DHE_DSS_WITH_AES_256_GCM_SHA384:
- case CipherSuite.TLS_DHE_PSK_WITH_AES_256_GCM_SHA384:
- case CipherSuite.TLS_DHE_RSA_WITH_AES_256_GCM_SHA384:
- case CipherSuite.TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384:
- case CipherSuite.TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384:
- case CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384:
- case CipherSuite.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384:
- case CipherSuite.TLS_PSK_WITH_AES_256_GCM_SHA384:
- case CipherSuite.TLS_RSA_PSK_WITH_AES_256_GCM_SHA384:
- case CipherSuite.TLS_RSA_WITH_AES_256_GCM_SHA384:
- return EncryptionAlgorithm.AES_256_GCM;
- case CipherSuite.DRAFT_TLS_DHE_PSK_WITH_AES_256_OCB:
- case CipherSuite.DRAFT_TLS_DHE_RSA_WITH_AES_256_OCB:
- case CipherSuite.DRAFT_TLS_ECDHE_ECDSA_WITH_AES_256_OCB:
- case CipherSuite.DRAFT_TLS_ECDHE_PSK_WITH_AES_256_OCB:
- case CipherSuite.DRAFT_TLS_ECDHE_RSA_WITH_AES_256_OCB:
- case CipherSuite.DRAFT_TLS_PSK_WITH_AES_256_OCB:
- return EncryptionAlgorithm.AES_256_OCB_TAGLEN96;
- case CipherSuite.TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA:
- case CipherSuite.TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA:
- case CipherSuite.TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA:
- case CipherSuite.TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA:
- case CipherSuite.TLS_RSA_WITH_CAMELLIA_128_CBC_SHA:
- return EncryptionAlgorithm.CAMELLIA_128_CBC;
- case CipherSuite.TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA256:
- case CipherSuite.TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA256:
- case CipherSuite.TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256:
- case CipherSuite.TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256:
- case CipherSuite.TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256:
- case CipherSuite.TLS_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256:
- case CipherSuite.TLS_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256:
- case CipherSuite.TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256:
- case CipherSuite.TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256:
- case CipherSuite.TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256:
- case CipherSuite.TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256:
- case CipherSuite.TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256:
- case CipherSuite.TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256:
- return EncryptionAlgorithm.CAMELLIA_128_CBC;
- case CipherSuite.TLS_DH_DSS_WITH_CAMELLIA_128_GCM_SHA256:
- case CipherSuite.TLS_DH_RSA_WITH_CAMELLIA_128_GCM_SHA256:
- case CipherSuite.TLS_DHE_DSS_WITH_CAMELLIA_128_GCM_SHA256:
- case CipherSuite.TLS_DHE_PSK_WITH_CAMELLIA_128_GCM_SHA256:
- case CipherSuite.TLS_DHE_RSA_WITH_CAMELLIA_128_GCM_SHA256:
- case CipherSuite.TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256:
- case CipherSuite.TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256:
- case CipherSuite.TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_GCM_SHA256:
- case CipherSuite.TLS_ECDHE_RSA_WITH_CAMELLIA_128_GCM_SHA256:
- case CipherSuite.TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256:
- case CipherSuite.TLS_RSA_PSK_WITH_CAMELLIA_128_GCM_SHA256:
- case CipherSuite.TLS_RSA_WITH_CAMELLIA_128_GCM_SHA256:
- return EncryptionAlgorithm.CAMELLIA_128_GCM;
- case CipherSuite.TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA:
- case CipherSuite.TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA:
- case CipherSuite.TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA:
- case CipherSuite.TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA:
- case CipherSuite.TLS_RSA_WITH_CAMELLIA_256_CBC_SHA:
- return EncryptionAlgorithm.CAMELLIA_256_CBC;
- case CipherSuite.TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA256:
- case CipherSuite.TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA256:
- case CipherSuite.TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256:
- case CipherSuite.TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256:
- case CipherSuite.TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256:
- return EncryptionAlgorithm.CAMELLIA_256_CBC;
- case CipherSuite.TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384:
- case CipherSuite.TLS_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384:
- case CipherSuite.TLS_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384:
- case CipherSuite.TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384:
- case CipherSuite.TLS_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384:
- case CipherSuite.TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384:
- case CipherSuite.TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384:
- case CipherSuite.TLS_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384:
- return EncryptionAlgorithm.CAMELLIA_256_CBC;
- case CipherSuite.TLS_DH_DSS_WITH_CAMELLIA_256_GCM_SHA384:
- case CipherSuite.TLS_DH_RSA_WITH_CAMELLIA_256_GCM_SHA384:
- case CipherSuite.TLS_DHE_DSS_WITH_CAMELLIA_256_GCM_SHA384:
- case CipherSuite.TLS_DHE_PSK_WITH_CAMELLIA_256_GCM_SHA384:
- case CipherSuite.TLS_DHE_RSA_WITH_CAMELLIA_256_GCM_SHA384:
- case CipherSuite.TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384:
- case CipherSuite.TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384:
- case CipherSuite.TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_GCM_SHA384:
- case CipherSuite.TLS_ECDHE_RSA_WITH_CAMELLIA_256_GCM_SHA384:
- case CipherSuite.TLS_PSK_WITH_CAMELLIA_256_GCM_SHA384:
- case CipherSuite.TLS_RSA_PSK_WITH_CAMELLIA_256_GCM_SHA384:
- case CipherSuite.TLS_RSA_WITH_CAMELLIA_256_GCM_SHA384:
- return EncryptionAlgorithm.CAMELLIA_256_GCM;
- case CipherSuite.DRAFT_TLS_DHE_PSK_WITH_CHACHA20_POLY1305_SHA256:
- case CipherSuite.DRAFT_TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256:
- case CipherSuite.DRAFT_TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256:
- case CipherSuite.DRAFT_TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256:
- case CipherSuite.DRAFT_TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256:
- case CipherSuite.DRAFT_TLS_PSK_WITH_CHACHA20_POLY1305_SHA256:
- case CipherSuite.DRAFT_TLS_RSA_PSK_WITH_CHACHA20_POLY1305_SHA256:
- return EncryptionAlgorithm.CHACHA20_POLY1305;
- case CipherSuite.TLS_RSA_WITH_NULL_MD5:
- return EncryptionAlgorithm.NULL;
- case CipherSuite.TLS_DHE_PSK_WITH_NULL_SHA:
- case CipherSuite.TLS_ECDH_anon_WITH_NULL_SHA:
- case CipherSuite.TLS_ECDH_ECDSA_WITH_NULL_SHA:
- case CipherSuite.TLS_ECDH_RSA_WITH_NULL_SHA:
- case CipherSuite.TLS_ECDHE_ECDSA_WITH_NULL_SHA:
- case CipherSuite.TLS_ECDHE_PSK_WITH_NULL_SHA:
- case CipherSuite.TLS_ECDHE_RSA_WITH_NULL_SHA:
- case CipherSuite.TLS_PSK_WITH_NULL_SHA:
- case CipherSuite.TLS_RSA_PSK_WITH_NULL_SHA:
- case CipherSuite.TLS_RSA_WITH_NULL_SHA:
- return EncryptionAlgorithm.NULL;
- case CipherSuite.TLS_DHE_PSK_WITH_NULL_SHA256:
- case CipherSuite.TLS_ECDHE_PSK_WITH_NULL_SHA256:
- case CipherSuite.TLS_PSK_WITH_NULL_SHA256:
- case CipherSuite.TLS_RSA_PSK_WITH_NULL_SHA256:
- case CipherSuite.TLS_RSA_WITH_NULL_SHA256:
- return EncryptionAlgorithm.NULL;
- case CipherSuite.TLS_DHE_PSK_WITH_NULL_SHA384:
- case CipherSuite.TLS_ECDHE_PSK_WITH_NULL_SHA384:
- case CipherSuite.TLS_PSK_WITH_NULL_SHA384:
- case CipherSuite.TLS_RSA_PSK_WITH_NULL_SHA384:
- return EncryptionAlgorithm.NULL;
- case CipherSuite.TLS_DH_anon_WITH_RC4_128_MD5:
- case CipherSuite.TLS_RSA_WITH_RC4_128_MD5:
- return EncryptionAlgorithm.RC4_128;
- case CipherSuite.TLS_DHE_PSK_WITH_RC4_128_SHA:
- case CipherSuite.TLS_ECDH_anon_WITH_RC4_128_SHA:
- case CipherSuite.TLS_ECDH_ECDSA_WITH_RC4_128_SHA:
- case CipherSuite.TLS_ECDH_RSA_WITH_RC4_128_SHA:
- case CipherSuite.TLS_ECDHE_ECDSA_WITH_RC4_128_SHA:
- case CipherSuite.TLS_ECDHE_PSK_WITH_RC4_128_SHA:
- case CipherSuite.TLS_ECDHE_RSA_WITH_RC4_128_SHA:
- case CipherSuite.TLS_PSK_WITH_RC4_128_SHA:
- case CipherSuite.TLS_RSA_WITH_RC4_128_SHA:
- case CipherSuite.TLS_RSA_PSK_WITH_RC4_128_SHA:
- return EncryptionAlgorithm.RC4_128;
- case CipherSuite.TLS_DH_DSS_WITH_SEED_CBC_SHA:
- case CipherSuite.TLS_DH_RSA_WITH_SEED_CBC_SHA:
- case CipherSuite.TLS_DHE_DSS_WITH_SEED_CBC_SHA:
- case CipherSuite.TLS_DHE_RSA_WITH_SEED_CBC_SHA:
- case CipherSuite.TLS_RSA_WITH_SEED_CBC_SHA:
- return EncryptionAlgorithm.SEED_CBC;
- default:
- throw new TlsFatalAlert(AlertDescription.internal_error);
- }
- }
- public static int GetKeyExchangeAlgorithm(int ciphersuite)
- {
- switch (ciphersuite)
- {
- case CipherSuite.TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA:
- case CipherSuite.TLS_DH_DSS_WITH_AES_128_CBC_SHA:
- case CipherSuite.TLS_DH_DSS_WITH_AES_128_CBC_SHA256:
- case CipherSuite.TLS_DH_DSS_WITH_AES_128_GCM_SHA256:
- case CipherSuite.TLS_DH_DSS_WITH_AES_256_CBC_SHA:
- case CipherSuite.TLS_DH_DSS_WITH_AES_256_CBC_SHA256:
- case CipherSuite.TLS_DH_DSS_WITH_AES_256_GCM_SHA384:
- case CipherSuite.TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA:
- case CipherSuite.TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA256:
- case CipherSuite.TLS_DH_DSS_WITH_CAMELLIA_128_GCM_SHA256:
- case CipherSuite.TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA:
- case CipherSuite.TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA256:
- case CipherSuite.TLS_DH_DSS_WITH_CAMELLIA_256_GCM_SHA384:
- case CipherSuite.TLS_DH_DSS_WITH_SEED_CBC_SHA:
- return KeyExchangeAlgorithm.DH_DSS;
- case CipherSuite.TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA:
- case CipherSuite.TLS_DH_RSA_WITH_AES_128_CBC_SHA:
- case CipherSuite.TLS_DH_RSA_WITH_AES_128_CBC_SHA256:
- case CipherSuite.TLS_DH_RSA_WITH_AES_128_GCM_SHA256:
- case CipherSuite.TLS_DH_RSA_WITH_AES_256_CBC_SHA:
- case CipherSuite.TLS_DH_RSA_WITH_AES_256_CBC_SHA256:
- case CipherSuite.TLS_DH_RSA_WITH_AES_256_GCM_SHA384:
- case CipherSuite.TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA:
- case CipherSuite.TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA256:
- case CipherSuite.TLS_DH_RSA_WITH_CAMELLIA_128_GCM_SHA256:
- case CipherSuite.TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA:
- case CipherSuite.TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA256:
- case CipherSuite.TLS_DH_RSA_WITH_CAMELLIA_256_GCM_SHA384:
- case CipherSuite.TLS_DH_RSA_WITH_SEED_CBC_SHA:
- return KeyExchangeAlgorithm.DH_RSA;
- case CipherSuite.TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA:
- case CipherSuite.TLS_DHE_DSS_WITH_AES_128_CBC_SHA:
- case CipherSuite.TLS_DHE_DSS_WITH_AES_128_CBC_SHA256:
- case CipherSuite.TLS_DHE_DSS_WITH_AES_128_GCM_SHA256:
- case CipherSuite.TLS_DHE_DSS_WITH_AES_256_CBC_SHA:
- case CipherSuite.TLS_DHE_DSS_WITH_AES_256_CBC_SHA256:
- case CipherSuite.TLS_DHE_DSS_WITH_AES_256_GCM_SHA384:
- case CipherSuite.TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA:
- case CipherSuite.TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256:
- case CipherSuite.TLS_DHE_DSS_WITH_CAMELLIA_128_GCM_SHA256:
- case CipherSuite.TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA:
- case CipherSuite.TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256:
- case CipherSuite.TLS_DHE_DSS_WITH_CAMELLIA_256_GCM_SHA384:
- case CipherSuite.TLS_DHE_DSS_WITH_SEED_CBC_SHA:
- return KeyExchangeAlgorithm.DHE_DSS;
- case CipherSuite.TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA:
- case CipherSuite.TLS_DHE_PSK_WITH_AES_128_CBC_SHA:
- case CipherSuite.TLS_DHE_PSK_WITH_AES_128_CBC_SHA256:
- case CipherSuite.TLS_DHE_PSK_WITH_AES_128_CCM:
- case CipherSuite.TLS_DHE_PSK_WITH_AES_128_GCM_SHA256:
- case CipherSuite.DRAFT_TLS_DHE_PSK_WITH_AES_128_OCB:
- case CipherSuite.TLS_DHE_PSK_WITH_AES_256_CBC_SHA:
- case CipherSuite.TLS_DHE_PSK_WITH_AES_256_CBC_SHA384:
- case CipherSuite.TLS_DHE_PSK_WITH_AES_256_CCM:
- case CipherSuite.TLS_DHE_PSK_WITH_AES_256_GCM_SHA384:
- case CipherSuite.DRAFT_TLS_DHE_PSK_WITH_AES_256_OCB:
- case CipherSuite.TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256:
- case CipherSuite.TLS_DHE_PSK_WITH_CAMELLIA_128_GCM_SHA256:
- case CipherSuite.TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384:
- case CipherSuite.TLS_DHE_PSK_WITH_CAMELLIA_256_GCM_SHA384:
- case CipherSuite.DRAFT_TLS_DHE_PSK_WITH_CHACHA20_POLY1305_SHA256:
- case CipherSuite.TLS_DHE_PSK_WITH_NULL_SHA:
- case CipherSuite.TLS_DHE_PSK_WITH_NULL_SHA256:
- case CipherSuite.TLS_DHE_PSK_WITH_NULL_SHA384:
- case CipherSuite.TLS_DHE_PSK_WITH_RC4_128_SHA:
- case CipherSuite.TLS_PSK_DHE_WITH_AES_128_CCM_8:
- case CipherSuite.TLS_PSK_DHE_WITH_AES_256_CCM_8:
- return KeyExchangeAlgorithm.DHE_PSK;
- case CipherSuite.TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA:
- case CipherSuite.TLS_DHE_RSA_WITH_AES_128_CBC_SHA:
- case CipherSuite.TLS_DHE_RSA_WITH_AES_128_CBC_SHA256:
- case CipherSuite.TLS_DHE_RSA_WITH_AES_128_CCM:
- case CipherSuite.TLS_DHE_RSA_WITH_AES_128_CCM_8:
- case CipherSuite.TLS_DHE_RSA_WITH_AES_128_GCM_SHA256:
- case CipherSuite.DRAFT_TLS_DHE_RSA_WITH_AES_128_OCB:
- case CipherSuite.TLS_DHE_RSA_WITH_AES_256_CBC_SHA:
- case CipherSuite.TLS_DHE_RSA_WITH_AES_256_CBC_SHA256:
- case CipherSuite.TLS_DHE_RSA_WITH_AES_256_CCM:
- case CipherSuite.TLS_DHE_RSA_WITH_AES_256_CCM_8:
- case CipherSuite.TLS_DHE_RSA_WITH_AES_256_GCM_SHA384:
- case CipherSuite.DRAFT_TLS_DHE_RSA_WITH_AES_256_OCB:
- case CipherSuite.TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA:
- case CipherSuite.TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256:
- case CipherSuite.TLS_DHE_RSA_WITH_CAMELLIA_128_GCM_SHA256:
- case CipherSuite.TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA:
- case CipherSuite.TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256:
- case CipherSuite.TLS_DHE_RSA_WITH_CAMELLIA_256_GCM_SHA384:
- case CipherSuite.DRAFT_TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256:
- case CipherSuite.TLS_DHE_RSA_WITH_SEED_CBC_SHA:
- return KeyExchangeAlgorithm.DHE_RSA;
- case CipherSuite.TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA:
- case CipherSuite.TLS_ECDH_anon_WITH_AES_128_CBC_SHA:
- case CipherSuite.TLS_ECDH_anon_WITH_AES_256_CBC_SHA:
- case CipherSuite.TLS_ECDH_anon_WITH_NULL_SHA:
- case CipherSuite.TLS_ECDH_anon_WITH_RC4_128_SHA:
- return KeyExchangeAlgorithm.ECDH_anon;
- case CipherSuite.TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA:
- case CipherSuite.TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA:
- case CipherSuite.TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256:
- case CipherSuite.TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256:
- case CipherSuite.DRAFT_TLS_ECDHE_ECDSA_WITH_AES_128_OCB:
- case CipherSuite.TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA:
- case CipherSuite.TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384:
- case CipherSuite.TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384:
- case CipherSuite.DRAFT_TLS_ECDHE_ECDSA_WITH_AES_256_OCB:
- case CipherSuite.TLS_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256:
- case CipherSuite.TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256:
- case CipherSuite.TLS_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384:
- case CipherSuite.TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384:
- case CipherSuite.TLS_ECDH_ECDSA_WITH_NULL_SHA:
- case CipherSuite.TLS_ECDH_ECDSA_WITH_RC4_128_SHA:
- return KeyExchangeAlgorithm.ECDH_ECDSA;
- case CipherSuite.TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA:
- case CipherSuite.TLS_ECDH_RSA_WITH_AES_128_CBC_SHA:
- case CipherSuite.TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256:
- case CipherSuite.TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256:
- case CipherSuite.TLS_ECDH_RSA_WITH_AES_256_CBC_SHA:
- case CipherSuite.TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384:
- case CipherSuite.TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384:
- case CipherSuite.TLS_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256:
- case CipherSuite.TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256:
- case CipherSuite.TLS_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384:
- case CipherSuite.TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384:
- case CipherSuite.TLS_ECDH_RSA_WITH_NULL_SHA:
- case CipherSuite.TLS_ECDH_RSA_WITH_RC4_128_SHA:
- return KeyExchangeAlgorithm.ECDH_RSA;
- case CipherSuite.TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA:
- case CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA:
- case CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256:
- case CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_CCM:
- case CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8:
- case CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256:
- case CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA:
- case CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384:
- case CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_256_CCM:
- case CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8:
- case CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384:
- case CipherSuite.TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256:
- case CipherSuite.TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_GCM_SHA256:
- case CipherSuite.TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384:
- case CipherSuite.TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_GCM_SHA384:
- case CipherSuite.DRAFT_TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256:
- case CipherSuite.TLS_ECDHE_ECDSA_WITH_NULL_SHA:
- case CipherSuite.TLS_ECDHE_ECDSA_WITH_RC4_128_SHA:
- return KeyExchangeAlgorithm.ECDHE_ECDSA;
- case CipherSuite.TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA:
- case CipherSuite.TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA:
- case CipherSuite.TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256:
- case CipherSuite.DRAFT_TLS_ECDHE_PSK_WITH_AES_128_OCB:
- case CipherSuite.TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA:
- case CipherSuite.TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384:
- case CipherSuite.DRAFT_TLS_ECDHE_PSK_WITH_AES_256_OCB:
- case CipherSuite.TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256:
- case CipherSuite.TLS_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384:
- case CipherSuite.DRAFT_TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256:
- case CipherSuite.TLS_ECDHE_PSK_WITH_NULL_SHA:
- case CipherSuite.TLS_ECDHE_PSK_WITH_NULL_SHA256:
- case CipherSuite.TLS_ECDHE_PSK_WITH_NULL_SHA384:
- case CipherSuite.TLS_ECDHE_PSK_WITH_RC4_128_SHA:
- return KeyExchangeAlgorithm.ECDHE_PSK;
- case CipherSuite.TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA:
- case CipherSuite.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA:
- case CipherSuite.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256:
- case CipherSuite.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256:
- case CipherSuite.DRAFT_TLS_ECDHE_RSA_WITH_AES_128_OCB:
- case CipherSuite.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA:
- case CipherSuite.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384:
- case CipherSuite.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384:
- case CipherSuite.DRAFT_TLS_ECDHE_RSA_WITH_AES_256_OCB:
- case CipherSuite.TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256:
- case CipherSuite.TLS_ECDHE_RSA_WITH_CAMELLIA_128_GCM_SHA256:
- case CipherSuite.TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384:
- case CipherSuite.TLS_ECDHE_RSA_WITH_CAMELLIA_256_GCM_SHA384:
- case CipherSuite.DRAFT_TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256:
- case CipherSuite.TLS_ECDHE_RSA_WITH_NULL_SHA:
- case CipherSuite.TLS_ECDHE_RSA_WITH_RC4_128_SHA:
- return KeyExchangeAlgorithm.ECDHE_RSA;
- case CipherSuite.TLS_PSK_WITH_3DES_EDE_CBC_SHA:
- case CipherSuite.TLS_PSK_WITH_AES_128_CBC_SHA:
- case CipherSuite.TLS_PSK_WITH_AES_128_CBC_SHA256:
- case CipherSuite.TLS_PSK_WITH_AES_128_CCM:
- case CipherSuite.TLS_PSK_WITH_AES_128_CCM_8:
- case CipherSuite.TLS_PSK_WITH_AES_128_GCM_SHA256:
- case CipherSuite.DRAFT_TLS_PSK_WITH_AES_128_OCB:
- case CipherSuite.TLS_PSK_WITH_AES_256_CBC_SHA:
- case CipherSuite.TLS_PSK_WITH_AES_256_CBC_SHA384:
- case CipherSuite.TLS_PSK_WITH_AES_256_CCM:
- case CipherSuite.TLS_PSK_WITH_AES_256_CCM_8:
- case CipherSuite.TLS_PSK_WITH_AES_256_GCM_SHA384:
- case CipherSuite.DRAFT_TLS_PSK_WITH_AES_256_OCB:
- case CipherSuite.TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256:
- case CipherSuite.TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256:
- case CipherSuite.TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384:
- case CipherSuite.TLS_PSK_WITH_CAMELLIA_256_GCM_SHA384:
- case CipherSuite.DRAFT_TLS_PSK_WITH_CHACHA20_POLY1305_SHA256:
- case CipherSuite.TLS_PSK_WITH_NULL_SHA:
- case CipherSuite.TLS_PSK_WITH_NULL_SHA256:
- case CipherSuite.TLS_PSK_WITH_NULL_SHA384:
- case CipherSuite.TLS_PSK_WITH_RC4_128_SHA:
- return KeyExchangeAlgorithm.PSK;
- case CipherSuite.TLS_RSA_WITH_3DES_EDE_CBC_SHA:
- case CipherSuite.TLS_RSA_WITH_AES_128_CBC_SHA:
- case CipherSuite.TLS_RSA_WITH_AES_128_CBC_SHA256:
- case CipherSuite.TLS_RSA_WITH_AES_128_CCM:
- case CipherSuite.TLS_RSA_WITH_AES_128_CCM_8:
- case CipherSuite.TLS_RSA_WITH_AES_128_GCM_SHA256:
- case CipherSuite.TLS_RSA_WITH_AES_256_CBC_SHA:
- case CipherSuite.TLS_RSA_WITH_AES_256_CBC_SHA256:
- case CipherSuite.TLS_RSA_WITH_AES_256_CCM:
- case CipherSuite.TLS_RSA_WITH_AES_256_CCM_8:
- case CipherSuite.TLS_RSA_WITH_AES_256_GCM_SHA384:
- case CipherSuite.TLS_RSA_WITH_CAMELLIA_128_CBC_SHA:
- case CipherSuite.TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256:
- case CipherSuite.TLS_RSA_WITH_CAMELLIA_128_GCM_SHA256:
- case CipherSuite.TLS_RSA_WITH_CAMELLIA_256_CBC_SHA:
- case CipherSuite.TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256:
- case CipherSuite.TLS_RSA_WITH_CAMELLIA_256_GCM_SHA384:
- case CipherSuite.DRAFT_TLS_RSA_PSK_WITH_CHACHA20_POLY1305_SHA256:
- case CipherSuite.TLS_RSA_WITH_NULL_MD5:
- case CipherSuite.TLS_RSA_WITH_NULL_SHA:
- case CipherSuite.TLS_RSA_WITH_NULL_SHA256:
- case CipherSuite.TLS_RSA_WITH_RC4_128_MD5:
- case CipherSuite.TLS_RSA_WITH_RC4_128_SHA:
- case CipherSuite.TLS_RSA_WITH_SEED_CBC_SHA:
- return KeyExchangeAlgorithm.RSA;
- case CipherSuite.TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA:
- case CipherSuite.TLS_RSA_PSK_WITH_AES_128_CBC_SHA:
- case CipherSuite.TLS_RSA_PSK_WITH_AES_128_CBC_SHA256:
- case CipherSuite.TLS_RSA_PSK_WITH_AES_128_GCM_SHA256:
- case CipherSuite.TLS_RSA_PSK_WITH_AES_256_CBC_SHA:
- case CipherSuite.TLS_RSA_PSK_WITH_AES_256_CBC_SHA384:
- case CipherSuite.TLS_RSA_PSK_WITH_AES_256_GCM_SHA384:
- case CipherSuite.TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256:
- case CipherSuite.TLS_RSA_PSK_WITH_CAMELLIA_128_GCM_SHA256:
- case CipherSuite.TLS_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384:
- case CipherSuite.TLS_RSA_PSK_WITH_CAMELLIA_256_GCM_SHA384:
- case CipherSuite.TLS_RSA_PSK_WITH_NULL_SHA:
- case CipherSuite.TLS_RSA_PSK_WITH_NULL_SHA256:
- case CipherSuite.TLS_RSA_PSK_WITH_NULL_SHA384:
- case CipherSuite.TLS_RSA_PSK_WITH_RC4_128_SHA:
- return KeyExchangeAlgorithm.RSA_PSK;
- case CipherSuite.TLS_SRP_SHA_WITH_3DES_EDE_CBC_SHA:
- case CipherSuite.TLS_SRP_SHA_WITH_AES_128_CBC_SHA:
- case CipherSuite.TLS_SRP_SHA_WITH_AES_256_CBC_SHA:
- return KeyExchangeAlgorithm.SRP;
- case CipherSuite.TLS_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA:
- case CipherSuite.TLS_SRP_SHA_DSS_WITH_AES_128_CBC_SHA:
- case CipherSuite.TLS_SRP_SHA_DSS_WITH_AES_256_CBC_SHA:
- return KeyExchangeAlgorithm.SRP_DSS;
- case CipherSuite.TLS_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA:
- case CipherSuite.TLS_SRP_SHA_RSA_WITH_AES_128_CBC_SHA:
- case CipherSuite.TLS_SRP_SHA_RSA_WITH_AES_256_CBC_SHA:
- return KeyExchangeAlgorithm.SRP_RSA;
- default:
- throw new TlsFatalAlert(AlertDescription.internal_error);
- }
- }
- public static int GetMacAlgorithm(int ciphersuite)
- {
- switch (ciphersuite)
- {
- case CipherSuite.TLS_DH_DSS_WITH_AES_128_GCM_SHA256:
- case CipherSuite.TLS_DH_DSS_WITH_AES_256_GCM_SHA384:
- case CipherSuite.TLS_DH_DSS_WITH_CAMELLIA_128_GCM_SHA256:
- case CipherSuite.TLS_DH_DSS_WITH_CAMELLIA_256_GCM_SHA384:
- case CipherSuite.TLS_DH_RSA_WITH_AES_128_GCM_SHA256:
- case CipherSuite.TLS_DH_RSA_WITH_AES_256_GCM_SHA384:
- case CipherSuite.TLS_DH_RSA_WITH_CAMELLIA_128_GCM_SHA256:
- case CipherSuite.TLS_DH_RSA_WITH_CAMELLIA_256_GCM_SHA384:
- case CipherSuite.TLS_DHE_DSS_WITH_AES_128_GCM_SHA256:
- case CipherSuite.TLS_DHE_DSS_WITH_AES_256_GCM_SHA384:
- case CipherSuite.TLS_DHE_DSS_WITH_CAMELLIA_128_GCM_SHA256:
- case CipherSuite.TLS_DHE_DSS_WITH_CAMELLIA_256_GCM_SHA384:
- case CipherSuite.TLS_DHE_PSK_WITH_AES_128_CCM:
- case CipherSuite.TLS_DHE_PSK_WITH_AES_128_GCM_SHA256:
- case CipherSuite.DRAFT_TLS_DHE_PSK_WITH_AES_128_OCB:
- case CipherSuite.TLS_DHE_PSK_WITH_AES_256_CCM:
- case CipherSuite.TLS_DHE_PSK_WITH_AES_256_GCM_SHA384:
- case CipherSuite.DRAFT_TLS_DHE_PSK_WITH_AES_256_OCB:
- case CipherSuite.TLS_DHE_PSK_WITH_CAMELLIA_128_GCM_SHA256:
- case CipherSuite.TLS_DHE_PSK_WITH_CAMELLIA_256_GCM_SHA384:
- case CipherSuite.DRAFT_TLS_DHE_PSK_WITH_CHACHA20_POLY1305_SHA256:
- case CipherSuite.TLS_DHE_RSA_WITH_AES_128_CCM:
- case CipherSuite.TLS_DHE_RSA_WITH_AES_128_CCM_8:
- case CipherSuite.TLS_DHE_RSA_WITH_AES_128_GCM_SHA256:
- case CipherSuite.DRAFT_TLS_DHE_RSA_WITH_AES_128_OCB:
- case CipherSuite.TLS_DHE_RSA_WITH_AES_256_CCM:
- case CipherSuite.TLS_DHE_RSA_WITH_AES_256_CCM_8:
- case CipherSuite.TLS_DHE_RSA_WITH_AES_256_GCM_SHA384:
- case CipherSuite.DRAFT_TLS_DHE_RSA_WITH_AES_256_OCB:
- case CipherSuite.TLS_DHE_RSA_WITH_CAMELLIA_128_GCM_SHA256:
- case CipherSuite.TLS_DHE_RSA_WITH_CAMELLIA_256_GCM_SHA384:
- case CipherSuite.DRAFT_TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256:
- case CipherSuite.TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256:
- case CipherSuite.TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384:
- case CipherSuite.TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256:
- case CipherSuite.TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384:
- case CipherSuite.TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256:
- case CipherSuite.TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384:
- case CipherSuite.TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256:
- case CipherSuite.TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384:
- case CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_CCM:
- case CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8:
- case CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256:
- case CipherSuite.DRAFT_TLS_ECDHE_ECDSA_WITH_AES_128_OCB:
- case CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_256_CCM:
- case CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8:
- case CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384:
- case CipherSuite.DRAFT_TLS_ECDHE_ECDSA_WITH_AES_256_OCB:
- case CipherSuite.TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_GCM_SHA256:
- case CipherSuite.TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_GCM_SHA384:
- case CipherSuite.DRAFT_TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256:
- case CipherSuite.DRAFT_TLS_ECDHE_PSK_WITH_AES_128_OCB:
- case CipherSuite.DRAFT_TLS_ECDHE_PSK_WITH_AES_256_OCB:
- case CipherSuite.DRAFT_TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256:
- case CipherSuite.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256:
- case CipherSuite.DRAFT_TLS_ECDHE_RSA_WITH_AES_128_OCB:
- case CipherSuite.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384:
- case CipherSuite.DRAFT_TLS_ECDHE_RSA_WITH_AES_256_OCB:
- case CipherSuite.TLS_ECDHE_RSA_WITH_CAMELLIA_128_GCM_SHA256:
- case CipherSuite.TLS_ECDHE_RSA_WITH_CAMELLIA_256_GCM_SHA384:
- case CipherSuite.DRAFT_TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256:
- case CipherSuite.TLS_PSK_DHE_WITH_AES_128_CCM_8:
- case CipherSuite.TLS_PSK_DHE_WITH_AES_256_CCM_8:
- case CipherSuite.TLS_PSK_WITH_AES_128_CCM:
- case CipherSuite.TLS_PSK_WITH_AES_128_CCM_8:
- case CipherSuite.TLS_PSK_WITH_AES_128_GCM_SHA256:
- case CipherSuite.DRAFT_TLS_PSK_WITH_AES_128_OCB:
- case CipherSuite.TLS_PSK_WITH_AES_256_CCM:
- case CipherSuite.TLS_PSK_WITH_AES_256_CCM_8:
- case CipherSuite.TLS_PSK_WITH_AES_256_GCM_SHA384:
- case CipherSuite.DRAFT_TLS_PSK_WITH_AES_256_OCB:
- case CipherSuite.TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256:
- case CipherSuite.TLS_PSK_WITH_CAMELLIA_256_GCM_SHA384:
- case CipherSuite.DRAFT_TLS_PSK_WITH_CHACHA20_POLY1305_SHA256:
- case CipherSuite.TLS_RSA_PSK_WITH_AES_128_GCM_SHA256:
- case CipherSuite.TLS_RSA_PSK_WITH_AES_256_GCM_SHA384:
- case CipherSuite.TLS_RSA_PSK_WITH_CAMELLIA_128_GCM_SHA256:
- case CipherSuite.TLS_RSA_PSK_WITH_CAMELLIA_256_GCM_SHA384:
- case CipherSuite.DRAFT_TLS_RSA_PSK_WITH_CHACHA20_POLY1305_SHA256:
- case CipherSuite.TLS_RSA_WITH_AES_128_CCM:
- case CipherSuite.TLS_RSA_WITH_AES_128_CCM_8:
- case CipherSuite.TLS_RSA_WITH_AES_128_GCM_SHA256:
- case CipherSuite.TLS_RSA_WITH_AES_256_CCM:
- case CipherSuite.TLS_RSA_WITH_AES_256_CCM_8:
- case CipherSuite.TLS_RSA_WITH_AES_256_GCM_SHA384:
- case CipherSuite.TLS_RSA_WITH_CAMELLIA_128_GCM_SHA256:
- case CipherSuite.TLS_RSA_WITH_CAMELLIA_256_GCM_SHA384:
- return MacAlgorithm.cls_null;
- case CipherSuite.TLS_RSA_WITH_NULL_MD5:
- case CipherSuite.TLS_RSA_WITH_RC4_128_MD5:
- return MacAlgorithm.hmac_md5;
- case CipherSuite.TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA:
- case CipherSuite.TLS_DH_DSS_WITH_AES_128_CBC_SHA:
- case CipherSuite.TLS_DH_DSS_WITH_AES_256_CBC_SHA:
- case CipherSuite.TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA:
- case CipherSuite.TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA:
- case CipherSuite.TLS_DH_DSS_WITH_SEED_CBC_SHA:
- case CipherSuite.TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA:
- case CipherSuite.TLS_DH_RSA_WITH_AES_128_CBC_SHA:
- case CipherSuite.TLS_DH_RSA_WITH_AES_256_CBC_SHA:
- case CipherSuite.TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA:
- case CipherSuite.TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA:
- case CipherSuite.TLS_DH_RSA_WITH_SEED_CBC_SHA:
- case CipherSuite.TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA:
- case CipherSuite.TLS_DHE_DSS_WITH_AES_128_CBC_SHA:
- case CipherSuite.TLS_DHE_DSS_WITH_AES_256_CBC_SHA:
- case CipherSuite.TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA:
- case CipherSuite.TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA:
- case CipherSuite.TLS_DHE_DSS_WITH_SEED_CBC_SHA:
- case CipherSuite.TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA:
- case CipherSuite.TLS_DHE_PSK_WITH_AES_128_CBC_SHA:
- case CipherSuite.TLS_DHE_PSK_WITH_AES_256_CBC_SHA:
- case CipherSuite.TLS_DHE_PSK_WITH_NULL_SHA:
- case CipherSuite.TLS_DHE_PSK_WITH_RC4_128_SHA:
- case CipherSuite.TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA:
- case CipherSuite.TLS_DHE_RSA_WITH_AES_128_CBC_SHA:
- case CipherSuite.TLS_DHE_RSA_WITH_AES_256_CBC_SHA:
- case CipherSuite.TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA:
- case CipherSuite.TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA:
- case CipherSuite.TLS_DHE_RSA_WITH_SEED_CBC_SHA:
- case CipherSuite.TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA:
- case CipherSuite.TLS_ECDH_anon_WITH_AES_128_CBC_SHA:
- case CipherSuite.TLS_ECDH_anon_WITH_AES_256_CBC_SHA:
- case CipherSuite.TLS_ECDH_anon_WITH_NULL_SHA:
- case CipherSuite.TLS_ECDH_anon_WITH_RC4_128_SHA:
- case CipherSuite.TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA:
- case CipherSuite.TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA:
- case CipherSuite.TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA:
- case CipherSuite.TLS_ECDH_ECDSA_WITH_NULL_SHA:
- case CipherSuite.TLS_ECDH_ECDSA_WITH_RC4_128_SHA:
- case CipherSuite.TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA:
- case CipherSuite.TLS_ECDH_RSA_WITH_AES_128_CBC_SHA:
- case CipherSuite.TLS_ECDH_RSA_WITH_AES_256_CBC_SHA:
- case CipherSuite.TLS_ECDH_RSA_WITH_NULL_SHA:
- case CipherSuite.TLS_ECDH_RSA_WITH_RC4_128_SHA:
- case CipherSuite.TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA:
- case CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA:
- case CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA:
- case CipherSuite.TLS_ECDHE_ECDSA_WITH_NULL_SHA:
- case CipherSuite.TLS_ECDHE_ECDSA_WITH_RC4_128_SHA:
- case CipherSuite.TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA:
- case CipherSuite.TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA:
- case CipherSuite.TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA:
- case CipherSuite.TLS_ECDHE_PSK_WITH_NULL_SHA:
- case CipherSuite.TLS_ECDHE_PSK_WITH_RC4_128_SHA:
- case CipherSuite.TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA:
- case CipherSuite.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA:
- case CipherSuite.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA:
- case CipherSuite.TLS_ECDHE_RSA_WITH_NULL_SHA:
- case CipherSuite.TLS_ECDHE_RSA_WITH_RC4_128_SHA:
- case CipherSuite.TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA:
- case CipherSuite.TLS_RSA_PSK_WITH_AES_128_CBC_SHA:
- case CipherSuite.TLS_RSA_PSK_WITH_AES_256_CBC_SHA:
- case CipherSuite.TLS_PSK_WITH_3DES_EDE_CBC_SHA:
- case CipherSuite.TLS_PSK_WITH_AES_128_CBC_SHA:
- case CipherSuite.TLS_PSK_WITH_AES_256_CBC_SHA:
- case CipherSuite.TLS_PSK_WITH_NULL_SHA:
- case CipherSuite.TLS_PSK_WITH_RC4_128_SHA:
- case CipherSuite.TLS_RSA_PSK_WITH_NULL_SHA:
- case CipherSuite.TLS_RSA_PSK_WITH_RC4_128_SHA:
- case CipherSuite.TLS_RSA_WITH_3DES_EDE_CBC_SHA:
- case CipherSuite.TLS_RSA_WITH_AES_128_CBC_SHA:
- case CipherSuite.TLS_RSA_WITH_AES_256_CBC_SHA:
- case CipherSuite.TLS_RSA_WITH_CAMELLIA_128_CBC_SHA:
- case CipherSuite.TLS_RSA_WITH_CAMELLIA_256_CBC_SHA:
- case CipherSuite.TLS_RSA_WITH_NULL_SHA:
- case CipherSuite.TLS_RSA_WITH_RC4_128_SHA:
- case CipherSuite.TLS_RSA_WITH_SEED_CBC_SHA:
- case CipherSuite.TLS_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA:
- case CipherSuite.TLS_SRP_SHA_DSS_WITH_AES_128_CBC_SHA:
- case CipherSuite.TLS_SRP_SHA_DSS_WITH_AES_256_CBC_SHA:
- case CipherSuite.TLS_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA:
- case CipherSuite.TLS_SRP_SHA_RSA_WITH_AES_128_CBC_SHA:
- case CipherSuite.TLS_SRP_SHA_RSA_WITH_AES_256_CBC_SHA:
- case CipherSuite.TLS_SRP_SHA_WITH_3DES_EDE_CBC_SHA:
- case CipherSuite.TLS_SRP_SHA_WITH_AES_128_CBC_SHA:
- case CipherSuite.TLS_SRP_SHA_WITH_AES_256_CBC_SHA:
- return MacAlgorithm.hmac_sha1;
- case CipherSuite.TLS_DH_DSS_WITH_AES_128_CBC_SHA256:
- case CipherSuite.TLS_DH_DSS_WITH_AES_256_CBC_SHA256:
- case CipherSuite.TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA256:
- case CipherSuite.TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA256:
- case CipherSuite.TLS_DH_RSA_WITH_AES_128_CBC_SHA256:
- case CipherSuite.TLS_DH_RSA_WITH_AES_256_CBC_SHA256:
- case CipherSuite.TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA256:
- case CipherSuite.TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA256:
- case CipherSuite.TLS_DHE_DSS_WITH_AES_128_CBC_SHA256:
- case CipherSuite.TLS_DHE_DSS_WITH_AES_256_CBC_SHA256:
- case CipherSuite.TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256:
- case CipherSuite.TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256:
- case CipherSuite.TLS_DHE_PSK_WITH_AES_128_CBC_SHA256:
- case CipherSuite.TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256:
- case CipherSuite.TLS_DHE_PSK_WITH_NULL_SHA256:
- case CipherSuite.TLS_DHE_RSA_WITH_AES_128_CBC_SHA256:
- case CipherSuite.TLS_DHE_RSA_WITH_AES_256_CBC_SHA256:
- case CipherSuite.TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256:
- case CipherSuite.TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256:
- case CipherSuite.TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256:
- case CipherSuite.TLS_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256:
- case CipherSuite.TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256:
- case CipherSuite.TLS_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256:
- case CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256:
- case CipherSuite.TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256:
- case CipherSuite.TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256:
- case CipherSuite.TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256:
- case CipherSuite.TLS_ECDHE_PSK_WITH_NULL_SHA256:
- case CipherSuite.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256:
- case CipherSuite.TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256:
- case CipherSuite.TLS_PSK_WITH_AES_128_CBC_SHA256:
- case CipherSuite.TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256:
- case CipherSuite.TLS_PSK_WITH_NULL_SHA256:
- case CipherSuite.TLS_RSA_PSK_WITH_AES_128_CBC_SHA256:
- case CipherSuite.TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256:
- case CipherSuite.TLS_RSA_PSK_WITH_NULL_SHA256:
- case CipherSuite.TLS_RSA_WITH_AES_128_CBC_SHA256:
- case CipherSuite.TLS_RSA_WITH_AES_256_CBC_SHA256:
- case CipherSuite.TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256:
- case CipherSuite.TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256:
- case CipherSuite.TLS_RSA_WITH_NULL_SHA256:
- return MacAlgorithm.hmac_sha256;
- case CipherSuite.TLS_DHE_PSK_WITH_AES_256_CBC_SHA384:
- case CipherSuite.TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384:
- case CipherSuite.TLS_DHE_PSK_WITH_NULL_SHA384:
- case CipherSuite.TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384:
- case CipherSuite.TLS_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384:
- case CipherSuite.TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384:
- case CipherSuite.TLS_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384:
- case CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384:
- case CipherSuite.TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384:
- case CipherSuite.TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384:
- case CipherSuite.TLS_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384:
- case CipherSuite.TLS_ECDHE_PSK_WITH_NULL_SHA384:
- case CipherSuite.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384:
- case CipherSuite.TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384:
- case CipherSuite.TLS_PSK_WITH_AES_256_CBC_SHA384:
- case CipherSuite.TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384:
- case CipherSuite.TLS_PSK_WITH_NULL_SHA384:
- case CipherSuite.TLS_RSA_PSK_WITH_AES_256_CBC_SHA384:
- case CipherSuite.TLS_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384:
- case CipherSuite.TLS_RSA_PSK_WITH_NULL_SHA384:
- return MacAlgorithm.hmac_sha384;
- default:
- throw new TlsFatalAlert(AlertDescription.internal_error);
- }
- }
- public static ProtocolVersion GetMinimumVersion(int ciphersuite)
- {
- switch (ciphersuite)
- {
- case CipherSuite.TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA256:
- case CipherSuite.TLS_DH_anon_WITH_CAMELLIA_128_GCM_SHA256:
- case CipherSuite.TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA256:
- case CipherSuite.TLS_DH_anon_WITH_CAMELLIA_256_GCM_SHA384:
- case CipherSuite.TLS_DH_DSS_WITH_AES_128_CBC_SHA256:
- case CipherSuite.TLS_DH_DSS_WITH_AES_128_GCM_SHA256:
- case CipherSuite.TLS_DH_DSS_WITH_AES_256_CBC_SHA256:
- case CipherSuite.TLS_DH_DSS_WITH_AES_256_GCM_SHA384:
- case CipherSuite.TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA256:
- case CipherSuite.TLS_DH_DSS_WITH_CAMELLIA_128_GCM_SHA256:
- case CipherSuite.TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA256:
- case CipherSuite.TLS_DH_DSS_WITH_CAMELLIA_256_GCM_SHA384:
- case CipherSuite.TLS_DH_RSA_WITH_AES_128_CBC_SHA256:
- case CipherSuite.TLS_DH_RSA_WITH_AES_128_GCM_SHA256:
- case CipherSuite.TLS_DH_RSA_WITH_AES_256_CBC_SHA256:
- case CipherSuite.TLS_DH_RSA_WITH_AES_256_GCM_SHA384:
- case CipherSuite.TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA256:
- case CipherSuite.TLS_DH_RSA_WITH_CAMELLIA_128_GCM_SHA256:
- case CipherSuite.TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA256:
- case CipherSuite.TLS_DH_RSA_WITH_CAMELLIA_256_GCM_SHA384:
- case CipherSuite.TLS_DHE_DSS_WITH_AES_128_CBC_SHA256:
- case CipherSuite.TLS_DHE_DSS_WITH_AES_128_GCM_SHA256:
- case CipherSuite.TLS_DHE_DSS_WITH_AES_256_CBC_SHA256:
- case CipherSuite.TLS_DHE_DSS_WITH_AES_256_GCM_SHA384:
- case CipherSuite.TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256:
- case CipherSuite.TLS_DHE_DSS_WITH_CAMELLIA_128_GCM_SHA256:
- case CipherSuite.TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256:
- case CipherSuite.TLS_DHE_DSS_WITH_CAMELLIA_256_GCM_SHA384:
- case CipherSuite.TLS_DHE_PSK_WITH_AES_128_CCM:
- case CipherSuite.TLS_DHE_PSK_WITH_AES_128_GCM_SHA256:
- case CipherSuite.DRAFT_TLS_DHE_PSK_WITH_AES_128_OCB:
- case CipherSuite.TLS_DHE_PSK_WITH_AES_256_CCM:
- case CipherSuite.TLS_DHE_PSK_WITH_AES_256_GCM_SHA384:
- case CipherSuite.DRAFT_TLS_DHE_PSK_WITH_AES_256_OCB:
- case CipherSuite.TLS_DHE_PSK_WITH_CAMELLIA_128_GCM_SHA256:
- case CipherSuite.TLS_DHE_PSK_WITH_CAMELLIA_256_GCM_SHA384:
- case CipherSuite.DRAFT_TLS_DHE_PSK_WITH_CHACHA20_POLY1305_SHA256:
- case CipherSuite.TLS_DHE_RSA_WITH_AES_128_CBC_SHA256:
- case CipherSuite.TLS_DHE_RSA_WITH_AES_128_CCM:
- case CipherSuite.TLS_DHE_RSA_WITH_AES_128_CCM_8:
- case CipherSuite.TLS_DHE_RSA_WITH_AES_128_GCM_SHA256:
- case CipherSuite.DRAFT_TLS_DHE_RSA_WITH_AES_128_OCB:
- case CipherSuite.TLS_DHE_RSA_WITH_AES_256_CBC_SHA256:
- case CipherSuite.TLS_DHE_RSA_WITH_AES_256_CCM:
- case CipherSuite.TLS_DHE_RSA_WITH_AES_256_CCM_8:
- case CipherSuite.TLS_DHE_RSA_WITH_AES_256_GCM_SHA384:
- case CipherSuite.DRAFT_TLS_DHE_RSA_WITH_AES_256_OCB:
- case CipherSuite.TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256:
- case CipherSuite.TLS_DHE_RSA_WITH_CAMELLIA_128_GCM_SHA256:
- case CipherSuite.TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256:
- case CipherSuite.TLS_DHE_RSA_WITH_CAMELLIA_256_GCM_SHA384:
- case CipherSuite.DRAFT_TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256:
- case CipherSuite.TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256:
- case CipherSuite.TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256:
- case CipherSuite.TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384:
- case CipherSuite.TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384:
- case CipherSuite.TLS_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256:
- case CipherSuite.TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256:
- case CipherSuite.TLS_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384:
- case CipherSuite.TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384:
- case CipherSuite.TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256:
- case CipherSuite.TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256:
- case CipherSuite.TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384:
- case CipherSuite.TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384:
- case CipherSuite.TLS_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256:
- case CipherSuite.TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256:
- case CipherSuite.TLS_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384:
- case CipherSuite.TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384:
- case CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256:
- case CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_CCM:
- case CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8:
- case CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256:
- case CipherSuite.DRAFT_TLS_ECDHE_ECDSA_WITH_AES_128_OCB:
- case CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384:
- case CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_256_CCM:
- case CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8:
- case CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384:
- case CipherSuite.DRAFT_TLS_ECDHE_ECDSA_WITH_AES_256_OCB:
- case CipherSuite.TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256:
- case CipherSuite.TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_GCM_SHA256:
- case CipherSuite.TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384:
- case CipherSuite.TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_GCM_SHA384:
- case CipherSuite.DRAFT_TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256:
- case CipherSuite.DRAFT_TLS_ECDHE_PSK_WITH_AES_128_OCB:
- case CipherSuite.DRAFT_TLS_ECDHE_PSK_WITH_AES_256_OCB:
- case CipherSuite.DRAFT_TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256:
- case CipherSuite.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256:
- case CipherSuite.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256:
- case CipherSuite.DRAFT_TLS_ECDHE_RSA_WITH_AES_128_OCB:
- case CipherSuite.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384:
- case CipherSuite.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384:
- case CipherSuite.DRAFT_TLS_ECDHE_RSA_WITH_AES_256_OCB:
- case CipherSuite.TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256:
- case CipherSuite.TLS_ECDHE_RSA_WITH_CAMELLIA_128_GCM_SHA256:
- case CipherSuite.TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384:
- case CipherSuite.TLS_ECDHE_RSA_WITH_CAMELLIA_256_GCM_SHA384:
- case CipherSuite.DRAFT_TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256:
- case CipherSuite.TLS_PSK_DHE_WITH_AES_128_CCM_8:
- case CipherSuite.TLS_PSK_DHE_WITH_AES_256_CCM_8:
- case CipherSuite.TLS_PSK_WITH_AES_128_CCM:
- case CipherSuite.TLS_PSK_WITH_AES_128_CCM_8:
- case CipherSuite.TLS_PSK_WITH_AES_128_GCM_SHA256:
- case CipherSuite.DRAFT_TLS_PSK_WITH_AES_128_OCB:
- case CipherSuite.TLS_PSK_WITH_AES_256_CCM:
- case CipherSuite.TLS_PSK_WITH_AES_256_CCM_8:
- case CipherSuite.TLS_PSK_WITH_AES_256_GCM_SHA384:
- case CipherSuite.DRAFT_TLS_PSK_WITH_AES_256_OCB:
- case CipherSuite.TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256:
- case CipherSuite.TLS_PSK_WITH_CAMELLIA_256_GCM_SHA384:
- case CipherSuite.DRAFT_TLS_PSK_WITH_CHACHA20_POLY1305_SHA256:
- case CipherSuite.TLS_RSA_PSK_WITH_AES_128_GCM_SHA256:
- case CipherSuite.TLS_RSA_PSK_WITH_AES_256_GCM_SHA384:
- case CipherSuite.TLS_RSA_PSK_WITH_CAMELLIA_128_GCM_SHA256:
- case CipherSuite.TLS_RSA_PSK_WITH_CAMELLIA_256_GCM_SHA384:
- case CipherSuite.DRAFT_TLS_RSA_PSK_WITH_CHACHA20_POLY1305_SHA256:
- case CipherSuite.TLS_RSA_WITH_AES_128_CBC_SHA256:
- case CipherSuite.TLS_RSA_WITH_AES_128_CCM:
- case CipherSuite.TLS_RSA_WITH_AES_128_CCM_8:
- case CipherSuite.TLS_RSA_WITH_AES_128_GCM_SHA256:
- case CipherSuite.TLS_RSA_WITH_AES_256_CBC_SHA256:
- case CipherSuite.TLS_RSA_WITH_AES_256_CCM:
- case CipherSuite.TLS_RSA_WITH_AES_256_CCM_8:
- case CipherSuite.TLS_RSA_WITH_AES_256_GCM_SHA384:
- case CipherSuite.TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256:
- case CipherSuite.TLS_RSA_WITH_CAMELLIA_128_GCM_SHA256:
- case CipherSuite.TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256:
- case CipherSuite.TLS_RSA_WITH_CAMELLIA_256_GCM_SHA384:
- case CipherSuite.TLS_RSA_WITH_NULL_SHA256:
- return ProtocolVersion.TLSv12;
- default:
- return ProtocolVersion.SSLv3;
- }
- }
- public static bool IsAeadCipherSuite(int ciphersuite)
- {
- return CipherType.aead == GetCipherType(ciphersuite);
- }
- public static bool IsBlockCipherSuite(int ciphersuite)
- {
- return CipherType.block == GetCipherType(ciphersuite);
- }
- public static bool IsStreamCipherSuite(int ciphersuite)
- {
- return CipherType.stream == GetCipherType(ciphersuite);
- }
- public static bool IsValidCipherSuiteForVersion(int cipherSuite, ProtocolVersion serverVersion)
- {
- return GetMinimumVersion(cipherSuite).IsEqualOrEarlierVersionOf(serverVersion.GetEquivalentTLSVersion());
- }
- }
- }
- #endif
|