예제 #1
0
        internal static TimeStampToken FromTimestampInfo(CRYPT_TIMESTAMP_INFO info, Signer signer, bool trusted)
        {
            string hashAlgorithm;
            try
            {
                var oid = Oid.FromOidValue(info.HashAlgorithm.pszObjId, OidGroup.HashAlgorithm);
                hashAlgorithm = oid.FriendlyName;
            }
            catch
            {
                hashAlgorithm = info.HashAlgorithm.pszObjId;
            }

            var hashedMessage = new byte[info.HashedMessage.cbData];
            Marshal.Copy(info.HashedMessage.pbData, hashedMessage, 0, hashedMessage.Length);

            return new TimeStampToken(
                (int)info.dwVersion,
                info.pszTSAPolicyId,
                hashAlgorithm,
                hashedMessage,
                DateTime.FromFileTime((long)(((ulong)(uint)info.ftTime.dwHighDateTime << 32) | (uint)info.ftTime.dwLowDateTime)).ToUniversalTime(),
                info.fOrdering,
                signer,
                trusted);
        }
예제 #2
0
 private TimeStampToken(int version, string tsaPolicyId, string hashAlgorithm, byte[] hashedMessage, DateTime timestampUtc, bool ordered, Signer signer, bool isTrusted)
 {
     Version = version;
     TsaPolicyId = tsaPolicyId;
     HashAlgorithm = hashAlgorithm;
     HashedMessage = hashedMessage;
     TimestampUtc = timestampUtc;
     Ordered = ordered;
     Signer = signer;
     IsTrusted = isTrusted;
 }
예제 #3
0
 private static void DumpSigner(Signature signature, Signer signer)
 {
     AnsiConsole.Output.WriteLine("  [Subject]");
     AnsiConsole.Output.WriteLine("    " + signer.SignerCertificate.Subject);
     AnsiConsole.Output.WriteLine("  [Issuer]");
     AnsiConsole.Output.WriteLine("    " + signer.SignerCertificate.Issuer);
     AnsiConsole.Output.WriteLine("  [SPKI]");
     AnsiConsole.Output.WriteLine("    " + signer.Spki);
     AnsiConsole.Output.WriteLine("  [Signature Algorithm]");
     AnsiConsole.Output.WriteLine("    " + signer.SignerCertificate.SignatureAlgorithm.FriendlyName);
     AnsiConsole.Output.WriteLine("  [Signing Time]");
     AnsiConsole.Output.WriteLine("    " + (signer.SigningTime?.ToString("O")) ?? "UNKNOWN!");
     AnsiConsole.Output.WriteLine("  [Cert Chain]");
     var chain = new X509Chain();
     chain.ChainPolicy.ExtraStore.AddRange(signature.Certificates);
     chain.Build(signer.SignerCertificate);
     foreach (var element in chain.ChainElements)
     {
         AnsiConsole.Output.WriteLine("    " + element.Certificate.Subject);
         AnsiConsole.Output.WriteLine("      Issued By: " + element.Certificate.IssuerName.CommonName());
         AnsiConsole.Output.WriteLine("      Status: " + String.Join(", ", element.ChainElementStatus.Select(s => s.Status)));
         AnsiConsole.Output.WriteLine("      Info:   " + element.Information);
         AnsiConsole.Output.WriteLine("      SPKI:   " + element.Certificate.ComputePublicKeyIdentifier());
     }
 }
예제 #4
0
 private TimeStampToken(int version, string tsaPolicyId, string hashAlgorithm, byte[] hashedMessage, DateTime timestampUtc, bool ordered, Signer signer, bool isTrusted)
 {
     Version       = version;
     TsaPolicyId   = tsaPolicyId;
     HashAlgorithm = hashAlgorithm;
     HashedMessage = hashedMessage;
     TimestampUtc  = timestampUtc;
     Ordered       = ordered;
     Signer        = signer;
     IsTrusted     = isTrusted;
 }