public static ICollection GetSignatureTimestamps()

in net/JetBrains.SignatureVerifier/src/Crypt/BC/TSPUtil.cs [79:121]


    public static ICollection GetSignatureTimestamps(
      Org.BouncyCastle.Cms.SignerInformation signerInfo)
    {
      IList timestamps = Platform.CreateArrayList();

      Org.BouncyCastle.Asn1.Cms.AttributeTable unsignedAttrs = signerInfo.UnsignedAttributes;
      if (unsignedAttrs != null)
      {
        foreach (Org.BouncyCastle.Asn1.Cms.Attribute tsAttr in unsignedAttrs.GetAll(
          PkcsObjectIdentifiers.IdAASignatureTimeStampToken))
        {
          foreach (Asn1Encodable asn1 in tsAttr.AttrValues)
          {
            try
            {
              Org.BouncyCastle.Asn1.Cms.ContentInfo contentInfo = Org.BouncyCastle.Asn1.Cms.ContentInfo.GetInstance(
                asn1.ToAsn1Object());
              TimeStampToken timeStampToken = new TimeStampToken(contentInfo);
              TimeStampTokenInfo tstInfo = timeStampToken.TimeStampInfo;

              byte[] expectedDigest = DigestUtilities.CalculateDigest(
                GetDigestAlgName(tstInfo.MessageImprintAlgOid),
                signerInfo.GetSignature());

              if (!Arrays.FixedTimeEquals(expectedDigest, tstInfo.GetMessageImprintDigest()))
                throw new TspValidationException("Incorrect digest in message imprint");

              timestamps.Add(timeStampToken);
            }
            catch (SecurityUtilityException)
            {
              throw new TspValidationException("Unknown hash algorithm specified in timestamp");
            }
            catch (Exception)
            {
              throw new TspValidationException("Timestamp could not be parsed");
            }
          }
        }
      }

      return timestamps;
    }