Hi! Unfortunately wiki is down and I did not found anything related in internet. I have following issue. I have GnuPG signed public key that contains signed public key:
root@ubuntu:~# gpg --import < pkey.asc gpg: /root/.gnupg/trustdb.gpg: trustdb created gpg: key 771E0A0E: public key "User (User) <[email protected]>" imported gpg: Total number processed: 1 gpg: imported: 1 root@ubuntu:~# root@ubuntu:~# gpg --encrypt -r User gpg: 91A942AE: There is no assurance this key belongs to the named user pub 4096g/91A942AE 2010-10-29 User (User) <[email protected]> Primary key fingerprint: BB08 D13A 1AEB 2F23 1767 D912 CCD0 17AF 771E 0A0E Subkey fingerprint: E87A 27D3 A3D8 6489 70D8 2D19 2C65 0745 91A9 42AE .... And so on. So key is correct and usable. To extract PgpPublicKey object from key I'm using following method: public static PgpPublicKey PublicKeyFromString(string keyString) { using (Stream mStream = new MemoryStream(StringToBytes(keyString))) { using (Stream inputStream = PgpUtilities.GetDecoderStream(mStream)) { PgpPublicKeyRingBundle pgpPub = new PgpPublicKeyRingBundle(inputStream); foreach (PgpPublicKeyRing kRing in pgpPub.GetKeyRings()) { foreach (PgpPublicKey pKey in kRing.GetPublicKeys()) { if (pKey.IsEncryptionKey) { return pKey; } } } } } // not found throw new ArgumentException(SJ.Resources.ErrorPGPNoKeysInKeyRing); } The problem I see - kRing.GetPublicKeys() returns two elements - one of them public key itself and second one is key sign. But public key returned with attribute IsEncryptionKey set to false, and sign returned with IsEncryptionKey set to true. I can't use this PgpPublicKey object for encryption, and of course can't use sign for this puprose. kRing.GetPublicKey() also returns public key with IsEncryptionKey set to false. When I got public key using this method it looks usable (untill I'm trying to encrypt anything) and I can even save them in armored format. But after this GnuPG import says: root@ubuntu:~# gpg --import < pkey-extracted.asc gpg: /root/.gnupg/trustdb.gpg: trustdb created gpg: key 771E0A0E: public key "User (User) <[email protected]>" imported gpg: Total number processed: 1 gpg: imported: 1 root@ubuntu:~# gpg --encrypt -r User gpg: Darkterror: skipped: unusable public key gpg: [stdin]: encryption failed: unusable public key root@ubuntu:~# Is is bug or I missunderstood something? What is correct way to extract signed public key form keyring? Thanks in advance! -- когда я опустился на самое дно, снизу мне постучали..
