コード例 #1
0
ファイル: HttpsWriter.cs プロジェクト: ZaneDubya/Monolith
 public HttpsWriter(HttpsSession session, ERecordType recordType)
 {
     IsEncrypted = false;
     RecordType  = recordType;
     Write((byte)recordType);
     Write((ushort)session.Protocol);
     Write((ushort)0x0000); // length, must fixup on compile.
 }
コード例 #2
0
ファイル: XmlManager.cs プロジェクト: AdamPetras/Manager
 private Tuple <double, double> ParseIRecord(ERecordType recType, string priceString, string bonusString)
 {
     if (recType != ERecordType.Vacation && recType != ERecordType.None)
     {
         double.TryParse(priceString.Replace(',', '.'), NumberStyles.Any, CultureInfo.InvariantCulture, out double price);
         double.TryParse(bonusString.Replace(',', '.'), NumberStyles.Any, CultureInfo.InvariantCulture, out double bonus);
         return(new Tuple <double, double>(price, bonus));
     }
     return(new Tuple <double, double>(0, 0));
 }
コード例 #3
0
ファイル: HttpsReader.cs プロジェクト: ZaneDubya/Monolith
 public HttpsReader(HttpsSession session, byte[] buffer, int length)
     : base(buffer, length)
 {
     IsDecrypted   = false;
     Session       = session;
     RecordType    = (ERecordType)ReadByte();
     RecordVersion = (EProtocol)ReadUShort();
     RecordLength  = ReadUShort();
     VerifyLengthRemaining(this, LengthRemaining, "SSL record header");
     if (Session?.IsClientEncrypting ?? false)
     {
         Decrypt();
     }
 }
コード例 #4
0
ファイル: Record.cs プロジェクト: yandong2017/ServerMMORPG
        // 添加记录
        public static void RecValue(ERecordType RecType, EActionSource ActionSource, long puid = 0, long v0 = 0, params object[] args)
        {
            var sb  = new StringBuilder();
            var sb1 = new StringBuilder();
            var sb2 = new StringBuilder();

            sb.Append($"insert into {BaseServerInfo.ServerID}{SqlText.GameRecord}{(int)RecType}");
            for (int i = 0; i < args.Length; i++)
            {
                sb1.Append($", v{i + 1}");
                sb2.Append($", '{args[i]}'");
            }
            sb.Append($"(RecDate, RecTime, ActionSource, Puid, v0{sb1}) values ");
            sb.Append($"(Now(), Now(), '{(int)ActionSource}', '{puid}', '{v0}'{sb2})");
            ThreadDbMysqlSecond.AddCmd(sb.ToString());
        }
コード例 #5
0
        private static string MapRecordType(ERecordType type)
        {
            switch (type)
            {
            case ERecordType.Hours:
                return(AppResource.HoursType);

            case ERecordType.Pieces:
                return(AppResource.PiecesType);

            case ERecordType.Vacation:
                return(AppResource.VacationType);

            case ERecordType.None:
                return("");

            default:
                throw new ArgumentOutOfRangeException(nameof(type), type, null);
            }
        }
コード例 #6
0
 // Copy constructor
 public CBackReference( CBackReference other )
 {
     m_ertRecordType = other.m_ertRecordType;
     m_xref = other.m_xref;
     m_sEventType = other.m_sEventType;
 }
コード例 #7
0
 // Constructor
 public CBackReference( ERecordType recordType, string xrefId, string eventType )
 {
     m_ertRecordType = recordType;
     m_xref = xrefId;
     m_sEventType = eventType;
 }
コード例 #8
0
ファイル: Cryptor.cs プロジェクト: ZaneDubya/Monolith
        /// <summary>
        /// Creates a SSLv3 message authentification code for the passed buffer.
        /// </summary>
        private static byte[] CreateMAC(EProtocol protocol, KeyedHashAlgorithm hasher, ulong seqNum, ERecordType recordType, byte[] buffer, int offset)
        {
            int bufferLengthTransformed = buffer.Length - offset;

            // hash seq_num, fragment type, fragment length
            byte[] infoPad = CreateMACInfoPad(seqNum, (byte)recordType, protocol, bufferLengthTransformed);
            // hash(MAC_write_secret + pad_2 + hash(MAC_write_secret + pad_1 + seq_num + record_type + length + content));
            hasher.Initialize();
            hasher.TransformBlock(infoPad, 0, infoPad.Length, infoPad, 0);
            hasher.TransformFinalBlock(buffer, offset, bufferLengthTransformed);
            return(hasher.Hash);
        }
コード例 #9
0
ファイル: Cryptor.cs プロジェクト: ZaneDubya/Monolith
 public static bool CreateMAC(CipherSuiteInfo cipher, KeyedHashAlgorithm hasher, ulong seqNum, ERecordType recordType, byte[] buffer, int offset, out byte[] mac)
 {
     mac = CreateMAC(EProtocol.SSLv30, hasher, seqNum, recordType, buffer, offset);
     return(true);
 }
コード例 #10
0
ファイル: Cryptor.cs プロジェクト: ZaneDubya/Monolith
 public static bool VerifyMAC(CipherSuiteInfo cipher, KeyedHashAlgorithm hasher, ulong seqNum, ERecordType recordType, byte[] buffer, out byte[] bufferWithoutMac)
 {
     bufferWithoutMac = null;
     if (cipher.CipherType == ECipherType.Stream || cipher.CipherType == ECipherType.Block)
     {
         if (buffer.Length < cipher.MACLength)
         {
             return(false);
         }
         bufferWithoutMac = new byte[buffer.Length - cipher.MACLength];
         Buffer.BlockCopy(buffer, 0, bufferWithoutMac, 0, bufferWithoutMac.Length);
         byte[] hash = CreateMAC(EProtocol.SSLv30, hasher, seqNum, recordType, bufferWithoutMac, 0);
         for (int i = 1; i <= cipher.MACLength; i++)
         {
             if (buffer[buffer.Length - i] != hash[hash.Length - i])
             {
                 byte[] originalMac = new byte[16];
                 Buffer.BlockCopy(buffer, buffer.Length - cipher.MACLength, originalMac, 0, cipher.MACLength);
                 throw new HttpsException($"MAC verification fail:\n{BufferFormat.AsHexString(originalMac, cipher.MACLength)}{BufferFormat.AsHexString(hash, cipher.MACLength)}");
             }
         }
         return(true);
     }
     return(false);
 }
コード例 #11
0
 public Record CreateRecord(ERecordType type)
 {
     return(_prototypes[type].Clone());
 }