public void ParsePrivateKeyPkcs8_parses_openssl_generated_key_pem_file() { var pem = GetFixture("openssl-private-key", "pem"); var rsa = Pem.ParsePrivateKeyPkcs8(pem); VerifyRsaKey(rsa); }
public static RSAParameters ParseEncryptedPrivateKey(string encryptedPrivateKey, byte[] encryptionKey) { var decrypted = Util.DecryptAes256(encryptedPrivateKey.DecodeHex(), encryptionKey, CipherMode.CBC, encryptionKey.Take(16).ToArray()); const string header = "LastPassPrivateKey<"; const string footer = ">LastPassPrivateKey"; if (!decrypted.StartsWith(header) || !decrypted.EndsWith(footer)) { throw new InternalErrorException("Failed to decrypt private key"); } var pkcs8 = decrypted.Substring(header.Length, decrypted.Length - header.Length - footer.Length).DecodeHex(); return(Pem.ParsePrivateKeyPkcs8(pkcs8)); }
public static byte[] DecryptRsaSha256(byte[] ciphertext, byte[] privateKey) { return(Crypto.DecryptRsaSha256(ciphertext, Pem.ParsePrivateKeyPkcs8(privateKey))); }
public void ParsePrivateKeyPkcs8_parses_openssl_generated_key() { var rsa = Pem.ParsePrivateKeyPkcs8(PrivateKeyPkcs8); VerifyRsaKey(rsa); }