EldoS | Feel safer!

Software components for data protection, secure storage and transfer

How to Load, verify, and set Trust of Public Key

Also by EldoS: CallbackRegistry
A component to monitor and control Windows registry access and create virtual registry keys.
Posted: 01/30/2009 15:20:27
by Mykola Olshevsky (Basic support level)
Joined: 07/07/2005
Posts: 450

Okay, it can be (), not [] :)
In this case recipient is that person, which can decrypt your message, so that one, whose public key you are using for encryption.
Posted: 02/02/2009 09:12:57
by David Yee (Standard support level)
Joined: 01/26/2009
Posts: 8

OK, for the record, the final rev of the *working* code is as follows:

Dim SBBKey As New SBPGPKeys.TElPGPKeyring
Dim SSBPGPWriter As New SBPGP.TElPGPWriter
Dim fsInputFile As FileStream
Dim fsOutputFile As FileStream

fsInputFile = New FileStream(strFileName, FileMode.Open)

fsOutputFile = New FileStream(strFileName & ".gpg", FileMode.Create)

SBBKey.Load("C:\HSATransmit\pubring.gpg", "", True)
SBBKey.AddPublicKey(SBBKey.PublicKeys(SBBKey.FindPublicKeyByEmailAddress("fxrunit@mellon.com", 0)))

SSBPGPWriter.Filename = strFileName & ".gpg"
SSBPGPWriter.InputIsText = True
SSBPGPWriter.EncryptingKeys = SBBKey
SSBPGPWriter.Encrypt(fsInputFile, fsOutputFile, 0)


Return True
Catch ex As Exception
MessageBox.Show("Encryption error: " & ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Return False
End Try
Posted: 02/03/2009 09:17:42
by David Yee (Standard support level)
Joined: 01/26/2009
Posts: 8

OH OH...that actually did not work. I'm in contact with the file transfer guy at the receiving end of the file, and he can't decrypt it.
I am able to maually encrypt it using the following command line:

gpg --primary-keyring "pubring.gpg" -r "DMCHSAWW" --verbose --output "H:\HsaTransmit\Sent files\HSATransmit-Manual-2-3-2009-1.gpg" --encrypt "H:\HSATransmit\Sent files\HSATransmitTest-2-3-2009-1.txt"

I'm thinking that I need to set the "-r" recipient parameter to "DMCHSAWW". It is not clear in the documentation which function(s) I need to use and what I need to supply the function(s) to accomplish this.
Posted: 02/03/2009 09:41:57
by Ken Ivanov (EldoS Corp.)

Can it be so that you are encrypting a file with a wrong key? You are encrypting the file for a key that belongs to "fxrunit@mellon.com" address, is it the same key that belongs to the "DMCHSAWW" name?

If the correct key is used, please ask your partner to provide more information about the decryption error he encounters.
Posted: 02/03/2009 09:55:35
by David Yee (Standard support level)
Joined: 01/26/2009
Posts: 8

Yes, this is the same key/recipient...I couldn't figure out how to set the "recipient username", so I used the "FindPublicKeyByEmailAddress" instead.
By the way...is there a way to set the recipient public key to use by User name? (as in '-r "DMCHSAWW" ')
Posted: 02/03/2009 10:09:32
by Ken Ivanov (EldoS Corp.)

Then please ask your partner about decryption error he receives.

By the way...is there a way to set the recipient public key to use by User name? (as in '-r "DMCHSAWW" ')

The only way to do it is to iterate over all the keys contained in the keyring, checking that one of the corresponding UserID's contains the needed substring.
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.



Topic viewed 6140 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!