コード例 #1
0
        /// <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();
        }
コード例 #2
0
        /// <summary>
        /// Initialize any lists
        /// </summary>
        private void InitializeLists()
        {
            switch (Api)
            {
            case CryptographyApi.MSDN:
                Algorithims = BaseMsdnAsymmetric.GetAlgorthims(SelectedOperation);
                break;

            case CryptographyApi.BouncyCastle:
                Algorithims = BaseBouncyAsymmetric.GetAlgorthims(SelectedOperation);
                break;

            default:
                Debugger.Break();
                break;
            }

            ChangedAlgorithim();
        }