Quantcast
Channel: Common Language Runtime Internals and Architecture forum
Viewing all articles
Browse latest Browse all 1710

Cngkey import not working for ECDSA

$
0
0

Hi,

I am trying to use the CngKey import and it gives me an exception.

I have a byte array of 64 bytes as my public key and I need to used it to verify an ECDSA signature received.

How will be this possible

if I use this sequence it works all the time.

 Dim dsa1 = New ECDsaCng(256)


            Dim publicKey = dsa1.Key.Export(CngKeyBlobFormat.EccPublicBlob)

            signature = dsa1.SignData(message)

            ' Dim crypto = New ECDsaCng(newKey)
            'Dim verify = crypto.VerifyHash()

            Dim key = CngKey.Import(publicKey, CngKeyBlobFormat.EccPublicBlob)
            Dim dsa = New ECDsaCng(key)
            dsa.HashAlgorithm = CngAlgorithm.Sha256

            If dsa.VerifyData(message, signature) Then
                MessageBox.Show("Verified")
                Return True
            Else
                MessageBox.Show("Not Verified")

                Return False
            End If

But I do not need to sign or export my current data. I need to verify a signature received using a known public key that is made as a byte array

I have my byte array and I even pad data to the array to meet the 72 byte format I see in when creating the key. Yet the program does not work and exemption occurs.

keyType = New Byte() {&H45, &H43, &H53, &H31}
keyLength = New Byte() {&H20, &H0, &H0, &H0}

keyImport = keyType.Concat(keyLength).Concat(publicKey_ax).Concat(publicKey_ay).ToArray

the publickey_ax and publicKey_ay contain the public key

newKey = CngKey.Import(keyImport, CngKeyBlobFormat.GenericPublicBlob) //this makes an exeption

Please help me find a solution. I am currently developing an ECDSA application and we cannot continue with this function broken.

Regards,

Aaron Arellano

Maxim Integrated Products

aaron.arellano@maximintegrated.com


Viewing all articles
Browse latest Browse all 1710

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>