Exemplo n.º 1
0
        public async void IUKRescueCodeEncryptDecryptTest()
        {
            for (int i = 0; i < 10; i++)
            {
                SQRLIdentity identity = new SQRLIdentity();
                byte[]       iuk      = SQRL.CreateIUK();

                string rescueCode = SQRL.CreateRescueCode();
                identity = await SQRL.GenerateIdentityBlock2(iuk, rescueCode, identity);

                var decryptResult = await SQRL.DecryptBlock2(identity, rescueCode);

                Assert.Equal(Sodium.Utilities.BinaryToHex(iuk), Sodium.Utilities.BinaryToHex(decryptResult.Iuk));
            }
        }
Exemplo n.º 2
0
        public async void LMKILKPasswordEncryptDecryptTest()
        {
            for (int i = 0; i < 50; i++)
            {
                SQRLIdentity identity = new SQRLIdentity();
                byte[]       iuk      = SQRL.CreateIUK();
                string       password = Sodium.Utilities.BinaryToHex(Sodium.SodiumCore.GetRandomBytes(32), Sodium.Utilities.HexFormat.None, Sodium.Utilities.HexCase.Lower);

                identity = await SQRL.GenerateIdentityBlock1(iuk, password, identity);

                byte[] imk           = SQRL.CreateIMK(iuk);
                byte[] ilk           = SQRL.CreateILK(iuk);
                var    decryptedData = await SQRL.DecryptBlock1(identity, password);

                Assert.Equal(Sodium.Utilities.BinaryToHex(imk), Sodium.Utilities.BinaryToHex(decryptedData.Imk));
                Assert.Equal(Sodium.Utilities.BinaryToHex(ilk), Sodium.Utilities.BinaryToHex(decryptedData.Ilk));
            }
        }