EldoS | Feel safer!

Software components for data protection, secure storage and transfer

PGP operation failed: No appropriate key for decryption found

Also by EldoS: Solid File System
A virtual file system that offers a feature-rich storage for application documents and data with built-in compression and encryption.
#762
Posted: 07/19/2006 09:39:59
by Ken Ivanov (EldoS Corp.)

Would you be so kind to provide more details about the issue:
a) is your project an ASP.NET or Windows Forms application?
b) does this problem appear with the sample keys included to the distribution?

It would be excellent if you provide us something that will help us to reproduce the issue. A document encrypted with the sample keys and a chunk of code that you use to decrypt this document will help us much in solving it.
#765
Posted: 07/19/2006 10:29:41
by Jim Bounce (Basic support level)
Joined: 07/11/2006
Posts: 13

sorry ivanov, it is the same code I posted with other problem. First solutions that works is that I added following:
pgpReader.KeyPassphrase = "das ist ein Test"
previously I had only this:
pgpReader.Passphrase = "das ist ein Test"

funny thing is that the first solutions works with one file, the second with the other.

here the complete code:
Code
Friend Function PGPDecrypt(ByVal sourceFile As String) As Boolean
        Dim keyring As New SBPGPKeys.TElPGPKeyring
        Dim inF As System.IO.FileStream
        mLogger.Log("PGP Decryption runnig...")
        If System.IO.File.Exists(sourceFile) Then
            Try
                keyring.Load("D:\__tmp\pubring.pkr", "D:\__tmp\secring.skr", True)
                pgpReader.DecryptingKeys = keyring
                pgpReader.VerifyingKeys = keyring
                pgpReader.Passphrase = "das ist ein Test"
                pgpReader.KeyPassphrase = "das ist ein Test"
                inF = New System.IO.FileStream(sourceFile, IO.FileMode.Open)
                Try
                    pgpReader.DecryptAndVerify(inF, 0)
                    pgpReader.Dispose()
                Catch ex As Exception
                    Console.WriteLine("unable to necrypt: " & ex.Message)
                    Console.ReadLine()
                End Try
                Console.WriteLine("Loaded successfull")
                Console.WriteLine("hit any key to continue..")
                Console.ReadLine()
            Catch ex As Exception
                Console.WriteLine("Failed to load keyring" & ex.Message)
            End Try
        Else
            Console.WriteLine("File to encrypt does not exists")
            Console.ReadLine()
        End If
        Return True
    End Function


Can u answer me one more question, how can I delete the pgp file after decrypting, before my app terminates. I always become a message that the file is allready in use.

thx a lot
regards
#766
Posted: 07/19/2006 11:00:54
by Ken Ivanov (EldoS Corp.)

Quote
pgpReader.KeyPassphrase = "das ist ein Test"
previously I had only this:
pgpReader.Passphrase = "das ist ein Test"

funny thing is that the first solutions works with one file, the second with the other.

ElPGPReader.KeyPassphrase specifies a passphrase that should be used to decrypt *the secret key*. ElPGPReader.Passphrase specifies a passphrase that should be used to decrypt *the document* (in case if the document was encrypted with a passphrase).

Quote
Can u answer me one more question, how can I delete the pgp file after decrypting, before my app terminates. I always become a message that the file is allready in use.

You will be able to delete the file after releasing the input file stream. It's a good idea to envelope the DecryptAndVerify operation into a Try/Finally block:
Code
Try
  pgpReader.DecryptAndVerify(inF, 0)
Finally
  InF.Close
End Try
#767
Posted: 07/19/2006 11:12:31
by Eugene Mayevski (EldoS Corp.)

I would like to notice, that as our support policy says, the products expect certain level of competence when you use them. We don't teach basics of technology, computers or software development.

I would suggest that you get a book on .NET development - this will save your own time cause you will not need to wait while somebody answers your questions.


