EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Encryption Error "Encryption Session Key is Bad"

Also by EldoS: BizCrypto
Components for BizTalk® and SQL Server® Integration Services that let you securely store and transfer information in your business automation solutions.
#3645
Posted: 08/28/2007 15:06:30
by Joseph Rubio (Basic support level)
Joined: 08/28/2007
Posts: 7

I am looking for a little help with the encryption process. Below is the code I am using to encrypt a file. The file encrypts fine, however when I try and decrypt it I get the following error. "An Error has occurred: Encrypted Session Key is bad". Any help would be appreciated thanks.

Dim PGPwriter As New SBPGP.TElPGPWriter
Dim publicKey As New TElPGPPublicKey
Dim encryptionKey As New TElPGPKeyring
Dim InFile As IO.FileStream
Dim OutFile As IO.FileStream
Dim sSourceFile As String = "C:\test.log"



publicKey.LoadFromFile("C:\Data.asc")
encryptionKey.AddPublicKey(publicKey)
InFile = New System.IO.FileStream(sSourceFile, FileMode.Open)
OutFile = New System.IO.FileStream(sSourceFile & ".pgp", FileMode.Create)



With PGPwriter
.Armor = True
.ArmorHeaders.Clear()
.ArmorHeaders.Add("Version: EldoS OpenPGPBlackbox (.NET edition)")
.ArmorBoundary = "PGP MESSAGE"
.EncryptionType = SBPGP.TSBPGPEncryptionType.etPublicKey
.Compress = False
.Protection = SBPGPConstants.TSBPGPProtectionType.ptLow
.SymmetricKeyAlgorithm = SBPGPConstants.Unit.SB_PGP_ALGORITHM_SK_CAST5
.Timestamp = DateTime.Now
.UseOldPackets = False
.EncryptingKeys = encryptionKey
.Encrypt(InFile, OutFile, 0)

End With

InFile.Close()
OutFile.Close()
#3651
Posted: 08/29/2007 02:28:26
by Eugene Mayevski (EldoS Corp.)

Please provide a bit more information about the problem.
1) What software do you use to decrypt the file?
2) Does the problem happen with the sample keys included with SecureBlackbox (in <SecureBlackbox>\PGPKeys folder)?


Sincerely yours
Eugene Mayevski
#3658
Posted: 08/29/2007 14:22:45
by Joseph Rubio (Basic support level)
Joined: 08/28/2007
Posts: 7

I am using PGP 6.5.3 to decrypt. When I use the sample application to encrypt using the key I do not get an error when I try and decrypt. I read in the forums that I can set UseNewFeatures = false. I tried this and the error went away however when I decrypt the file it would only let me use secureviewer to see the file contents. I know I must be missing something because when I use the sample application everything works fine.
#3659
Posted: 08/29/2007 14:33:33
by Mykola Olshevsky (Basic support level)
Joined: 07/07/2005
Posts: 450

You need to set the PGPWriter.Filename property to the output file name to not to view it with secure viewer (because by default it is set to _CONSOLE, which has special meaning according to OpenPGP standart).
#3661
Posted: 08/30/2007 01:00:48
by Eugene Mayevski (EldoS Corp.)

Quote
Joseph Rubio wrote:
I know I must be missing something because when I use the sample application everything works fine.


You've missed the Search function of the site, that would lead you to the FAQ topic and a dozen of forum posts with the same question.


Sincerely yours
Eugene Mayevski
Also by EldoS: CallbackRegistry
A component to monitor and control Windows registry access and create virtual registry keys.

Reply

Statistics

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