예제 #1
0
		public void VerifySignatureAlgorithm (ITlsContext ctx, SignatureAndHashAlgorithm algorithm)
		{
			AssertTls12 (ctx);

			if (!ctx.IsAlgorithmSupported (algorithm))
				throw new TlsException (AlertDescription.IlegalParameter);
		}
예제 #2
0
 public void Add(SignatureAndHashAlgorithm algorithm)
 {
     SignatureAndHashAlgorithms.Add(algorithm);
 }
예제 #3
0
		public virtual void AssertServerSignatureAlgorithm (ITlsContext ctx, SignatureAndHashAlgorithm algorithm)
		{
			if (ctx.IsServer)
				throw new InvalidOperationException ();

			AssertTls12 (ctx);

			VerifySignatureAlgorithm (ctx, algorithm);

			if (ctx.HasCurrentSignatureParameters && ctx.CurrentSignatureParameters != null) {
				if (!ctx.CurrentSignatureParameters.SignatureAndHashAlgorithms.Contains (algorithm))
					throw new TlsException (AlertDescription.IlegalParameter);
			} else if (!algorithm.Equals (SignatureParameters.DefaultAlgorithm)) {
				throw new TlsException (AlertDescription.IlegalParameter);
			}
		}
예제 #4
0
		public virtual void AssertCertificateVerifySignatureAlgorithm (ITlsContext ctx, SignatureAndHashAlgorithm algorithm)
		{
			if (!ctx.IsServer)
				throw new InvalidOperationException ();

			AssertTls12 (ctx);

			VerifySignatureAlgorithm (ctx, algorithm);

			ClientCertificateParameters parameters;
			if (ctx.HasClientCertificateParameters && ctx.ClientCertificateParameters != null)
				parameters = ctx.ClientCertificateParameters;
			else
				parameters = null;

			if (parameters != null && parameters.HasSignatureParameters && parameters.SignatureParameters != null) {
				if (!parameters.SignatureParameters.SignatureAndHashAlgorithms.Contains (algorithm))
					throw new TlsException (AlertDescription.IlegalParameter);
			} else if (!algorithm.Equals (SignatureParameters.DefaultAlgorithm)) {
				throw new TlsException (AlertDescription.IlegalParameter);
			}
		}
예제 #5
0
		public virtual void AssertClientSignatureAlgorithm (ITlsContext ctx, SignatureAndHashAlgorithm algorithm)
		{
			if (!ctx.IsServer)
				throw new InvalidOperationException ();

			AssertTls12 (ctx);

			VerifySignatureAlgorithm (ctx, algorithm);
		}
예제 #6
0
		public bool IsAlgorithmSupported (SignatureAndHashAlgorithm algorithm)
		{
			if (HasNegotiatedProtocol && NegotiatedProtocol != TlsProtocolCode.Tls12)
				throw new TlsException (AlertDescription.IlegalParameter);

			return SignatureHelper.IsAlgorithmSupported (algorithm);
		}
예제 #7
0
        public virtual void AssertCertificateVerifySignatureAlgorithm(ITlsContext ctx, SignatureAndHashAlgorithm algorithm)
        {
            if (!ctx.IsServer)
            {
                throw new InvalidOperationException();
            }

            AssertTls12(ctx);

            VerifySignatureAlgorithm(ctx, algorithm);

            ClientCertificateParameters parameters;

            if (ctx.HasClientCertificateParameters && ctx.ClientCertificateParameters != null)
            {
                parameters = ctx.ClientCertificateParameters;
            }
            else
            {
                parameters = null;
            }

            if (parameters != null && parameters.HasSignatureParameters && parameters.SignatureParameters != null)
            {
                if (!parameters.SignatureParameters.SignatureAndHashAlgorithms.Contains(algorithm))
                {
                    throw new TlsException(AlertDescription.IlegalParameter);
                }
            }
            else if (!algorithm.Equals(SignatureParameters.DefaultAlgorithm))
            {
                throw new TlsException(AlertDescription.IlegalParameter);
            }
        }
예제 #8
0
		public void Add (SignatureAndHashAlgorithm algorithm)
		{
			SignatureAndHashAlgorithms.Add (algorithm);
		}
			protected override SignatureAndHashAlgorithm SelectSignatureAlgorithm ()
			{
				var algorithm = base.SelectSignatureAlgorithm ();
				DebugHelper.WriteLine ("SIGNATURE ALGORITHM: {0}", algorithm);
				algorithm = new SignatureAndHashAlgorithm (HashAlgorithmType.Sha1, SignatureAlgorithmType.Rsa);
				DebugHelper.WriteLine ("NEW SIGNATURE ALGORITHM: {0}", algorithm);
				return algorithm;
			}