Sincerely yours
Eugene Mayevski
#780
Posted: 07/20/2006 04:39:41
by Zane LEO (Standard support level)
Joined: 04/16/2006
Posts: 8

Hi,
I have upgraded from 4.4.90 to 4.4.91; I am using D7. My app has been working for many, many months and now it is not - the error is the same as for this topic title.

The version with 4.4.90 and prior is working fine in the field. I have recompiled my app but did not touch this section. I need help to solev the problem please. Here is a code extract...

begin
lv_PWD := ip_PWD;
if (lv_PWD = '') and ip_UserSignedOn then
lv_PWD := GetUserPassword;

if (ip_DeleteExistingDestFile) and (FileExists(ip_DestFile)) then
try
DeleteFile(ip_DestFile);
except
Result := 'R006'; //unable to delete file
Exit;
end;
if lv_PWD = '' then
begin
Result := 'R008'; //No PGP Password
Exit;
end;

Result := 'R000'; //Process Sucessful
lv_StartTime := now;
try
Src := TFileStream.Create(ip_SrcFile, fmOpenRead or fmShareDenyWrite);
Dst := TFileStream.Create(ip_DestFile, fmCreate);

if ip_DecryptAndVerify then
begin
if (pgpMainKeyring.PublicCount = 0) or (pgpMainKeyring.SecretCount = 0) then
LoadKeySetFromDB;

{ DONE -oZSL -cShow Stopper : Popup for PGP NO PGP Keys }
if (pgpMainKeyring.PublicCount = 0) or (pgpMainKeyring.SecretCount = 0) then
begin
DisplayMsg('No Public PGP Keys found.' +#13#13 + 'Unable to Decrypt file(s)...');
Exit;
end;

//pgpMainKeyring.PublicKeys. SaveToFile('c:\tmp\pubring.pgp',True);
//pgpMainKeyring.SecretKeys.SaveToFile('c:\tmp\Secring.pgp',True);

{ DONE -oZSL -cShow Stopper : Ask for PGP Password }
//comment next 2 lines and sometimes I get a decrypt
pgpReader.DecryptingKeys.Clear;
pgpReader.VerifyingKeys.Clear;
pgpReader.DecryptingKeys := pgpMainKeyring;
pgpReader.VerifyingKeys := pgpMainKeyring;
gv_EncodedDestFile := ip_DestFile;
{ DONE -oZSL -cShow Stopper : Popup for PGP Password }
gv_PGPPWD := lv_PWD;
pgpReader.OutputStream := Dst;
pgpReader.KeyPassphrase := lv_PWD;
pgpReader.Passphrase := lv_PWD;
try
Application.ProcessMessages;
pgpReader.DecryptAndVerify(Src, 0);
except
Result := 'R005'; //Decryption and Verify failure
end;
end
else

If you want I can send the "LoadKeySetFromDB" routine but it works perfectly for Encrypt

TIA

Zane
#782
Posted: 07/20/2006 04:52:16
by Eugene Mayevski (EldoS Corp.)

Please use build 90 (http://www.eldos.com/files/sbb/b90/secbboxnet.zip for .NET edition, for VCL edition add /b90 folder to the URL you have for registered version).


Sincerely yours
Eugene Mayevski
#785
Posted: 07/20/2006 05:39:08
by Eugene Mayevski (EldoS Corp.)

Build 94 for .NET is available at http://www.eldos.com/files/sbb/b94/secbboxnet.zip
It seems to fix the problem. Please test it and let us know so that we can release it to public.


Sincerely yours
Eugene Mayevski
#801
Posted: 07/21/2006 03:29:38
by Zane LEO (Standard support level)
Joined: 04/16/2006
Posts: 8

Eugene

I have install Build 94 and put it through test today.

All is well with the world again... <grin>

Thanks for the great support

Zane
Also by EldoS: Rethync
The cross-platform framework that simplifies synchronizing data between mobile and desktop applications and servers and cloud storages

Reply

Statistics

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