Exemplo n.º 1
0
 internal SignerInformation(Org.BouncyCastle.Asn1.Cms.SignerInfo info, DerObjectIdentifier contentType, CmsProcessable content, IDigestCalculator digestCalculator)
 {
     this.info               = info;
     this.sid                = new SignerID();
     this.contentType        = contentType;
     this.isCounterSignature = (contentType == null);
     try
     {
         SignerIdentifier signerID = info.SignerID;
         if (signerID.IsTagged)
         {
             Asn1OctetString instance = Asn1OctetString.GetInstance(signerID.ID);
             this.sid.SubjectKeyIdentifier = instance.GetEncoded();
         }
         else
         {
             Org.BouncyCastle.Asn1.Cms.IssuerAndSerialNumber instance2 = Org.BouncyCastle.Asn1.Cms.IssuerAndSerialNumber.GetInstance(signerID.ID);
             this.sid.Issuer       = instance2.Name;
             this.sid.SerialNumber = instance2.SerialNumber.Value;
         }
     }
     catch (IOException)
     {
         throw new ArgumentException("invalid sid in SignerInfo");
     }
     this.digestAlgorithm      = info.DigestAlgorithm;
     this.signedAttributeSet   = info.AuthenticatedAttributes;
     this.unsignedAttributeSet = info.UnauthenticatedAttributes;
     this.encryptionAlgorithm  = info.DigestEncryptionAlgorithm;
     this.signature            = info.EncryptedDigest.GetOctets();
     this.content          = content;
     this.digestCalculator = digestCalculator;
 }
Exemplo n.º 2
0
        internal SignerInformation(
            Asn1.Cms.SignerInfo info,
            DerObjectIdentifier contentType,
            ICmsTypedData content,
            byte[] digest)
        {
            this.info = info;

            this.contentType        = contentType;
            this.isCounterSignature = contentType == null;

            try
            {
                SignerIdentifier s = info.SignerID;

                if (s.IsTagged)
                {
                    Asn1OctetString octs = Asn1OctetString.GetInstance(s.ID);

                    this.sid = new SignerID(octs.GetEncoded());
                }
                else
                {
                    Asn1.Cms.IssuerAndSerialNumber iAnds =
                        Asn1.Cms.IssuerAndSerialNumber.GetInstance(s.ID);

                    this.sid = new SignerID(iAnds.Name, iAnds.SerialNumber.Value);
                }
            }
            catch (IOException)
            {
                throw new ArgumentException("invalid sid in SignerInfo");
            }

            this.digestAlgorithm      = info.DigestAlgorithm;
            this.signedAttributeSet   = info.AuthenticatedAttributes;
            this.unsignedAttributeSet = info.UnauthenticatedAttributes;
            this.encryptionAlgorithm  = info.DigestEncryptionAlgorithm;
            this.signature            = info.EncryptedDigest.GetOctets();

            this.content      = content;
            this.resultDigest = digest;
        }
Exemplo n.º 3
0
        private bool MatchExtension(
            byte[]                          b,
            X509Certificate c,
            DerObjectIdentifier oid)
        {
            if (b == null)
            {
                return(true);
            }

            Asn1OctetString extVal = c.GetExtensionValue(oid);

            if (extVal == null)
            {
                return(false);
            }

            return(extVal != null && Arrays.AreEqual(b, extVal.GetEncoded()));
        }