Пример #1
0
        private int twofishEncrypt()
        {
            ArrayUtils au = new ArrayUtils();

            byte[]     key         = { 0xa4, 0x46, 0xdc, 0x73, 0x25, 0x08, 0xee, 0xb7, 0x6c, 0x9e, 0xb4, 0x4a, 0xb8, 0xe7, 0x11, 0x03 };
            byte[]     iv          = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
            byte[]     plainText   = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
            byte[]     knownResult = { 0xba, 0x05, 0xf5, 0x6e, 0x86, 0x5f, 0xb6, 0xc9, 0xb2, 0x1d, 0xe1, 0x00, 0xb6, 0xec, 0x46, 0xe9 };
            byte[]     result      = new byte[16];
            MxoTwofish tf          = new MxoTwofish();

            tf.setIV(iv);
            tf.setKey(key);
            tf.encrypt(plainText, result);

            if (!ArrayUtils.equal(knownResult, result))
            {
                Output.Write("Failed\n");
                Output.WriteLine(StringUtils.bytesToString(knownResult));
                Output.WriteLine(StringUtils.bytesToString(result));
                return(0);
            }
            Output.Write("OK\n");
            return(1);
        }
Пример #2
0
 public void initCrypto()
 {
     crc32 = new Crc32();
     tf    = new MxoTwofish();
     tf.setIV(IV);
     tf.setKey(TF_Key);
 }
Пример #3
0
        private int twofishEncrypt()
        {
            ArrayUtils au = new ArrayUtils();
            byte[] key = { 0xa4,0x46,0xdc,0x73,0x25,0x08,0xee,0xb7,0x6c,0x9e,0xb4,0x4a,0xb8,0xe7,0x11,0x03 };
            byte[] iv = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
            byte[] plainText = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
            byte[] knownResult = {0xba,0x05,0xf5,0x6e,0x86,0x5f,0xb6,0xc9,0xb2,0x1d,0xe1,0x00,0xb6,0xec,0x46,0xe9};
            byte[] result = new byte[16];
            MxoTwofish tf = new MxoTwofish();
            tf.setIV(iv);
            tf.setKey(key);
            tf.encrypt(plainText,result);

            if (!ArrayUtils.equal(knownResult, result)){
                Output.Write("Failed\n");
                Output.WriteLine(StringUtils.bytesToString(knownResult));
                Output.WriteLine(StringUtils.bytesToString(result));
                return 0;
            }
            Output.Write("OK\n");
            return 1;
        }
Пример #4
0
        private int twofishDecrypt()
        {
            byte[] key        = { 0x6C, 0xAB, 0x8E, 0xCC, 0xE7, 0x3C, 0x22, 0x47, 0xDB, 0xEB, 0xDE, 0x1A, 0xA8, 0xE7, 0x5F, 0xB8 };
            byte[] iv         = { 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30 };
            byte[] cipherText = { 0x77, 0x7f, 0x54, 0xc6, 0xc9, 0x9e, 0x35, 0x56, 0x26, 0x4b, 0xc0, 0x17, 0x96, 0x33, 0x79, 0xe8 };

            byte[] knownResult = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
            byte[] result      = new byte[16];

            MxoTwofish tf = new MxoTwofish();

            tf.setIV(iv);
            tf.setKey(key);
            tf.decrypt(cipherText, result);

            if (!ArrayUtils.equal(knownResult, result))
            {
                Output.Write("Failed\n");
                return(0);
            }
            Output.Write("OK\n");
            return(1);
        }
Пример #5
0
 public MarginEncryption()
 {
     tf    = new MxoTwofish();
     crc32 = new Crc32();
 }
Пример #6
0
        private int twofishEncrypt()
        {
            byte[] key = { 0x6C, 0xAB, 0x8E, 0xCC, 0xE7, 0x3C, 0x22, 0x47, 0xDB, 0xEB, 0xDE, 0x1A, 0xA8, 0xE7, 0x5F, 0xB8 };
            byte[] iv = { 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30 };
            byte[] plainText = {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, 0x08 ,0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f};
            byte[] knownResult = {0x77,0x7f,0x54,0xc6,0xc9,0x9e,0x35,0x56,0x26,0x4b,0xc0,0x17,0x96,0x33,0x79,0xe8};
            byte[] result = new byte[16];
            MxoTwofish tf = new MxoTwofish();
            tf.setIV(iv);
            tf.setKey(key);
            tf.encrypt(plainText,result);

            if (!ArrayUtils.equal(knownResult, result))
            {
                Output.Write("Failed\n");
                Output.WriteLine(StringUtils.bytesToString(knownResult));
                Output.WriteLine(StringUtils.bytesToString(result));
                return 0;
            }
            Output.Write("OK\n");
            return 1;
        }
Пример #7
0
 public MarginEncryption()
 {
     tf = new MxoTwofish();
     crc32 = new Crc32();
 }