EldoS | Feel safer!

Software components for data protection, secure storage and transfer

PGP Plain Text Verify

Also by EldoS: RawDisk
Access locked and protected files in Windows, read and write disks and partitions and more.
#2774
Posted: 04/23/2007 10:49:22
by Andrew Milne (Standard support level)
Joined: 06/16/2006
Posts: 18

I'm having some trouble verifying a PGP signed (not encrypted) plain text string variable. I have the public key in a plain text file.

I get an error "Invalid header line" when calling DecryptAndVerify.

I'm using ver 4.4.0.89.

Code
Public Sub verifyPGP(ByVal txt As String)

   Dim PGPReader As New SBPGP.TElPGPReader
   Dim pubkeyring As New TElPGPKeyring

   Call setLicenseKey() 'used successfully before

   pubkeyring.Load("C:\public.key", String.Empty, True)
   PGPReader.VerifyingKeys = pubkeyring

   Dim inputBytes As Byte() = System.Text.Encoding.ASCII.GetBytes(txt)
   Dim inputStream As New MemoryStream(inputBytes)
   inputBytes = Nothing

   PGPReader.set_OnSigned(AddressOf FiredOnSigned)
   PGPReader.set_OnSignatures(AddressOf FiredOnSignature)

   PGPReader.DecryptAndVerify(inputStream, 0)

   inputStream.Close()
   PGPReader = Nothing
   pubkeyring = Nothing

End Sub

Sub FiredOnSigned(ByVal Sender As Object, ByVal KeyIDs As Byte()(), ByVal SignatureType As SBPGPUtils.TSBPGPSignatureType)
    For Each b As Byte() In KeyIDs
        MsgBox(System.Text.Encoding.ASCII.GetString(b))
    Next
End Sub

Sub FiredOnSignature(ByVal Sender As Object, ByVal Signatures As TElPGPSignature(), ByVal Validities As SBPGPStreams.TSBPGPSignatureValidity())
    For Each s As TElPGPSignature In Signatures
        MsgBox(s.SignerUserID)
    Next
    For Each b As SBPGPStreams.TSBPGPSignatureValidity In Validities
        MsgBox(b.ToString)
    Next
End Sub

My test text is:

Code
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

testing
-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 6.0.2 for non-commercial use <http://www.pgp.com>

iQA/AwUBRizU9xmPz8RPkEd0EQL7UQCg/uz6DwNtvwxslMmlmD01+qXx2lYAoMO/
fM+UjV1OwTT1meA6Gb1ZMTAY
=jk7A
-----END PGP SIGNATURE-----

And the test key file looks like:
Code
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: PGPfreeware 6.0.2 for non-commercial use <http://www.pgp.com>

**key data**
-----END PGP PUBLIC KEY BLOCK-----





#2780
Posted: 04/24/2007 07:17:57
by Ken Ivanov (EldoS Corp.)

Version 4.4.0.89 is quite old. We recommend you to upgrade to the latest available version (5.1.109) and check if the problem appears with it. The latest version contains a lot of compatibility improvements comparing to 4.4.0.89 one.
#2781
Posted: 04/24/2007 07:37:36
by Eugene Mayevski (EldoS Corp.)

If you are stuck to version 4, you can download version 4.4.94 and try it.
Also, we can test your data with SecureBlackbox 5 if you don't want to install it now.
In both cases please contact us via HelpDesk ( http://www.eldos.com/support/ticket_list.php )


Sincerely yours
Eugene Mayevski
#2782
Posted: 04/24/2007 09:22:34
by Andrew Milne (Standard support level)
Joined: 06/16/2006
Posts: 18

Thanks for the reply.

I'm getting an "Invalid Licence Key" error now. Am I going to need a new licence to use version 5 (5.0.107)?

#2783
Posted: 04/24/2007 09:50:36
by Eugene Mayevski (EldoS Corp.)

Yes, you do. I will send you a license letter for SBB 5 now.


Sincerely yours
Eugene Mayevski
#2784
Posted: 04/24/2007 10:16:41
by Andrew Milne (Standard support level)
Joined: 06/16/2006
Posts: 18

Much obliged, thanks for all your help.

One last thing - which should I be checking to confirm the signature is correct?

The Validities of the OnSignature event? I was thinking I should be looking to match the KeyIDs to the PGP Hex KeyID, but they do not seem to match...

Thanks again,

Andrew
#2790
Posted: 04/25/2007 02:24:02
by Ken Ivanov (EldoS Corp.)

Quote
The Validities of the OnSignature event?

Yes. The corresponding key identifiers can be accessed via TElPGPSignature.SignerKeyID property.

Quote
I was thinking I should be looking to match the KeyIDs to the PGP Hex KeyID, but they do not seem to match...

SecureBlackbox declares its own type (TSBKeyID) for storing key identifiers. Please note, that most of PGP implementation display only a half (4 lower bytes) of 8-byte key identifiers for the sake of simplicity.

Please use SBPGPUtils.Unit.KeyID2Str() method to get the string (hex) representation of the corresponding TSBKeyID object. Set its OnlyLowBytes parameter to True to get the key identifier in the 'compatible' (4 bytes) format.
#2791
Posted: 04/25/2007 03:36:14
by Andrew Milne (Standard support level)
Joined: 06/16/2006
Posts: 18

I've got this working now. Thanks for all your help - your standard of support is very good!
Also by EldoS: CallbackFilter
A component to monitor and control disk activity, track file and directory operations (create, read, write, rename etc.), alter file data, encrypt files, create virtual files.

Reply

Statistics

Topic viewed 3083 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!