public async Task <string> Wrap(IKeyVaultKey key, KeyVaultAlgorithm algorithm, string valueToWrap)
        {
            var uri     = new Uri(_root, $"keys/{key.Name}/wrapkey?api-version={Version}");
            var command = new
            {
                alg   = algorithm.GetConfigurationString(),
                value = valueToWrap
            };
            var data = await Post(uri, JsonConvert.SerializeObject(command), "application/json");

            return(data.value);
        }
        public async Task <String> GetKeyValue(IKeyVaultKey key)
        {
            var uri  = new Uri(_root, $"keys/{key.Name}?api-version={Version}");
            var data = await Get <dynamic>(uri);

            //var data = await Get<AzureKeyVaultKeyValue>(uri);
            if (data == null)
            {
                return(null);
            }
            return(JsonConvert.SerializeObject(new { key = ((dynamic)data).key }));
        }
        public async Task <string> Unwrap(IKeyVaultKey key, KeyVaultAlgorithm algorithm, string valueToUnwrap)
        {
            var uri     = new Uri(_root, $"keys/{key.Name}/unwrapkey?api-version={Version}");
            var command = new
            {
                alg   = algorithm.GetConfigurationString(),
                value = valueToUnwrap
            };
            var data = await Post(uri, JsonConvert.SerializeObject(command), "application/json");

            var base64EncodedData = (string)((dynamic)data).value;

            return(base64EncodedData.PadRight(base64EncodedData.Length + (4 - base64EncodedData.Length % 4) % 4, '='));
        }
        public EncryptDecryptDialog(IKeyVaultKey key)
        {
            _key = key;
            this.InitializeComponent();

            Loaded += (sender, args) =>
            {
                var allNames  = Enum.GetNames(typeof(KeyVaultAlgorithm));
                var allValues = allNames.Select(name => (KeyVaultAlgorithm)Enum.Parse(typeof(KeyVaultAlgorithm), name));
                algorithmSelection.ItemsSource   = allValues.Where(alg => alg.CanCryptOrWrap()).ToList();
                algorithmSelection.SelectedIndex = 0;

                //this.MinHeight = MainPage.MainPageInstance.ActualHeight * 0.8 - 500;
                //this.MinWidth = MainPage.MainPageInstance.ActualWidth * 0.8;

                //contentGrid.MinHeight = this.MinHeight;
            };
        }
Exemplo n.º 5
0
 public KeyVaultKeyDecorator(IKeyVaultKey key)
 {
     _key = key;
 }
Exemplo n.º 6
0
 public KeyVaultKeyViewModel(IKeyVaultKey key) : base(key)
 {
 }
Exemplo n.º 7
0
        public async Task <string> Wrap(IKeyVaultKey key, KeyVaultAlgorithm algorithm, string valueToEncrypt)
        {
            await Task.Yield();

            return(valueToEncrypt);
        }
Exemplo n.º 8
0
        public async Task <bool> Verify(IKeyVaultKey key, KeyVaultAlgorithm algorithm, string digest, string valueToVerify)
        {
            await Task.Yield();

            return(true);
        }
Exemplo n.º 9
0
        public async Task <string> Sign(IKeyVaultKey key, KeyVaultAlgorithm algorithm, string digest)
        {
            await Task.Yield();

            return("signature");
        }
Exemplo n.º 10
0
 public async Task Delete(IKeyVaultKey key)
 {
     await Task.Yield();
 }
Exemplo n.º 11
0
        public async Task <string> GetKeyValue(IKeyVaultKey key)
        {
            await Task.Yield();

            return("key value");
        }
 private async void ShowWrapDialog(IKeyVaultKey key)
 {
     await new WrapUnwrapDialog(key).ShowAsync();
 }
 private async void ShowSignDialog(IKeyVaultKey key)
 {
     await new SignVerifyDialog(key).ShowAsync();
 }
 private async void ShowEncryptDialog(IKeyVaultKey key)
 {
     await new EncryptDecryptDialog(key).ShowAsync();
 }
        public async Task Delete(IKeyVaultKey key)
        {
            var uri = new Uri(_root, $"keys/{key.Name}?api-version={Version}");

            await Delete(uri);
        }