예제 #1
0
        public OpenPGP(Xmpp xmpp, string jid)
        {
            this.xmpp = xmpp;
            this.jid  = jid;

            this.contextPrefs = Android.App.Application.Context.GetSharedPreferences("Legion", FileCreationMode.Private);

            Log.Info("PGP initializing");
            var p = this.contextPrefs.GetString("SecretKey", "");

            if (p != "")
            {
                Log.Info("Imported secret key from private store.");
                ImportSecretKey(Streamify(p));
            }
            else
            {
                Log.Info("Generating secret key.");
                Generate();
                Log.Info("Saving secret key to private store.");
                var edit = this.contextPrefs.Edit();
                edit.PutString("SecretKey", Convert.ToBase64String(secretKey.GetEncoded()));
                edit.Commit();
                Log.Info("Publishing public key.");
                Publish();
            }
            Log.Info("PGP initialized");
            //Publish();

            /*
             * var = priavteKeyInSecureStorage
             * if var then
             *      importPrivateKey
             * else
             *      generate(jid)
             *      saveInSecureStorage
             *      publish
             * end if
             */
        }
예제 #2
0
 public string Export(PgpSecretKey secretKey)
 {
     return(Export(secretKey.GetEncoded()));
 }