Пример #1
0
 public Rsa(Cert cert)
 {
     init(cert);
 }
Пример #2
0
 void init(Cert cert)
 {
     this.cert = (Cert)cert.Clone();
     this.data = null;
 }
Пример #3
0
 void init(byte[] data)
 {
     this.data = (byte[])data.Clone();
     this.cert = null;
 }
Пример #4
0
        void init(Cert cert)
        {
            PemReader pem = new PemReader(new StringReader(cert.PublicKey.GetString_Ascii()));

            key = (AsymmetricKeyParameter)pem.ReadObject();
        }
Пример #5
0
 public RsaInner(Cert cert)
 {
     init(cert);
 }
Пример #6
0
        public static WpcPacket ParsePacket(string recvStr)
        {
            List <WpcEntry> o = WpcEntry.ParseDataEntry(recvStr);

            WpcEntry e;

            try
            {
                e = WpcEntry.FindEntry(o, "PACK");
                if (e != null)
                {
                    byte[] hash = Secure.HashSHA1(e.Data);
                    Pack   pack = null;

                    pack = Pack.CreateFromBuf(new Buf(e.Data));

                    e = WpcEntry.FindEntry(o, "HASH");

                    if (e != null)
                    {
                        byte[] hash2 = e.Data;

                        if (Util.CompareByte(hash, hash2))
                        {
                            e = WpcEntry.FindEntry(o, "CERT");
                            if (e != null)
                            {
                                Cert cert;

                                try
                                {
                                    cert = new Cert(e.Data);
                                }
                                catch
                                {
                                    return(null);
                                }

                                e = WpcEntry.FindEntry(o, "SIGN");
                                if (e != null)
                                {
                                    byte[] sign = e.Data;

                                    if (cert.RsaPublicKey.VerifyData(hash2, sign))
                                    {
                                        return(new WpcPacket(pack, hash2, cert, sign));
                                    }
                                }
                            }
                            else
                            {
                                return(new WpcPacket(pack, hash2));
                            }
                        }
                    }
                }
            }
            catch (OverflowException)
            {
                return(null);
            }

            return(null);
        }
Пример #7
0
 public void SetResponse(Pack pack, Cert cert, Rsa key)
 {
     responsePack = pack;
     responseCert = cert;
     responseKey  = key;
 }