示例#1
0
        public static TimeStampToken RequestTST(string fileName, string tsaService, Oid hashAlg, string policy, string nonce, bool certReq, UserCredentials credentials)
        {
            byte[] nonce_bytes   = null;
            byte[] hashedMessage = DigestUtils.ComputeDigest(fileName, hashAlg);
            if (!string.IsNullOrEmpty(nonce))
            {
                nonce_bytes = SharedUtils.HexStringToBytes(nonce);
            }

            Request request = new Request(hashedMessage, hashAlg, nonce_bytes, policy, certReq);

            return(TimeStampClient.RequestTimeStampToken(tsaService, request, credentials));
        }
示例#2
0
        /// <summary>
        /// Requests time stamp for the data from stream.
        /// </summary>
        /// <param name="tsaUri">URL of a TSA service.</param>
        /// <param name="dataToTimestamp">Specifies the data to time-stamp.</param>
        /// <param name="digestType">Specifies the hash algorithm to be used to compute digest from data.</param>
        /// <param name="credentials">User's credentials to access TSA service.</param>
        /// <returns>Time-stamp token</returns>
        public static TimeStampToken RequestTimeStampToken(string tsaUri, Stream dataToTimestamp, Oid digestType, UserCredentials credentials)
        {
            if (null == tsaUri)
            {
                throw new ArgumentNullException("tsaUri");
            }

            if (null == dataToTimestamp)
            {
                throw new ArgumentNullException("dataToTimestamp");
            }

            if (null == digestType)
            {
                digestType = Oid.SHA512;
            }

            byte[]  digest  = DigestUtils.ComputeDigest(dataToTimestamp, digestType);
            Request request = new Request(digest, digestType.OID);

            return(RequestTST(tsaUri, request, credentials));
        }