@@ -129,14 +129,24 @@ public static bool IsSsl(TlsContext context)
129129 return context . ServerVersion . IsSsl ;
130130 }
131131
132+ public static bool IsTlsV11 ( ProtocolVersion version )
133+ {
134+ return ProtocolVersion . TLSv11 . IsEqualOrEarlierVersionOf ( version . GetEquivalentTLSVersion ( ) ) ;
135+ }
136+
132137 public static bool IsTlsV11 ( TlsContext context )
133138 {
134- return ProtocolVersion . TLSv11 . IsEqualOrEarlierVersionOf ( context . ServerVersion . GetEquivalentTLSVersion ( ) ) ;
139+ return IsTlsV11 ( context . ServerVersion ) ;
140+ }
141+
142+ public static bool IsTlsV12 ( ProtocolVersion version )
143+ {
144+ return ProtocolVersion . TLSv12 . IsEqualOrEarlierVersionOf ( version . GetEquivalentTLSVersion ( ) ) ;
135145 }
136146
137147 public static bool IsTlsV12 ( TlsContext context )
138148 {
139- return ProtocolVersion . TLSv12 . IsEqualOrEarlierVersionOf ( context . ServerVersion . GetEquivalentTLSVersion ( ) ) ;
149+ return IsTlsV12 ( context . ServerVersion ) ;
140150 }
141151
142152 public static void WriteUint8 ( byte i , Stream output )
@@ -712,11 +722,10 @@ public static IList ReadSignatureAlgorithmsExtension(byte[] extensionData)
712722 public static void EncodeSupportedSignatureAlgorithms ( IList supportedSignatureAlgorithms , bool allowAnonymous ,
713723 Stream output )
714724 {
715- if ( supportedSignatureAlgorithms == null || supportedSignatureAlgorithms . Count < 1
716- || supportedSignatureAlgorithms . Count >= ( 1 << 15 ) )
717- {
725+ if ( supportedSignatureAlgorithms == null )
726+ throw new ArgumentNullException ( "supportedSignatureAlgorithms" ) ;
727+ if ( supportedSignatureAlgorithms . Count < 1 || supportedSignatureAlgorithms . Count >= ( 1 << 15 ) )
718728 throw new ArgumentException ( "must have length from 1 to (2^15 - 1)" , "supportedSignatureAlgorithms" ) ;
719- }
720729
721730 // supported_signature_algorithms
722731 int length = 2 * supportedSignatureAlgorithms . Count ;
@@ -762,6 +771,27 @@ public static IList ParseSupportedSignatureAlgorithms(bool allowAnonymous, Strea
762771 return supportedSignatureAlgorithms ;
763772 }
764773
774+ public static void VerifySupportedSignatureAlgorithm ( IList supportedSignatureAlgorithms , SignatureAndHashAlgorithm signatureAlgorithm )
775+ {
776+ if ( supportedSignatureAlgorithms == null )
777+ throw new ArgumentNullException ( "supportedSignatureAlgorithms" ) ;
778+ if ( supportedSignatureAlgorithms . Count < 1 || supportedSignatureAlgorithms . Count >= ( 1 << 15 ) )
779+ throw new ArgumentException ( "must have length from 1 to (2^15 - 1)" , "supportedSignatureAlgorithms" ) ;
780+ if ( signatureAlgorithm == null )
781+ throw new ArgumentNullException ( "signatureAlgorithm" ) ;
782+
783+ if ( signatureAlgorithm . Signature != SignatureAlgorithm . anonymous )
784+ {
785+ foreach ( SignatureAndHashAlgorithm entry in supportedSignatureAlgorithms )
786+ {
787+ if ( entry . Hash == signatureAlgorithm . Hash && entry . Signature == signatureAlgorithm . Signature )
788+ return ;
789+ }
790+ }
791+
792+ throw new TlsFatalAlert ( AlertDescription . illegal_parameter ) ;
793+ }
794+
765795 public static byte [ ] PRF ( TlsContext context , byte [ ] secret , string asciiLabel , byte [ ] seed , int size )
766796 {
767797 ProtocolVersion version = context . ServerVersion ;
0 commit comments