/// <summary> /// Default constructor /// </summary> public KeyPairSetupDesignModel() { SelectedOperation = AsymmetricOperation.Encryption; Algorithims = BaseMsdnAsymmetric.GetAlgorthims(SelectedOperation); //Algorithims = IAsymmetricCipher.GetBouncyAlgorthims(SelectedOperation); SelectedAlgorithimIndex = 0; BaseMsdnAsymmetric.GetCipher(Algorithims[SelectedAlgorithimIndex]); PrivateKey = ByteConvert.HexStringToBytes("FFFFFFFFF111000"); PublicKey = ByteConvert.HexStringToBytes("00000000FFFFFFF"); }
/// <summary> /// The command method when a different algrithim is selected /// </summary> public void ChangedAlgorithim() { //Find out which api is beeing used switch (Api) { //MSDN API case CryptographyApi.MSDN: //Get the selected cipher algorithim SelectedCipher = BaseMsdnAsymmetric.GetCipher(Algorithims[SelectedAlgorithimIndex]); break; //Bouncy castle api case CryptographyApi.BouncyCastle: //Get the selected cipher algorithim SelectedCipher = BaseBouncyAsymmetric.GetCipher(Algorithims[SelectedAlgorithimIndex]); break; } //True if the cipher uses ec curves if (SelectedCipher is IECAlgorithims ecCipher) { UsesKeySize = false; UsesEcCurves = ecCipher.UsesCurves; if (UsesEcCurves) { Providers = ecCipher.GetEcProviders(); var provider = (EcCurveProvider)Enum.Parse(typeof(EcCurveProvider), Providers[ProviderIndex]); EcCurves = ecCipher.GetEcCurves(provider); EcCurveIndex = 0; } } //true if the cipher algorithims doesnt use ec curves else if (SelectedCipher is INonECAlgorithims nonEcCipher) { UsesEcCurves = false; UsesKeySize = nonEcCipher.UsesKeySize; KeySizes = nonEcCipher.GetKeySizes(); KeySizeIndex = 0; } PrivateKeyFilePath = string.Empty; PublicKeyFilePath = string.Empty; OtherPartyPublicKeyFilePath = string.Empty; OnKeyPairChanged(); }