EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Help me with PGP Key in MemoryStream function

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.
#12487
Posted: 02/18/2010 16:13:25
by Levan Sopromadze (Basic support level)
Joined: 02/16/2010
Posts: 5

Hi all.
I want to read PGP Public and Secret Keys from stream, not from file.
For example I have PGP public key:
Code
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Gnu Privacy Tools
Comment: Download at http://www.gnupt.de

mQENBEt68UoBCADZGx4kFEAMSZ1wVrs1ATAJ+bSYAtnlCXi/hvUuUA9P4Idf9pIz
U00XKhRziyR4xRxcME/b/K8I/01jC64az11rauO365nQva3SJ2whtrDVt/qOaN0p
...
...
50r5sOVu/ImNIZFB5hoTOtabe52VGKul5mfx89qTrVWPQu+Xnp8=
=miQa
-----END PGP PUBLIC KEY BLOCK-----


I'm trying to put this into string and than put it into stream like this:
Code
String pubKey = "mQENBEt68.......Xnp8=";
String secKey ="lQO+BEt6+6.......b3hdlRHg==";

Stream pubKeyStream = new MemoryStream(Encoding.ASCII.GetBytes(pubKey));
Stream secKeyStream = new MemoryStream(Encoding.ASCII.GetBytes(secKey));

TElPGPKeyring pgpKeyring = new TElPGPKeyring();
pgpKeyring.Load(pubKeyStream, secKeyStream, true);


but I got an error. I tried key with "=miQa" at the end and without but with the same result. I'm always getting error "Invalid PGP packet".

Maybe you can help me to how can I store my keys in source.
Thanks...
#12491
Posted: 02/19/2010 00:29:18
by Ken Ivanov (EldoS Corp.)

Thank you for contacting us.

You should form the string from the whole key data "as is" (including PEM headers):
Code
String pubKey = "-----BEGIN PGP PUBLIC KEY BLOCK-----" & vbCr & vbLf &
    "Version: GnuPG v1.4.10 (MingW32)" & vbCr & vbLf &
    "Comment: Gnu Privacy Tools" & vbCr & vbLf &
    "Comment: Download at [url]http://www.gnupt.de[/url]" & vbCr & vbLf &
    vbCr & vbLf &
    "mQENBEt68UoBCADZGx4kFEAMSZ1wVrs1ATAJ+bSYAtnlCXi/hvUuUA9P4Idf9pIz" & vbCr & vbLf &
    ....
    "-----END PGP PUBLIC KEY BLOCK-----"

Reply

Statistics

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