Exemplo n.º 1
0
        public async Task Create_Ed25519_Key()
        {
            const string name = "test-ed25519";
            var          key  = await _keyStoreService.CreateAsync(name, "ed25519", 0);

            try
            {
                Assert.NotNull(key);
                Assert.NotNull(key.Id);
                Assert.AreEqual(name, key.Name);

                var keys = await _keyStoreService.ListAsync();

                var clone = keys.Single(k => k.Name == name);
                Assert.AreEqual(key.Name, clone.Name);
                Assert.AreEqual(key.Id, clone.Id);

                var priv = await _keyStoreService.GetPrivateKeyAsync(name);

                Assert.NotNull(priv);
                var pub = await _keyStoreService.GetPublicKeyAsync(name);

                Assert.NotNull(pub);

                // Verify key can be used as peer ID.
                var peer = new Peer
                {
                    Id        = key.Id,
                    PublicKey = pub
                };
                Assert.True(peer.IsValid());
            }
            finally
            {
                await _keyStoreService.RemoveAsync(name);
            }
        }
Exemplo n.º 2
0
 public async Task <AsymmetricKeyParameter> GetPrivateKeyAsync(string privateKeyName)
 {
     return(await _keyStoreService.GetPrivateKeyAsync(privateKeyName).ConfigureAwait(false));
 }