Example #1
0
        public void Version2SignatureNullSecretFails()
        {
            // Arrange
            var paseto = new Version2();

            // Act & Assert
            Assert.Throws <ArgumentNullException>(() => paseto.Sign(null, HelloPaseto));
        }
Example #2
0
        public void Version2SignatureEmptySecretFails()
        {
            // Arrange
            var paseto = new Version2();

            // Act & Assert
            Assert.Throws <ArgumentException>(() => paseto.Sign(new byte[0], HelloPaseto));
        }
Example #3
0
        public void Version2SignatureEmptyPayloadFails()
        {
            // Arrange
            var paseto = new Version2();

            Ed25519.KeyPairFromSeed(out var pk, out var sk, new byte[32]);

            // Act & Assert
            Assert.Throws <ArgumentNullException>(() => paseto.Sign(sk, string.Empty));
        }
Example #4
0
        public void Version2SignatureTest()
        {
            // Arrange
            var paseto = new Version2();
            var seed   = new byte[32];

            Ed25519.KeyPairFromSeed(out var pk, out var sk, seed);

            // Act
            var signature = paseto.Sign(sk, HelloPaseto);

            // Assert
            Assert.IsNotNull(signature);
        }
Example #5
0
        public void Version2SignatureVerificationTest()
        {
            // Arrange
            var paseto = new Version2();
            var seed   = new byte[32];

            RandomNumberGenerator.Create().GetBytes(seed);
            Ed25519.KeyPairFromSeed(out var pk, out var sk, seed);

            //var pub = Convert.ToBase64String(pk);

            // Act
            var token    = paseto.Sign(sk, HelloPaseto);
            var verified = paseto.Verify(token, pk).Valid;

            // Assert
            Assert.IsTrue(verified);
        }