Esempio n. 1
0
    public bool HfunctionTests()
    {
        TwoFish tf   = new TwoFish();
        bool    done = true;

        BitArray[] wynik = tf.function_H(TwoFish.ConvertHexToBitArray("0"), TwoFish.ConvertHexToBitArray("00010203"), TwoFish.ConvertHexToBitArray("08090A0B"));
        if (tf.ConvertToHex(wynik[0]) != "af" | tf.ConvertToHex(wynik[1]) != "42" | tf.ConvertToHex(wynik[2]) != "22" | tf.ConvertToHex(wynik[3]) != "12")
        {
            done = false;
        }


        return(done);
    }
Esempio n. 2
0
    public bool SKeyTest()
    {
        bool     done  = true;
        TwoFish  tf    = new TwoFish();
        BitArray bytes = TwoFish.ConvertHexToBitArray("000102030405060708090A0B0C0D0E0F");

        BitArray[] wynik = tf.SKeyGenerator(bytes);
        //Debug.Log(tf.ConvertToHex(wynik[0]));
        //Debug.Log(tf.ConvertToHex(wynik[1]));
        if (tf.ConvertToHex(wynik[0]) != "2f062ad7" | tf.ConvertToHex(wynik[1]) != "f204791a")
        {
            done = false;
        }
        return(done);
    }
Esempio n. 3
0
    //Kilka prowizorycznych testów automatycznych
    public bool Q0_tests()
    {
        TwoFish tf   = new TwoFish();
        bool    done = true;

        if (tf.ConvertToHex(tf.q0(TwoFish.ConvertHexToBitArray("00"))) != "a9")
        {
            done = false;
        }
        if (tf.ConvertToHex(tf.q0(TwoFish.ConvertHexToBitArray("a1"))) != "f1")
        {
            done = false;
        }
        if (tf.ConvertToHex(tf.q0(TwoFish.ConvertHexToBitArray("1c"))) != "fa")
        {
            done = false;
        }
        if (tf.ConvertToHex(tf.q0(TwoFish.ConvertHexToBitArray("fb"))) != "42")
        {
            done = false;
        }
        if (tf.ConvertToHex(tf.q0(TwoFish.ConvertHexToBitArray("05"))) != "12")
        {
            done = false;
        }
        if (tf.ConvertToHex(tf.q0(TwoFish.ConvertHexToBitArray("01"))) != "a4")
        {
            done = false;
        }

        return(done);
    }
Esempio n. 4
0
    public bool InputWhiteningTest()
    {
        bool     done = true;
        TwoFish  tf   = new TwoFish();
        BitArray wt   = tf.InputWhitening(TwoFish.ConvertHexToBitArray("57656c636f6d52054776f46669736820"), TwoFish.ConvertHexToBitArray("54776f46697368206973206e69636520"));

        //Debug.Log(tf.ConvertToHex(wt));
        if (tf.ConvertToHex(wt) != "03120325061e3a252e05d40800100d00")
        {
            done = false;
        }
        return(done);
    }
Esempio n. 5
0
    public bool MdsTest()
    {
        TwoFish tf   = new TwoFish();
        bool    done = true;

        BitArray[] wynik = tf.function_H(TwoFish.ConvertHexToBitArray("0"), TwoFish.ConvertHexToBitArray("00010203"), TwoFish.ConvertHexToBitArray("08090A0B"));
        if (tf.ConvertToHex(tf.MDS(wynik[0], wynik[1], wynik[2], wynik[3])) != "5430e6e6")
        {
            done = false;
        }

        return(done);
    }
Esempio n. 6
0
    public bool Q1_tests()
    {
        TwoFish tf   = new TwoFish();
        bool    done = true;

        if (tf.ConvertToHex(tf.q1(TwoFish.ConvertHexToBitArray("00"))) != "15")
        {
            done = false;
        }
        if (tf.ConvertToHex(tf.q1(TwoFish.ConvertHexToBitArray("00"))) != "15")
        {
            done = false;
        }
        if (tf.ConvertToHex(tf.q1(TwoFish.ConvertHexToBitArray("a3"))) != "e2")
        {
            done = false;
        }
        if (tf.ConvertToHex(tf.q1(TwoFish.ConvertHexToBitArray("1e"))) != "06")
        {
            done = false;
        }
        if (tf.ConvertToHex(tf.q1(TwoFish.ConvertHexToBitArray("f1"))) != "af")
        {
            done = false;
        }
        if (tf.ConvertToHex(tf.q1(TwoFish.ConvertHexToBitArray("e0"))) != "22")
        {
            done = false;
        }
        if (tf.ConvertToHex(tf.q1(TwoFish.ConvertHexToBitArray("01"))) != "ea")
        {
            done = false;
        }

        return(done);
    }