Пример #1
0
        public static string GeneratePacket(Pack pack, Cert cert, Rsa key)
        {
            Buf b = new Buf();

            byte[] pack_data = pack.WriteToBuf().ByteData;
            WpcEntry.AddDataEntry(b, "PACK", pack_data);

            byte[] hash = Secure.HashSHA1(pack_data);
            WpcEntry.AddDataEntry(b, "HASH", hash);

            if (cert != null && key != null)
            {
                WpcEntry.AddDataEntry(b, "CERT", cert.ByteData);
                WpcEntry.AddDataEntry(b, "SIGN", key.SignData(hash));
            }

            return(Str.AsciiEncoding.GetString(b.ByteData));
        }
Пример #2
0
 void init(string ip)
 {
     ipAddress = ip;
     hostName  = "";
     try
     {
         hostName = Domain.GetHostName(IPAddress.Parse(ip), 250)[0];
     }
     catch
     {
     }
     if (Str.IsEmptyStr(hostName))
     {
         hostName = ip;
     }
     requestPack  = null;
     requestCert  = null;
     responsePack = null;
     responseCert = null;
     responseKey  = null;
     guid         = System.Guid.NewGuid().ToString();
 }
Пример #3
0
 public void SetResponse(Pack pack, Cert cert, Rsa key)
 {
     responsePack = pack;
     responseCert = cert;
     responseKey  = key;
 }