Example #1
0
        public void TestGenerate()
        {
            AsymmetricKeyPair result = _generator.Generate();

            int secretKeyHeaderLength = Ed25519Asn1KeyGenerator.SecretKeyAsn1Header.Length;

            Assert.AreEqual(KeyAlgorithm.Ed25519, result.SecretKey.Algorithm);
            Assert.AreEqual(secretKeyHeaderLength + 32, result.SecretKey.Bytes.Length);
            CollectionAssert.AreEqual(Ed25519Asn1KeyGenerator.SecretKeyAsn1Header, result.SecretKey.Bytes.Take(secretKeyHeaderLength).ToArray());

            int publicKeyHeaderLength = Ed25519Asn1KeyGenerator.PublicKeyAsn1Header.Length;

            Assert.AreEqual(KeyAlgorithm.Ed25519, result.PublicKey.Algorithm);
            Assert.AreEqual(publicKeyHeaderLength + 32, result.PublicKey.Bytes.Length);
            CollectionAssert.AreEqual(Ed25519Asn1KeyGenerator.PublicKeyAsn1Header, result.PublicKey.Bytes.Take(publicKeyHeaderLength).ToArray());
        }
Example #2
0
        public void RegenerateKeyPair()
        {
            AsymmetricKeyPair asymmetricKeyPair = _ed25519Asn1KeyGenerator.Generate();

            _appSettings.AuthenticationPublicKey = asymmetricKeyPair.PublicKey.Base64;
            _appSettings.AuthenticationSecretKey = asymmetricKeyPair.SecretKey.Base64;
            _logger.Info("New auth key pair successfully generated and saved.");
        }