EldoS | Feel safer!

Software components for data protection, secure storage and transfer

File Decryption - VBScript - Please Help !

Also by EldoS: MsgConnect
Cross-platform protocol-independent communication framework for building peer-to-peer and client-server applications and middleware components.
#18973
Posted: 02/08/2012 05:43:42
by Harsh Patel (Priority Standard support level)
Joined: 02/08/2012
Posts: 14

Hi - I have recently downloaded the SecureBlackBox demo and am trying to see if this will work for simple file encryption and decryption.

I have managed to write a vbscript to Encrypt a file using only a Public Key file.

I am now trying to Decrypt the file using the same public key file.

Code
Set PGPReader = CreateObject("PGPBBox8.ElPGPReaderX")
PGPReader.DecryptingKeys = PGPEncFile
PGPReader.VerifyingKeys = PGPEncFile
PGPReader.DecryptAndVerifyFile strFileSource


When I run the script, I keep getting an error "PGPBBox8.ElPGPReaderX: No appropriate OpenPGP secret key for decryption found"

Can anyone help....I tried searching throuogh the forum and also tried following any examples, but unfortunately can't find any examples for file encryption and decryption using vbscript.

Thanks
#18974
Posted: 02/08/2012 05:52:07
by Vsevolod Ievgiienko (EldoS Corp.)

Thank you for contacting us.

1) Are you sure that you use appropriate keys for decryption?
2) Did you set license key? You can see how to set it in the sample that is located in \EldoS\SecureBlackbox.AX\Samples\Scripts\SFTPBlackbox\Client\SimpleSftpDemo folder (its not related to OpenPGP).
#18975
Posted: 02/08/2012 05:55:43
by Harsh Patel (Priority Standard support level)
Joined: 02/08/2012
Posts: 14

I think I have set this correctly...here's more snippet of my code for the Encrypting and decrypting:

Code
Dim LicenseMgr, PGPEncFile, PGPWriter, strTemp
Set LicenseMgr = CreateObject("BaseBBox8.ElSBLicenseManagerX")
Set PGPEncFile = CreateObject("PGPBBox8.ElPGPKeyringX")
Set PGPWriter = CreateObject("PGPBBox8.ElPGPWriterX")
Set PGPReader = CreateObject("PGPBBox8.ElPGPReaderX")
   
   Success = LicenseMgr.SetLicenseKey ("8343...1648")
If (Success <> "") Then
QuitProcess ".......... Failed to Load Valid License Key"
End If
   
' Load the Public Key
Success = PGPEncFile.LoadFromFiles (PGPEncryptionKey,"",Clear)
If (Success <> "") Then
QuitProcess ".......... Failed to Load Valid License Key" & PGPEncryptionKey
End If
   
' Set to use public key encryption type and encrypt the file
PGPWriter.EncryptionType = etPublicKey
PGPWriter.EncryptingKeys = PGPEncFile
PGPWriter.EncryptFile strFileSource   

' Decrypt the file, just to check that it can be decrypted!
PGPReader.DecryptingKeys = PGPEncFile
PGPReader.VerifyingKeys = PGPEncFile
PGPReader.DecryptAndVerifyFile strFileSource
#18976
Posted: 02/08/2012 06:02:21
by Vsevolod Ievgiienko (EldoS Corp.)

Code
Success = PGPEncFile.LoadFromFiles (PGPEncryptionKey,"",Clear)

You pass the second parameter as an empty string thats why your code loads only public keys while you need secret keys for decryption.
#19076
Posted: 02/15/2012 10:52:14
by Harsh Patel (Priority Standard support level)
Joined: 02/08/2012
Posts: 14

OK - I am trying to get my head around this (being a noob!)..

I have created a set of test keys (Private and Public).

I managed to Encrypt a test text file using the public key. Now I am trtying to decrypt that file and the code I am using is:

Code
Set PGPEncFile = CreateObject("PGPBBox8.ElPGPKeyringX")
PGPPrivEncKeyC = "C:\secret-key-E60306CF.asc"         
PGPPubEncKeyC = "C:\PublicTest.key"

PGPEncFile.LoadFromFiles PGPPubEncKeyC,PGPPrivEncKeyC,True


When I execute this it gives me an error :

PGPBBox8.ElPGPKeyringX: Invalid header line


Any Ideas ....?

Thanks
#19078
Posted: 02/15/2012 10:59:49
by Vsevolod Ievgiienko (EldoS Corp.)

Could you please attach here both key files.
#19079
Posted: 02/15/2012 11:03:41
by Harsh Patel (Priority Standard support level)
Joined: 02/08/2012
Posts: 14

Secret Key..


[ Download ]
#19080
Posted: 02/15/2012 11:04:04
by Harsh Patel (Priority Standard support level)
Joined: 02/08/2012
Posts: 14

Public Key ....


[ Download ]
#19081
Posted: 02/15/2012 11:07:04
by Vsevolod Ievgiienko (EldoS Corp.)

The public key is OK but you should remove all text that is located before -----BEGIN PGP PUBLIC KEY BLOCK----- in the private key file.
#19083
Posted: 02/15/2012 11:19:24
by Harsh Patel (Priority Standard support level)
Joined: 02/08/2012
Posts: 14

Fabulous - that get's me one step closer !

So now I have the following:
Code
Set PGPEncFile = CreateObject("PGPBBox8.ElPGPKeyringX")
PGPPrivEncKeyC = "C:\secret-key-E60306CF.asc"          
PGPPubEncKeyC = "C:\PublicTest.key"

PGPEncFile.LoadFromFiles PGPPubEncKeyC,PGPPrivEncKeyC,True
PGPReader.DecryptingKeys = PGPEncFile
PGPReader.KeyPassphrase = "password"
PGPReader.DecryptAndVerifyFile strSource


Now this does not return any errors (and thanks for your help !). SO how do I get to write out the decrypted data to a file ?

Thanks again...
Also by EldoS: MsgConnect
Cross-platform protocol-independent communication framework for building peer-to-peer and client-server applications and middleware components.

Reply

Statistics

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