public static bool IsValidKeyParams(this AsymmetricCipherKeyPair keyPair, int keySize) { var devideByEight = Math.Ceiling(keySize / 8.0); var devideBySixteen = Math.Ceiling(keySize / 16.0); var keyParams = keyPair.GetPrivateRsaParameters(); return(devideByEight == keyParams.D.Length && devideBySixteen == keyParams.DP.Length && devideBySixteen == keyParams.DQ.Length && 3 == keyParams.Exponent.Length && devideBySixteen == keyParams.InverseQ.Length && devideByEight == keyParams.Modulus.Length && devideBySixteen == keyParams.P.Length && devideBySixteen == keyParams.Q.Length); }
public static byte[] GetPrivateKeyBytes(this AsymmetricCipherKeyPair keyPair) { return(keyPair.GetPrivateRsaParameters().GetKeyBytes()); }