HSM Simulator - Decryption Problem

Apr 30, 2012 at 5:13 AM

Hi,

I have encrypted and decrypted a PIN provided in a textbox successfully.

Now I want to move further in development.

In my case I shall be provided with a list of encrypted PINs and i need to decrypt them. So I tried one decrypted key "DBE85D5EE01D" by using one of the following keys

  •  
    • 1313131313131313
    • 1515151515151515

And following code i use to decrypt this PIN

 

/**************************************************************************************************************/

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Try
            thales = New TCP.WorkerClient(New Net.Sockets.TcpClient(txtIPAddress.Text, Convert.ToInt32(txtPort.Text)))
            thales.InitOps()
        Catch ex As Exception
            doLog("Connection error (" + ex.Message + ")")
            Me.Enabled = True
            Exit Sub
        End Try
        txtLog.Text = ""
        'Dim key As New Cryptography.HexKey("1313131313131313")
        Dim key As New Cryptography.HexKey("1515151515151515")

       
        ' This line gives error
        doLog("DEc Pin = " + Cryptography.TripleDES.TripleDESDecrypt(key, "DBE85D5EE01D").Substring(0, 4))

        thales.TermClient()
        thales = Nothing


    End Sub

/**************************************************************************************************************/

When this code is executed, then at the line

 doLog("DEc Pin = " + Cryptography.TripleDES.TripleDESDecrypt(key, "DBE85D5EE01D").Substring(0, 4))

it gives following error:

XInvalidData was unhandled
Invalid data for 3DEncrypt

 

Please advise.

Many Thanks & Regards,

Shabber.

 

 


Coordinator
Apr 30, 2012 at 9:50 AM

I've no problem helping you out. But I think that a debug session would help you much more than me just pointing out the mistake. Just step in the TripleDESDecrypt method call.

Apr 30, 2012 at 10:12 AM

Thanks Nick,

 

I did it and found that decrypted PIN was having some spaces thats why it was giving errors.

 

Regards,