trunk/src/LythumOSL.Net.Lslw/LslwRawConnection.cs
/// <summary>
/// This method must be called before any encrypting and etc...
/// Eslewhere data will be encrypted with random keys which is just for initialization of objects
/// And later replaced with good keys
/// </summary>
/// <returns></returns>
This method must be called before any encrypting and etc
Eslewhere data will be encrypted with random keys which is just for initialization of objects
And later replaced with good keys
This method must be called before any encrypting and etc Eslewhere data will be encrypted with random keys which is just for initialization of objects And later replaced with good keys
public bool Connect ()
		{
			if (_Connected)
			{
				return _Connected;
			}
			string errorStage = string.Empty;
				errorStage = "requesting RSA public key";	
				LslwResult result = RawRequest( LslwRawOperation.RsaGetPublicKey, null);
				if (result.HasErrors)
				{
					return false;
				}
				errorStage = "loading RSA public key"; 
				_Rsa.LoadCertificateFromString (result.Result);
				errorStage = "generating AES keys"; 
				_Aes.GenerateRandomKeys ();
				HttpAttributes postData = PreparePostData ();
				postData["key"] = Base64.Encode( _Rsa.Encrypt (_Aes.Key), true);
				postData["iv"] = Base64.Encode (_Rsa.Encrypt (_Aes.IV), true);
				errorStage = "sending AES keys"; 
				result = RawRequest (LslwRawOperation.AesReceiveKey, postData);
				errorStage = "parsing AES result"; 
				if (!result.HasErrors)
				{
					string[] nodes = result.DecryptedResult.Split (' ');
					_Connected = nodes[0].Equals("000");
				}
			return _Connected;
		}
public bool Connect ( ) { if ( _Connected ) { return _Connected ; } string errorStage = string . Empty ; errorStage = " " ; LslwResult result = RawRequest ( LslwRawOperation . RsaGetPublicKey , null ) ; if ( result . HasErrors ) { return false ; } errorStage = " " ; _Rsa . LoadCertificateFromString ( result . Result ) ; errorStage = " " ; _Aes . GenerateRandomKeys ( ) ; HttpAttributes postData = PreparePostData ( ) ; postData [ " " ] = Base64 . Encode ( _Rsa . Encrypt ( _Aes . Key ) , true ) ; postData [ " " ] = Base64 . Encode ( _Rsa . Encrypt ( _Aes . IV ) , true ) ; errorStage = " " ; result = RawRequest ( LslwRawOperation . AesReceiveKey , postData ) ; errorStage = " " ; if ( ! result . HasErrors ) { string [ ] nodes = result . DecryptedResult . Split ( ' ' ) ; _Connected = nodes [ 0 ] . Equals ( " " ) ; } return _Connected ; }
This method must be called before any encrypting and etc...
Eslewhere data will be encrypted with random keys which is just for initialization of objects
And later replaced with good keys
This method must be called before any encrypting and etc ... Eslewhere data will be encrypted with random keys which is just for initialization of objects And later replaced with good keys
// checking if already connected //try //{ // RSA // RSA // AES //DumpKeys ("Keys before generate"); //DumpKeys ("Keys after generate"); // AES //} //catch (Exception ex) //{ //    Error ("Error " + errorStage + "\r\n" + ex.Message + "\r\n" + ex.StackTrace); //}
None