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

            // Act & Assert
            Assert.Throws <NotSupportedException>(() => paseto.Verify("v2.public.eyJleGFtcGxlIjoiSGVsbG8gUGFzZX", new byte[32]));
        }
Beispiel #2
0
        public void Version2SignatureVerificationInvalidTokenHeaderFails()
        {
            // Arrange
            var paseto = new Version2();

            // Act & Assert
            Assert.Throws <NotSupportedException>(() => paseto.Verify("v2.remote.", new byte[32]));
        }
Beispiel #3
0
        public void Version2SignatureVerificationInvalidPublicKeyFails()
        {
            // Arrange
            var paseto = new Version2();

            // Act & Assert
            Assert.Throws <ArgumentException>(() => paseto.Verify(TokenV2, new byte[16]));
        }
Beispiel #4
0
        public void Version2SignatureVerificationNullPublicKeyFails()
        {
            // Arrange
            var paseto = new Version2();

            // Act & Assert
            Assert.Throws <ArgumentNullException>(() => paseto.Verify(TokenV2, null));
        }
Beispiel #5
0
        public void Version2SignatureVerificationEmptyTokenFails()
        {
            // Arrange
            var paseto = new Version2();

            // Act & Assert
            Assert.Throws <ArgumentNullException>(() => paseto.Verify(string.Empty, null));
        }
Beispiel #6
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);
        }