EldoS | Feel safer!

Software components for data protection, secure storage and transfer

PGP: How do I import a private key into a keyring ?

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.
#31151
Posted: 10/28/2014 11:54:11
by Stephane Grobety (Priority Standard support level)
Joined: 04/18/2006
Posts: 170

Hello,

I have an issue with keys exported from Kleopatra: I can't seem to find a way to properly import them into a Keyring WITH the private key part.

It tried the following code:

Code
      ANewKey := TElPGPPublicKey.Create();
      try
        ANewKey.LoadFromFile(OpenDlg.FileName);
        pgpKeyring.AddPublicKey(ANewKey);
      finally
        ANewkey.Free;
      end;


And this does not load the private key part.

I then tried this code:

Code
      ANewKey := TElPGPSecretKey.Create();
      try
        ANewKey.LoadFromFile(OpenDlg.FileName);
        pgpKeyring.AddSecretKey(ANewKey);
      finally
        ANewkey.Free;
      end;


And it seems to work but the key isn't actually loaded properly.

I attach a file as exported by Kleopatra to this message

And the corresponding pèasphrase (although that shouldn't be necessary):

9ouv9W9jtcW0D4B701ZWL8MKegxCDcHyFpp9ttsy


[ Download ]
#31153
Posted: 10/28/2014 11:56:21
by Eugene Mayevski (EldoS Corp.)

You load the key or keyring (PGP format allows this) right into TElPGPKeyring object. Please try this.


Sincerely yours
Eugene Mayevski
#31155
Posted: 10/28/2014 12:07:12
by Stephane Grobety (Priority Standard support level)
Joined: 04/18/2006
Posts: 170

Thanks for answering

How do I do that: All I have is a single file. No overload version of the TElPGPKeyring object accepts a single stream: all wants to deal with private and public key collections separately.
#31156
Posted: 10/28/2014 12:12:03
by Eugene Mayevski (EldoS Corp.)

Just pass empty string to other parameter.


Sincerely yours
Eugene Mayevski
#31157
Posted: 10/28/2014 12:17:44
by Stephane Grobety (Priority Standard support level)
Joined: 04/18/2006
Posts: 170

It still doesn't import the secret key if I do that, I'm afraid.
#31158
Posted: 10/28/2014 12:20:06
by Eugene Mayevski (EldoS Corp.)

Then you don't have private keys in the file.


Sincerely yours
Eugene Mayevski
#31159
Posted: 10/28/2014 12:22:00
by Stephane Grobety (Priority Standard support level)
Joined: 04/18/2006
Posts: 170

Thanks again for your answer.

But I do have a private key: please look at the sample I provided.

Regards,
Stephane
#31160
Posted: 10/28/2014 12:23:43
by Eugene Mayevski (EldoS Corp.)

The file can not be found (if you click the link, you'll see this).

Now how do you know that the file contains the private key(s)?


Sincerely yours
Eugene Mayevski
#31161
Posted: 10/28/2014 12:26:56
by Stephane Grobety (Priority Standard support level)
Joined: 04/18/2006
Posts: 170

I know there is a private key inside because.

1/ I explicitly exported the private key from Kleopatra
2/ When I re-import the same file in Kleopatra into a new keyring, the result contains a private key.
3/ look at the delimiters


Here is the content of the file:

-----BEGIN PGP PRIVATE KEY BLOCK-----
Version: GnuPG v2.0.22 (MingW32)

lQO+BFRPyMoBCACyQ6aI2lzZe1PdBw9PN6Q6qA9Kg5i3uErN60+v/A0u1zRBjNEL
dtH7nnLBtvMSp4GEA7WTT05KR1XRRnk/cIkdmPFmr/hLfWc/esbq7kbmeYwFKjFB
TeCidksL4zSELDpXv6BTeQ6wLOTxhjQ6ch7LjED+y/JNxpuTw7sgIXNfLiU2HVEu
XCGWax0eilw4POhTdBW/ItHglM516HSSg4puRKErevLQj9N3YlJ6NXpgAtHUj0Ru
rJuZho2fQKyrzcOWKcAz2rXDscHCC0k844jmLTvy0QGHbqFtsAEbLGlK+o8JEO6h
CoxvSbianw0xa2p1gwddMocs9u5cn9k2V599ABEBAAH+AwMCkZpQ9m3xyB2+U/Sy
Ks/iZsrYZ7HwzV4D3byomayx2ClYA/+ZDTA7P/YVQvPlEcAGCnTqbzUvkNjViYsE
AcYr+XFlPHTzAQ54Q1P+wjmfh+bZLSDfQKhsDt8ttVKT9cpI7vzz6rAJKvKB5S9v
ytYPeU5vG3dJwY4+5w+Z8c6/5UfGJLbQF9LI1n4qtrcowUiC13DCQKuiLgeJa4Gn
0Uny9OHVCDD+n5dc0x/iwe7Us2grNgqPilP0kKm8A4qy0oj5kihIR/Hsk9PBkoRx
QkqBh7sm6jv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m3Hr9X39C4iLors4lCxVgRmwPN
A+AbGFc+fvTHKH2c+YKUtHnCcwGlEQJQTjNuiq0=
=M8Lw
-----END PGP PRIVATE KEY BLOCK----
#31162
Posted: 10/28/2014 12:59:50
by Eugene Mayevski (EldoS Corp.)

Frankly speaking I don't understand your problem. The file is loaded correctly into PGPKeys sample when you pass this file as a secret keyring. Please try doing this.
Also by EldoS: Callback File System
Create virtual file systems and disks, expose and manage remote data as if they were files on the local disk.

Reply

Statistics

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