EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Remove KeyPassphrase from Secret Key

Also by EldoS: RawDisk
Access locked and protected files in Windows, read and write disks and partitions and more.
#13730
Posted: 06/22/2010 18:57:52
by Thomas Lunsford (Basic support level)
Joined: 06/22/2010
Posts: 2

I have a keyring that has a private key on it that I would like to remove its KeyPassphrase from. I know the KeyPassphrase but would like to store the file differently (and securely). Having a passphrase would no longer be required, so I would like to keep the same secret key but have it with no passphrase.

Can this be done?

Thanks,
Thomas
#13731
Posted: 06/22/2010 19:29:23
by Thomas Lunsford (Basic support level)
Joined: 06/22/2010
Posts: 2

Ok, I think I have it figured out, though it's not fully tested yet...


public static void StoreSecretKeyWithNoPassphrase()
{
using (TElPGPKeyring keyringSecret = new TElPGPKeyring())
{
ArrayList listOfKeys = new ArrayList();

// Get the secret key...

TElPGPSecretKey pgpSecretKey = null;

keyringSecret.Load(null, @"C:\Temp\secring.pgp", true);

keyringSecret.ListKeys(false, "userid=Widgets Inc", ref listOfKeys);

if (listOfKeys.Count == 1)
{
pgpSecretKey = (TElPGPSecretKey)listOfKeys[0];

pgpSecretKey.Passphrase = "Password234.";

if (pgpSecretKey.PassphraseValid() == true)
{
pgpSecretKey.ChangePassphrase(null, SBPGPConstants.TSBPGPProtectionType.ptNone);

pgpSecretKey.SaveToFile(@"C:\Temp\newSecring.pgp", true);
}
else
{
//TODO
}

}
else
{
//TODO
}
}
}

Reply

Statistics

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