Implement signed message passing in the UIs.
This commit is contained in:
@@ -134,23 +134,17 @@ namespace TestClient
|
||||
|
||||
private void signButton_Click( object sender, EventArgs e )
|
||||
{
|
||||
// Signing not yet supported in the NSspi library;
|
||||
MessageBox.Show( "Signing not yet supported" );
|
||||
return;
|
||||
|
||||
/*
|
||||
byte[] plaintext;
|
||||
byte[] cipherText;
|
||||
Message message;
|
||||
|
||||
plaintext = Encoding.UTF8.GetBytes( this.sendTextbox.Text );
|
||||
|
||||
cipherText = this.context.Sign( plaintext );
|
||||
cipherText = this.context.MakeSignature( plaintext );
|
||||
|
||||
message = new Message( ProtocolOp.SignedMessage, cipherText );
|
||||
|
||||
this.connection.Send( message );
|
||||
*/
|
||||
}
|
||||
|
||||
private void connection_Received( Message message )
|
||||
@@ -175,7 +169,7 @@ namespace TestClient
|
||||
}
|
||||
else if( message.Operation == ProtocolOp.SignedMessage )
|
||||
{
|
||||
// Not yet supported
|
||||
HandleSigned( message );
|
||||
}
|
||||
} );
|
||||
}
|
||||
@@ -234,6 +228,21 @@ namespace TestClient
|
||||
this.receiveTextbox.Text += "Received encrypted message from server:\r\n" + text + "\r\n";
|
||||
}
|
||||
|
||||
private void HandleSigned( Message message )
|
||||
{
|
||||
byte[] plaintext;
|
||||
string text;
|
||||
|
||||
if( this.context.VerifySignature( message.Data, out plaintext ) )
|
||||
{
|
||||
text = Encoding.UTF8.GetString( plaintext );
|
||||
this.receiveTextbox.Text += "Received valid signed message from server:\r\n" + text + "\r\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
this.receiveTextbox.Text += "Received *** invalid *** signed message from server.\r\n";
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateButtons()
|
||||
{
|
||||
|
||||
@@ -108,7 +108,15 @@ namespace TestServer
|
||||
|
||||
private void signButton_Click( object sender, EventArgs e )
|
||||
{
|
||||
// Not implemented.
|
||||
byte[] plainText = Encoding.UTF8.GetBytes( this.sendTextbox.Text );
|
||||
byte[] signedData;
|
||||
Message message;
|
||||
|
||||
signedData = this.serverContext.MakeSignature( plainText );
|
||||
|
||||
message = new Message( ProtocolOp.SignedMessage, signedData );
|
||||
|
||||
this.server.Send( message );
|
||||
}
|
||||
|
||||
private void UpdateButtons()
|
||||
@@ -211,16 +219,21 @@ namespace TestServer
|
||||
|
||||
private void HandleSigned( Message message )
|
||||
{
|
||||
// Not implemented yet.
|
||||
/*
|
||||
this.Invoke( (Action)delegate()
|
||||
{
|
||||
byte[] plainText = this.serverContext.Decrypt( message.Data );
|
||||
string text = Encoding.UTF8.GetString( plainText );
|
||||
byte[] plainText;
|
||||
|
||||
this.receivedTextbox.Text += "Received encrypted message from client:\r\n" + text + "\r\n";
|
||||
if( this.serverContext.VerifySignature( message.Data, out plainText ) )
|
||||
{
|
||||
string text = Encoding.UTF8.GetString( plainText );
|
||||
|
||||
this.receivedTextbox.Text += "Received valid signed message from client:\r\n" + text + "\r\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
this.receivedTextbox.Text += "Received *** invalid *** signed message from client.\r\n";
|
||||
}
|
||||
} );
|
||||
*/
|
||||
}
|
||||
|
||||
private void HandleUnknown( Message message )
|
||||
|
||||
Reference in New Issue
Block a user