{"action":"created","issue":{"url":"https://api.github.com/repos/jstedfast/MimeKit/issues/220","labels_url":"https://api.github.com/repos/jstedfast/MimeKit/issues/220/labels{/name}","comments_url":"https://api.github.com/repos/jstedfast/MimeKit/issues/220/comments","events_url":"https://api.github.com/repos/jstedfast/MimeKit/issues/220/events","html_url":"https://github.com/jstedfast/MimeKit/issues/220","id":127774696,"number":220,"title":"Howto import keys into GnuPGContext using ImportSecretKeys?","user":{"login":"polterguy","id":8466933,"avatar_url":"https://avatars.githubusercontent.com/u/8466933?v=3","gravatar_id":"","url":"https://api.github.com/users/polterguy","html_url":"https://github.com/polterguy","followers_url":"https://api.github.com/users/polterguy/followers","following_url":"https://api.github.com/users/polterguy/following{/other_user}","gists_url":"https://api.github.com/users/polterguy/gists{/gist_id}","starred_url":"https://api.github.com/users/polterguy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/polterguy/subscriptions","organizations_url":"https://api.github.com/users/polterguy/orgs","repos_url":"https://api.github.com/users/polterguy/repos","events_url":"https://api.github.com/users/polterguy/events{/privacy}","received_events_url":"https://api.github.com/users/polterguy/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/jstedfast/MimeKit/labels/question","name":"question","color":"cc317c"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":20,"created_at":"2016-01-20T20:16:48Z","updated_at":"2016-01-21T18:36:05Z","closed_at":"2016-01-20T22:41:04Z","body":"Howdy, I'm fiddling around with trying to create a key pair using BouncyCastle, and figured I'd use the ImportSecretKeys method on OpenPGPContext to import my keys, but it doesn't work. It doesn't throw an error or anything, but when I check out my keys in GPG Keychain (MAC OS X), the keys don't show up ...?\r\n\r\nHere is my code ...\r\n```csharp\r\n// Creating our keypair\r\nIAsymmetricCipherKeyPairGenerator kpg = new RsaKeyPairGenerator ();\r\nkpg.Init (new RsaKeyGenerationParameters (BigInteger.ValueOf(0x13), new SecureRandom (), 1024, 8));\r\nAsymmetricCipherKeyPair kp = kpg.GenerateKeyPair();\r\n\r\n// Importing keypair to GnuPG\r\nusing (var ctx = new GnuPrivacyContext ()) {\r\n\r\n    // Serializing key(s) to MemoryStream\r\n    using (var memStreamPrivate = new MemoryStream ()) {\r\n        PgpSecretKey secretKey = new PgpSecretKey (\r\n            PgpSignature.DefaultCertification,\r\n            PublicKeyAlgorithmTag.RsaGeneral,\r\n            kp.Public,\r\n            kp.Private,\r\n            DateTime.Now,\r\n            \"foo@bar.com\",\r\n            SymmetricKeyAlgorithmTag.Cast5,\r\n            \"password\".ToCharArray (),\r\n            null,\r\n            null,\r\n            new SecureRandom());\r\n        secretKey.Encode (memStreamPrivate);\r\n        ctx.ImportSecretKeys (memStreamPrivate);\r\n    }\r\n}\r\n\r\n```\r\n\r\nIs there something I have misunderstood ...? (which I assume btw)\r\n\r\nBasically, what I am trying to achieve, is to create a private/public OpenPGP keypair, and import it into my Keychain ..."},"comment":{"url":"https://api.github.com/repos/jstedfast/MimeKit/issues/comments/173667836","html_url":"https://github.com/jstedfast/MimeKit/issues/220#issuecomment-173667836","issue_url":"https://api.github.com/repos/jstedfast/MimeKit/issues/220","id":173667836,"user":{"login":"polterguy","id":8466933,"avatar_url":"https://avatars.githubusercontent.com/u/8466933?v=3","gravatar_id":"","url":"https://api.github.com/users/polterguy","html_url":"https://github.com/polterguy","followers_url":"https://api.github.com/users/polterguy/followers","following_url":"https://api.github.com/users/polterguy/following{/other_user}","gists_url":"https://api.github.com/users/polterguy/gists{/gist_id}","starred_url":"https://api.github.com/users/polterguy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/polterguy/subscriptions","organizations_url":"https://api.github.com/users/polterguy/orgs","repos_url":"https://api.github.com/users/polterguy/repos","events_url":"https://api.github.com/users/polterguy/events{/privacy}","received_events_url":"https://api.github.com/users/polterguy/received_events","type":"User","site_admin":false},"created_at":"2016-01-21T18:36:05Z","updated_at":"2016-01-21T18:36:05Z","body":"I know, I started slowly realising what was wrong myself ...!! :D\r\nObviously PGPTools won't show a key when it doesn't have a public key ...\r\nSo then comes the question of how to import the public parts ...?\r\nI am assuming \"Import\" on OpenPGPContext, but importing WHAT ...?\r\n\r\nBTW, may I suggest a little \"API change\". Instead of supplying the stream, how about supplying the \"PgpSecretKeyRingBundle\" instead, and then have a method that extracts both public and private ...? :)\r\n\r\nMaybe mark the current one as \"obsolete\" ...?"}}