Ejemplo n.º 1
0
        /// <summary>
        /// Initializes properties
        /// </summary>
        /// <param name="api">The type of crypto api selected</param>
        private void InitializeProperties(CryptographyApi api)
        {
            //according to the selected cipher api create a cipher object
            switch (api)
            {
            case CryptographyApi.MSDN:
                SelectedCipherApi = new MsdnSymmetricCipher();
                break;

            case CryptographyApi.BouncyCastle:
                SelectedCipherApi = new BouncySymmetricCipher();
                break;

            default:
                Debugger.Break();
                break;
            }

            //Gets all the available algorithims from cipher api
            Algorithims = SelectedCipherApi.GetAlgorthims();

            //Gets all the available key sizes for the currently selected algorithim
            KeySizes = SelectedCipherApi.GetKeySizes(SelectedAlgorithim);

            //As default select the first item in the list
            SelectedKeySize = KeySizes[0];

            //Gets the iv size of the currently selected algorithim
            IvSize = SelectedCipherApi.GetIvSize(SelectedAlgorithim);

            ///Subscribe to the DataChanged event from the <see cref="DataInputViewModel"/>
            DataInput.DataChanged += DataChanged;
        }
        /// <summary>
        /// Default constructor
        /// </summary>
        public SymmetricDesignModel()
        {
            SelectedCipherApi = new BouncySymmetricCipher();
            //SelectedCipherApi = new MsdnSymmetricCipher();
            Algorithims     = SelectedCipherApi.GetAlgorthims();
            KeySizes        = SelectedCipherApi.GetKeySizes(SelectedAlgorithim);
            SelectedKeySize = KeySizes[0];
            IvSize          = SelectedCipherApi.GetIvSize(SelectedAlgorithim);

            DataInput.Data = "Some data";
            DataInput.DataFormatOptions  = Enum.GetValues(typeof(Format)).Cast <Format>().Select(t => t.ToString()).ToList();
            DataInput.DataFormatSelected = Format.File;
            SecretKey = "FFFFFFFFFFFF";
            IV        = "FFFFFFFFFFFF";
            IvSize    = 6 * 8;
            KeySizes  = new ObservableCollection <int> {
                6 * 8, 55, 23
            };
            SelectedKeySize = 6 * 8;
            IvSize          = 6 * 8;
        }