[pgsqlclient-checkins] pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls TlsSessi
Status: Inactive
Brought to you by:
carlosga_fb
From: <car...@us...> - 2003-10-14 09:48:05
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls In directory sc8-pr-cvs1:/tmp/cvs-serv32059 Modified Files: TlsSessionContext.cs Log Message: - Added methods GetUnixTime and GetSecureRandomBytes. Index: TlsSessionContext.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/TlsSessionContext.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TlsSessionContext.cs 13 Oct 2003 19:13:30 -0000 1.2 --- TlsSessionContext.cs 14 Oct 2003 09:48:01 -0000 1.3 *************** *** 194,197 **** --- 194,215 ---- #region KEY_GENERATION_METODS + public byte[] GetSecureRandomBytes(int count) + { + byte[] secureBytes = new byte[count]; + + RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider(); + rng.GetNonZeroBytes(secureBytes); + + return secureBytes; + } + + public int GetUnixTime() + { + DateTime now = DateTime.Now.ToUniversalTime(); + TimeSpan unixTime = now.Subtract(new DateTime(1970, 1, 1)); + + return (int)unixTime.TotalSeconds; + } + public byte[] CreatePremasterSecret() { *************** *** 199,209 **** // Write protocol version ! stream.WriteShort((short)TlsProtocol.Tls1); // Generate random bytes ! byte[] random = new byte[46]; ! RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider(); ! rng.GetNonZeroBytes(random); ! stream.Write(random); byte[] preMasterSecret = stream.GetBytes(); --- 217,224 ---- // Write protocol version ! stream.WriteShort((short)protocol); // Generate random bytes ! stream.Write(GetSecureRandomBytes(46)); byte[] preMasterSecret = stream.GetBytes(); |