Esempio n. 1
0
        /// <summary>
        /// Search a secret key ring collection for a secret key corresponding to keyID if it exists.
        /// </summary>
        /// <param name="pgpSec">A secret key ring collection</param>
        /// <param name="keyID">The keyID we want.</param>
        /// <param name="password">The passphrase to decrypt secret key with.</param>
        /// <returns>The private key.</returns>
        private Key.Bcpg.OpenPgp.PgpPrivateKey FindSecretKey(Key.Bcpg.OpenPgp.PgpSecretKeyRingBundle pgpSec, long keyID, char[] password)
        {
            // Get the secret key from the unique key id.
            Key.Bcpg.OpenPgp.PgpSecretKey pgpSecKey = pgpSec.GetSecretKey(keyID);

            // If a secret key does not exist.
            if (pgpSecKey == null)
            {
                return(null);
            }

            // Extract the private key.
            return(pgpSecKey.ExtractPrivateKey(password));
        }