public IDigest ForkPrfHash()
        {
            CheckStopBuffering();

            if (buf != null)
            {
                IDigest prfHash = DtlsHelper.CreateHash((short)prfHashAlgorithm);
                buf.UpdateDigest(prfHash);
                return(prfHash);
            }

            return(DtlsHelper.CloneHash((short)prfHashAlgorithm, (IDigest)hashes[prfHashAlgorithm.Value]));
        }
        public TlsHandshakeHash StopTracking()
        {
            IDigest prfHash = DtlsHelper.CloneHash(prfHashAlgorithm.Value, (IDigest)hashes[prfHashAlgorithm.Value]);

            if (buf != null)
            {
                buf.UpdateDigest(prfHash);
            }

            DeferredHash result = new DeferredHash(prfHashAlgorithm.Value, prfHash);

            result.Init(context);
            return(result);
        }
        public byte[] GetFinalHash(byte hashAlgorithm)
        {
            IDigest d = (IDigest)hashes[hashAlgorithm];

            if (d == null)
            {
                throw new InvalidOperationException("HashAlgorithm." + HashAlgorithm.GetText(hashAlgorithm) + " is not being tracked");
            }

            d = DtlsHelper.CloneHash(hashAlgorithm, d);
            if (buf != null)
            {
                buf.UpdateDigest(d);
            }

            byte[] bs = new byte[d.GetDigestSize()];
            d.DoFinal(bs, 0);
            return(bs);
        }
 public CombinedHash(CombinedHash t)
 {
     this.context = t.context;
     this.md5     = DtlsHelper.CloneHash(HashAlgorithm.md5, t.md5);
     this.sha1    = DtlsHelper.CloneHash(HashAlgorithm.sha1, t.sha1);
 }