示例#1
0
        /// <summary>
        /// Method used by the library, not not call youself.
        /// </summary>
        /// <param name="hash">The hash on which the digesht must be calculated</param>
        /// <param name="digestMethod">The digest method with which the hash was calculated</param>
        /// <returns>The RFC3161 Timestamp token</returns>
        public virtual byte[] GetTimestampFromDocumentHash(byte[] hash, string digestMethod)
        {
            //create request
            DSS.SignRequest request = new DSS.SignRequest();

            //Set some standard value of the request
            request.RequestID = "_" + Guid.NewGuid().ToString("D");
            request.Profile   = profile;

            //Create the document hash structure
            DSS.DocumentHash docHash = new DSS.DocumentHash();
            docHash.DigestMethod           = new DSS.DigestMethodType();
            docHash.DigestMethod.Algorithm = digestMethod;
            docHash.DigestValue            = hash;
            request.InputDocuments         = new DSS.InputDocuments();
            request.InputDocuments.Items   = new Object[] { docHash };

            //Send the request
            DSS.SignResponse resp = client.Stamp(request);

            if (resp.Result.ResultMajor != "urn:oasis:names:tc:dss:1.0:resultmajor:Success")
            {
                throw new ApplicationException(resp.Result.ResultMessage.Value);
            }

            return((byte[])((DSS.Timestamp)resp.SignatureObject.Item).Item);
        }
示例#2
0
        /// <summary>
        /// Method used by the library, not not call youself.
        /// </summary>
        /// <param name="hash">The hash on which the digesht must be calculated</param>
        /// <param name="digestMethod">The digest method with which the hash was calculated</param>
        /// <returns>The RFC3161 Timestamp token</returns>
        public virtual byte[] GetTimestampFromDocumentHash(byte[] hash, string digestMethod)
        {
            //create request
            DSS.SignRequest request = new DSS.SignRequest();

            //Set some standard value of the request
            request.RequestID = "_" + Guid.NewGuid().ToString("D");
            request.Profile = profile;

            //Create the document hash structure
            DSS.DocumentHash docHash = new DSS.DocumentHash();
            docHash.DigestMethod = new DSS.DigestMethodType();
            docHash.DigestMethod.Algorithm = digestMethod;
            docHash.DigestValue = hash;
            request.InputDocuments = new DSS.InputDocuments();
            request.InputDocuments.Items = new Object[] { docHash };

            //Send the request
            DSS.SignResponse resp = client.Stamp(request);

            if (resp.Result.ResultMajor != "urn:oasis:names:tc:dss:1.0:resultmajor:Success")
            {
                throw new ApplicationException(resp.Result.ResultMessage.Value);
            }

            return (byte[]) ((DSS.Timestamp)resp.SignatureObject.Item).Item;
        }