Пример #1
0
        public IEnumerable <P7kSignInfo> GetP7kSignatures()
        {
            var p7k = P7kLoadFromBuf();

            if (p7k.Equals(0))
            {
                return(Enumerable.Empty <P7kSignInfo>());
            }

            var count = P7kGetSignatureCount(p7k);

            if (count.Equals(0))
            {
                return(Enumerable.Empty <P7kSignInfo>());
            }

            var result = new List <P7kSignInfo>();

            for (int i = 0; i < count; i++)
            {
                var buf  = P7kGetSignerInfo(p7k, i);
                var x509 = X509LoadFromBuf(buf);
                var sign = new P7kSignInfo(this, p7k, x509, i);
                X509Free(x509);
                sign.Children = GetP7kChildren(p7k, i);
                result.Add(sign);
            }
            P7kFree(p7k);
            return(result);
        }
Пример #2
0
        public IEnumerable <SignInfo> GetP7kChildren(int pades, int parentHandle, int num, SignInfo.SignTypes signType)
        {
            var result = new List <SignInfo>();

            if (P7kSignatureHasTS(parentHandle, num))
            {
                var ts = P7kSignatureGetTS(parentHandle, num);
                result.Add(new TSSignInfo(this, parentHandle, ts, num));
                TSFree(ts);
            }

            var p7k = P7kGetCountersignature(parentHandle, num);

            if (p7k.Equals(0))
            {
                return(result);
            }

            var count = P7kGetSignatureCount(p7k);

            if (count.Equals(0))
            {
                P7kFree(p7k);
                return(result);
            }

            for (int i = 0; i < count; i++)
            {
                var buf  = P7kGetSignerInfo(p7k, i);
                var x509 = X509LoadFromBuf(buf);
                var sign = new P7kSignInfo(this, pades, p7k, x509, i, signType);
                X509Free(x509);
                sign.Children = GetP7kChildren(pades, p7k, i, signType);
                result.Add(sign);
            }
            P7kFree(p7k);

            return(result);
        }
Пример #3
0
        public IEnumerable <P7kSignInfo> GetPADESSignatures()
        {
            var pades = PADES_OpenFromBuf();

            if (pades.Equals(0))
            {
                return(Enumerable.Empty <P7kSignInfo>());
            }

            var iPADESCount = PADES_GetSignatureCount(pades);

            if (iPADESCount.Equals(0))
            {
                PADES_Free(pades);
                return(Enumerable.Empty <P7kSignInfo>());
            }

            var result = new List <P7kSignInfo>();

            for (int iPADES = 0; iPADES < iPADESCount; iPADES++)
            {
                var p7k      = PADES_GetSignatureObject(pades, iPADES);
                var p7kCount = P7kGetSignatureCount(p7k);
                for (int iP7k = 0; iP7k < p7kCount; iP7k++)
                {
                    var buf  = P7kGetSignerInfo(p7k, iP7k);
                    var x509 = X509LoadFromBuf(buf);
                    var sign = new P7kSignInfo(this, pades, p7k, x509, iP7k, SignInfo.SignTypes.PAdES);
                    X509Free(x509);
                    sign.Children = GetP7kChildren(pades, p7k, iP7k, SignInfo.SignTypes.PAdES);
                    result.Add(sign);
                }
                P7kFree(p7k);
            }
            PADES_Free(pades);
            return(result);
        }