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. }
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)); }
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(); } }
// 添加记录 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()); }
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); } }
// Copy constructor public CBackReference( CBackReference other ) { m_ertRecordType = other.m_ertRecordType; m_xref = other.m_xref; m_sEventType = other.m_sEventType; }
// Constructor public CBackReference( ERecordType recordType, string xrefId, string eventType ) { m_ertRecordType = recordType; m_xref = xrefId; m_sEventType = eventType; }
/// <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); }
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); }
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); }
public Record CreateRecord(ERecordType type) { return(_prototypes[type].Clone()); }