Commit fa47e066 authored by Josh Ji's avatar Josh Ji

AES padding mode, sql connect string

parent 02a565bc
No preview for this file type
...@@ -58,6 +58,7 @@ ...@@ -58,6 +58,7 @@
this.tabControl2 = new System.Windows.Forms.TabControl(); this.tabControl2 = new System.Windows.Forms.TabControl();
this.tabPage4 = new System.Windows.Forms.TabPage(); this.tabPage4 = new System.Windows.Forms.TabPage();
this.tabPage5 = new System.Windows.Forms.TabPage(); this.tabPage5 = new System.Windows.Forms.TabPage();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.tabControl1.SuspendLayout(); this.tabControl1.SuspendLayout();
this.tabPage1.SuspendLayout(); this.tabPage1.SuspendLayout();
this.tabPage2.SuspendLayout(); this.tabPage2.SuspendLayout();
...@@ -68,7 +69,7 @@ ...@@ -68,7 +69,7 @@
// //
// selectFIDOApplet // selectFIDOApplet
// //
this.selectFIDOApplet.Location = new System.Drawing.Point(832, 87); this.selectFIDOApplet.Location = new System.Drawing.Point(832, 108);
this.selectFIDOApplet.Name = "selectFIDOApplet"; this.selectFIDOApplet.Name = "selectFIDOApplet";
this.selectFIDOApplet.Size = new System.Drawing.Size(119, 23); this.selectFIDOApplet.Size = new System.Drawing.Size(119, 23);
this.selectFIDOApplet.TabIndex = 0; this.selectFIDOApplet.TabIndex = 0;
...@@ -78,7 +79,7 @@ ...@@ -78,7 +79,7 @@
// //
// getInfo // getInfo
// //
this.getInfo.Location = new System.Drawing.Point(832, 116); this.getInfo.Location = new System.Drawing.Point(832, 137);
this.getInfo.Name = "getInfo"; this.getInfo.Name = "getInfo";
this.getInfo.Size = new System.Drawing.Size(119, 23); this.getInfo.Size = new System.Drawing.Size(119, 23);
this.getInfo.TabIndex = 1; this.getInfo.TabIndex = 1;
...@@ -98,7 +99,7 @@ ...@@ -98,7 +99,7 @@
// //
// clearWindow // clearWindow
// //
this.clearWindow.Location = new System.Drawing.Point(832, 58); this.clearWindow.Location = new System.Drawing.Point(832, 79);
this.clearWindow.Name = "clearWindow"; this.clearWindow.Name = "clearWindow";
this.clearWindow.Size = new System.Drawing.Size(119, 23); this.clearWindow.Size = new System.Drawing.Size(119, 23);
this.clearWindow.TabIndex = 3; this.clearWindow.TabIndex = 3;
...@@ -119,7 +120,7 @@ ...@@ -119,7 +120,7 @@
// //
// getPuKxRx // getPuKxRx
// //
this.getPuKxRx.Location = new System.Drawing.Point(832, 290); this.getPuKxRx.Location = new System.Drawing.Point(832, 311);
this.getPuKxRx.Name = "getPuKxRx"; this.getPuKxRx.Name = "getPuKxRx";
this.getPuKxRx.Size = new System.Drawing.Size(119, 23); this.getPuKxRx.Size = new System.Drawing.Size(119, 23);
this.getPuKxRx.TabIndex = 7; this.getPuKxRx.TabIndex = 7;
...@@ -129,7 +130,7 @@ ...@@ -129,7 +130,7 @@
// //
// getAttestationPublicKey // getAttestationPublicKey
// //
this.getAttestationPublicKey.Location = new System.Drawing.Point(832, 145); this.getAttestationPublicKey.Location = new System.Drawing.Point(832, 166);
this.getAttestationPublicKey.Name = "getAttestationPublicKey"; this.getAttestationPublicKey.Name = "getAttestationPublicKey";
this.getAttestationPublicKey.Size = new System.Drawing.Size(164, 23); this.getAttestationPublicKey.Size = new System.Drawing.Size(164, 23);
this.getAttestationPublicKey.TabIndex = 8; this.getAttestationPublicKey.TabIndex = 8;
...@@ -139,7 +140,7 @@ ...@@ -139,7 +140,7 @@
// //
// dumpIDSecret // dumpIDSecret
// //
this.dumpIDSecret.Location = new System.Drawing.Point(832, 261); this.dumpIDSecret.Location = new System.Drawing.Point(832, 282);
this.dumpIDSecret.Name = "dumpIDSecret"; this.dumpIDSecret.Name = "dumpIDSecret";
this.dumpIDSecret.Size = new System.Drawing.Size(119, 23); this.dumpIDSecret.Size = new System.Drawing.Size(119, 23);
this.dumpIDSecret.TabIndex = 9; this.dumpIDSecret.TabIndex = 9;
...@@ -149,7 +150,7 @@ ...@@ -149,7 +150,7 @@
// //
// getCx // getCx
// //
this.getCx.Location = new System.Drawing.Point(832, 319); this.getCx.Location = new System.Drawing.Point(832, 340);
this.getCx.Name = "getCx"; this.getCx.Name = "getCx";
this.getCx.Size = new System.Drawing.Size(119, 23); this.getCx.Size = new System.Drawing.Size(119, 23);
this.getCx.TabIndex = 10; this.getCx.TabIndex = 10;
...@@ -159,7 +160,7 @@ ...@@ -159,7 +160,7 @@
// //
// getPuKxCx // getPuKxCx
// //
this.getPuKxCx.Location = new System.Drawing.Point(832, 377); this.getPuKxCx.Location = new System.Drawing.Point(832, 398);
this.getPuKxCx.Name = "getPuKxCx"; this.getPuKxCx.Name = "getPuKxCx";
this.getPuKxCx.Size = new System.Drawing.Size(119, 23); this.getPuKxCx.Size = new System.Drawing.Size(119, 23);
this.getPuKxCx.TabIndex = 11; this.getPuKxCx.TabIndex = 11;
...@@ -250,7 +251,7 @@ ...@@ -250,7 +251,7 @@
// //
// resetCredentials // resetCredentials
// //
this.resetCredentials.Location = new System.Drawing.Point(832, 232); this.resetCredentials.Location = new System.Drawing.Point(832, 253);
this.resetCredentials.Name = "resetCredentials"; this.resetCredentials.Name = "resetCredentials";
this.resetCredentials.Size = new System.Drawing.Size(119, 23); this.resetCredentials.Size = new System.Drawing.Size(119, 23);
this.resetCredentials.TabIndex = 13; this.resetCredentials.TabIndex = 13;
...@@ -260,7 +261,7 @@ ...@@ -260,7 +261,7 @@
// //
// getCredentialCount // getCredentialCount
// //
this.getCredentialCount.Location = new System.Drawing.Point(832, 203); this.getCredentialCount.Location = new System.Drawing.Point(832, 224);
this.getCredentialCount.Name = "getCredentialCount"; this.getCredentialCount.Name = "getCredentialCount";
this.getCredentialCount.Size = new System.Drawing.Size(134, 23); this.getCredentialCount.Size = new System.Drawing.Size(134, 23);
this.getCredentialCount.TabIndex = 14; this.getCredentialCount.TabIndex = 14;
...@@ -270,7 +271,7 @@ ...@@ -270,7 +271,7 @@
// //
// getFreeSpace // getFreeSpace
// //
this.getFreeSpace.Location = new System.Drawing.Point(832, 174); this.getFreeSpace.Location = new System.Drawing.Point(832, 195);
this.getFreeSpace.Name = "getFreeSpace"; this.getFreeSpace.Name = "getFreeSpace";
this.getFreeSpace.Size = new System.Drawing.Size(119, 23); this.getFreeSpace.Size = new System.Drawing.Size(119, 23);
this.getFreeSpace.TabIndex = 15; this.getFreeSpace.TabIndex = 15;
...@@ -280,7 +281,7 @@ ...@@ -280,7 +281,7 @@
// //
// IDxBox // IDxBox
// //
this.IDxBox.Location = new System.Drawing.Point(832, 348); this.IDxBox.Location = new System.Drawing.Point(832, 369);
this.IDxBox.Name = "IDxBox"; this.IDxBox.Name = "IDxBox";
this.IDxBox.PlaceholderText = "IDx"; this.IDxBox.PlaceholderText = "IDx";
this.IDxBox.Size = new System.Drawing.Size(119, 23); this.IDxBox.Size = new System.Drawing.Size(119, 23);
...@@ -288,7 +289,7 @@ ...@@ -288,7 +289,7 @@
// //
// ClientPIN_getRetries // ClientPIN_getRetries
// //
this.ClientPIN_getRetries.Location = new System.Drawing.Point(1004, 58); this.ClientPIN_getRetries.Location = new System.Drawing.Point(1004, 79);
this.ClientPIN_getRetries.Name = "ClientPIN_getRetries"; this.ClientPIN_getRetries.Name = "ClientPIN_getRetries";
this.ClientPIN_getRetries.Size = new System.Drawing.Size(181, 23); this.ClientPIN_getRetries.Size = new System.Drawing.Size(181, 23);
this.ClientPIN_getRetries.TabIndex = 17; this.ClientPIN_getRetries.TabIndex = 17;
...@@ -298,7 +299,7 @@ ...@@ -298,7 +299,7 @@
// //
// ClientPIN_getKeyAgreement // ClientPIN_getKeyAgreement
// //
this.ClientPIN_getKeyAgreement.Location = new System.Drawing.Point(1004, 87); this.ClientPIN_getKeyAgreement.Location = new System.Drawing.Point(1004, 108);
this.ClientPIN_getKeyAgreement.Name = "ClientPIN_getKeyAgreement"; this.ClientPIN_getKeyAgreement.Name = "ClientPIN_getKeyAgreement";
this.ClientPIN_getKeyAgreement.Size = new System.Drawing.Size(181, 23); this.ClientPIN_getKeyAgreement.Size = new System.Drawing.Size(181, 23);
this.ClientPIN_getKeyAgreement.TabIndex = 18; this.ClientPIN_getKeyAgreement.TabIndex = 18;
...@@ -308,7 +309,7 @@ ...@@ -308,7 +309,7 @@
// //
// pinBox // pinBox
// //
this.pinBox.Location = new System.Drawing.Point(1004, 116); this.pinBox.Location = new System.Drawing.Point(1004, 137);
this.pinBox.Name = "pinBox"; this.pinBox.Name = "pinBox";
this.pinBox.PlaceholderText = "PIN"; this.pinBox.PlaceholderText = "PIN";
this.pinBox.Size = new System.Drawing.Size(119, 23); this.pinBox.Size = new System.Drawing.Size(119, 23);
...@@ -316,7 +317,7 @@ ...@@ -316,7 +317,7 @@
// //
// SetPIN // SetPIN
// //
this.SetPIN.Location = new System.Drawing.Point(1004, 145); this.SetPIN.Location = new System.Drawing.Point(1004, 166);
this.SetPIN.Name = "SetPIN"; this.SetPIN.Name = "SetPIN";
this.SetPIN.Size = new System.Drawing.Size(181, 23); this.SetPIN.Size = new System.Drawing.Size(181, 23);
this.SetPIN.TabIndex = 20; this.SetPIN.TabIndex = 20;
...@@ -363,11 +364,23 @@ ...@@ -363,11 +364,23 @@
this.tabPage5.Text = "load cert"; this.tabPage5.Text = "load cert";
this.tabPage5.UseVisualStyleBackColor = true; this.tabPage5.UseVisualStyleBackColor = true;
// //
// comboBox1
//
this.comboBox1.FormattingEnabled = true;
this.comboBox1.Items.AddRange(new object[] {
"127.0.0.1:3306",
"192.168.0.100:32306"});
this.comboBox1.Location = new System.Drawing.Point(832, 50);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(164, 23);
this.comboBox1.TabIndex = 22;
//
// Form1 // Form1
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1211, 729); this.ClientSize = new System.Drawing.Size(1211, 729);
this.Controls.Add(this.comboBox1);
this.Controls.Add(this.tabControl2); this.Controls.Add(this.tabControl2);
this.Controls.Add(this.SetPIN); this.Controls.Add(this.SetPIN);
this.Controls.Add(this.pinBox); this.Controls.Add(this.pinBox);
...@@ -388,6 +401,7 @@ ...@@ -388,6 +401,7 @@
this.Controls.Add(this.selectFIDOApplet); this.Controls.Add(this.selectFIDOApplet);
this.Name = "Form1"; this.Name = "Form1";
this.Text = "Form1"; this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.tabControl1.ResumeLayout(false); this.tabControl1.ResumeLayout(false);
this.tabPage1.ResumeLayout(false); this.tabPage1.ResumeLayout(false);
this.tabPage1.PerformLayout(); this.tabPage1.PerformLayout();
...@@ -435,5 +449,6 @@ ...@@ -435,5 +449,6 @@
private TabControl tabControl2; private TabControl tabControl2;
private TabPage tabPage4; private TabPage tabPage4;
private TabPage tabPage5; private TabPage tabPage5;
private ComboBox comboBox1;
} }
} }
\ No newline at end of file
...@@ -239,7 +239,9 @@ namespace FidoReader ...@@ -239,7 +239,9 @@ namespace FidoReader
} }
Debug.WriteLine("Mysql Connecting ..."); Debug.WriteLine("Mysql Connecting ...");
#region mysql connecting #region mysql connecting
string connectString = "server=127.0.0.1;port=3306;user id=IDP;password=idppasswd;database=idp;charset=utf8;"; string mysql_addr = comboBox1.Text.Split(':')[0];
string mysql_port = comboBox1.Text.Split(':')[1];
string connectString = "server="+ mysql_addr+ ";port="+ mysql_port+ ";user id=root;password=rootpasswd;database=idp;charset=utf8;";
MySqlConnection mySqlConnection = new MySqlConnection(connectString); MySqlConnection mySqlConnection = new MySqlConnection(connectString);
if (mySqlConnection.State != ConnectionState.Open) { if (mySqlConnection.State != ConnectionState.Open) {
try { try {
...@@ -332,11 +334,11 @@ namespace FidoReader ...@@ -332,11 +334,11 @@ namespace FidoReader
aes.Key = hashedSharedSecrect; aes.Key = hashedSharedSecrect;
aes.BlockSize = 128; aes.BlockSize = 128;
aes.Mode = CipherMode.CBC; aes.Mode = CipherMode.CBC;
aes.Padding = PaddingMode.None; aes.Padding = PaddingMode.PKCS7;
aes.IV = IV; aes.IV = IV;
// decrypt cx // decrypt cx
byte[] decryptedCx = aes.DecryptCbc(encryptedCx, IV, PaddingMode.None); byte[] decryptedCx = aes.DecryptCbc(encryptedCx, IV, PaddingMode.PKCS7);
paramBox.Text += "Encrypted Cx : " + BitConverter.ToString(encryptedCx) + "\r\n"; paramBox.Text += "Encrypted Cx : " + BitConverter.ToString(encryptedCx) + "\r\n";
paramBox.Text += "Decrypted Cx : " + BitConverter.ToString(decryptedCx) + "\r\n"; paramBox.Text += "Decrypted Cx : " + BitConverter.ToString(decryptedCx) + "\r\n";
...@@ -347,7 +349,7 @@ namespace FidoReader ...@@ -347,7 +349,7 @@ namespace FidoReader
Debug.WriteLine(BitConverter.ToString(IDxAndCx)); Debug.WriteLine(BitConverter.ToString(IDxAndCx));
byte[] hashedIDxAndCx = sha256.ComputeHash(IDxAndCx); byte[] hashedIDxAndCx = sha256.ComputeHash(IDxAndCx);
paramBox.Text += "hashedIDxAndCx : " + BitConverter.ToString(hashedIDxAndCx) + "\r\n"; paramBox.Text += "hashedIDxAndCx : " + BitConverter.ToString(hashedIDxAndCx) + "\r\n";
byte[] hmac = aes.EncryptCbc(hashedIDxAndCx, IV, PaddingMode.None); byte[] hmac = aes.EncryptCbc(hashedIDxAndCx, IV, PaddingMode.PKCS7);
paramBox.Text += "hmac : " + BitConverter.ToString(hmac) + "\r\n"; paramBox.Text += "hmac : " + BitConverter.ToString(hmac) + "\r\n";
String hmacBase64 = Convert.ToBase64String(hmac); String hmacBase64 = Convert.ToBase64String(hmac);
...@@ -807,5 +809,9 @@ namespace FidoReader ...@@ -807,5 +809,9 @@ namespace FidoReader
file.Close(); file.Close();
} }
} }
private void Form1_Load(object sender, EventArgs e) {
comboBox1.SelectedIndex = 0;
}
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment