Esempio n. 1
0
		public byte[] CalculateRawSignature(AsymmetricKeyParameter privateKey, byte[] md5andsha1)
		{
			// Note: Only use the SHA1 part of the hash
			ISigner sig = new DsaDigestSigner(new DsaSigner(), new NullDigest());
			sig.Init(true, privateKey);
			sig.BlockUpdate(md5andsha1, 16, 20);
			return sig.GenerateSignature();
		}
Esempio n. 2
0
        public void ThrowIfSignatureNotOkay(byte[] signature, params byte[][] inputs)
        {
            var signer = new DsaDigestSigner(new ECDsaSigner(), new Sha256Digest());
            signer.Init(false, _publicKey);

            foreach (var input in inputs)
            {
                signer.BlockUpdate(input, 0, input.Length);
            }

            if (!signer.VerifySignature(signature))
            {
                throw new ApplicationException();
            }
        }
        protected virtual ISigner MakeSigner(SignatureAndHashAlgorithm algorithm, bool raw, bool forSigning,
            ICipherParameters cp)
        {
            if ((algorithm != null) != TlsUtilities.IsTlsV12(mContext))
                throw new InvalidOperationException();

            if (algorithm != null && algorithm.Signature != SignatureAlgorithm)
                throw new InvalidOperationException();

            byte hashAlgorithm = algorithm == null ? HashAlgorithm.sha1 : algorithm.Hash;
            IDigest d = raw ? new NullDigest() : TlsUtilities.CreateHash(hashAlgorithm);

            ISigner s = new DsaDigestSigner(CreateDsaImpl(hashAlgorithm), d);
            s.Init(forSigning, MakeInitParameters(forSigning, cp));
            return s;
        }
Esempio n. 4
0
		protected virtual ISigner MakeSigner(IDigest d, bool forSigning, ICipherParameters cp)
		{
			ISigner s = new DsaDigestSigner(CreateDsaImpl(), d);
			s.Init(forSigning, cp);
			return s;
		}
		private ISigner GetSigner(TSignatureAlgorithm signatureAlgorithm, THashAlgorithm hashAlgorithm, AsymmetricKeyParameter serverPrivateKey)
		{
			ISigner result = null;
			switch (signatureAlgorithm)
			{
				case TSignatureAlgorithm.Anonymous:
					break;
				case TSignatureAlgorithm.RSA:
					break;
				case TSignatureAlgorithm.DSA:
					break;
				case TSignatureAlgorithm.ECDSA:
					result = new DsaDigestSigner(new ECDsaSigner(), GetDigest(hashAlgorithm));
					break;
				default:
					break;
			}
			result.Init(true, serverPrivateKey);
			//result.Init(true, new ParametersWithRandom(serverPrivateKey, this.mContext.SecureRandom));
			return result;
		}
Esempio n. 6
0
		public ISigner CreateVerifyer(AsymmetricKeyParameter publicKey)
		{
			ISigner s = new DsaDigestSigner(new DsaSigner(), new Sha1Digest());
			s.Init(false, publicKey);
			return s;
		}