Example #1
1
 private static UInt32[] Decrypt(UInt32[] v, UInt32[] k)
 {
     Int32 n = v.Length - 1;
     if (n < 1) {
         return v;
     }
     if (k.Length < 4) {
         UInt32[] Key = new UInt32[4];
         k.CopyTo(Key, 0);
         k = Key;
     }
     UInt32 z = v[n], y = v[0], sum, e;
     Int32 p, q = 6 + 52 / (n + 1);
     unchecked {
         sum = (UInt32)(q * delta);
         while (sum != 0) {
             e = sum >> 2 & 3;
             for (p = n; p > 0; p--) {
                 z = v[p - 1];
                 y = v[p] -= (z >> 5 ^ y << 2) + (y >> 3 ^ z << 4) ^ (sum ^ y) + (k[p & 3 ^ e] ^ z);
             }
             z = v[n];
             y = v[0] -= (z >> 5 ^ y << 2) + (y >> 3 ^ z << 4) ^ (sum ^ y) + (k[p & 3 ^ e] ^ z);
             sum -= delta;
         }
     }
     return v;
 }
Example #2
1
 private static UInt32[] Encrypt(UInt32[] v, UInt32[] k)
 {
     Int32 n = v.Length - 1;
     if (n < 1)
     {
         return v;
     }
     if (k.Length < 4)
     {
         UInt32[] Key = new UInt32[4];
         k.CopyTo(Key, 0);
         k = Key;
     }
     UInt32 z = v[n], y = v[0], delta = 0x9E3779B9, sum = 0, e;
     Int32 p, q = 6 + 52 / (n + 1);
     while (q-- > 0)
     {
         sum = unchecked(sum + delta);
         e = sum >> 2 & 3;
         for (p = 0; p < n; p++)
         {
             y = v[p + 1];
             z = unchecked(v[p] += (z >> 5 ^ y << 2) + (y >> 3 ^ z << 4) ^ (sum ^ y) + (k[p & 3 ^ e] ^ z));
         }
         y = v[0];
         z = unchecked(v[n] += (z >> 5 ^ y << 2) + (y >> 3 ^ z << 4) ^ (sum ^ y) + (k[p & 3 ^ e] ^ z));
     }
     return v;
 }
Example #3
0
        private static UInt32[] Decrypt(UInt32[] v, UInt32[] k)
        {
            Int32 n = v.Length - 1;
            if (n < 1)
            {
                return v;
            }
            if (k.Length < 4)
            {
                var key = new UInt32[4];
                k.CopyTo(key, 0);
                k = key;
            }
            UInt32 y = v[0];

            Int32 q = 6 + 52 / (n + 1);
            var sum = unchecked((UInt32)(q * mDelta));
            while (sum != 0)
            {
                UInt32 e = sum >> 2 & 3;
                UInt32 z;
                Int32 p;
                for (p = n; p > 0; p--)
                {
                    z = v[p - 1];
                    y = unchecked(v[p] -= (z >> 5 ^ y << 2) + (y >> 3 ^ z << 4) ^ (sum ^ y) + (k[p & 3 ^ e] ^ z));
                }
                z = v[n];
                y = unchecked(v[0] -= (z >> 5 ^ y << 2) + (y >> 3 ^ z << 4) ^ (sum ^ y) + (k[p & 3 ^ e] ^ z));
                sum = unchecked(sum - mDelta);
            }
            return v;
        }
Example #4
0
        private static UInt32[] Encrypt(UInt32[] v, UInt32[] k)
        {
            Int32 n = v.Length - 1;
            if (n < 1)
            {
                return v;
            }
            if (k.Length < 4)
            {
                var key = new UInt32[4];
                k.CopyTo(key, 0);
                k = key;
            }
            UInt32 z = v[n];

            UInt32 sum = 0;
            Int32 q = 6 + 52 / (n + 1);
            while (q-- > 0)
            {
                sum = unchecked(sum + mDelta);
                UInt32 e = sum >> 2 & 3;
                UInt32 y;
                Int32 p;
                for (p = 0; p < n; p++)
                {
                    y = v[p + 1];
                    z = unchecked(v[p] += (z >> 5 ^ y << 2) + (y >> 3 ^ z << 4) ^ (sum ^ y) + (k[p & 3 ^ e] ^ z));
                }
                y = v[0];
                z = unchecked(v[n] += (z >> 5 ^ y << 2) + (y >> 3 ^ z << 4) ^ (sum ^ y) + (k[p & 3 ^ e] ^ z));
            }
            return v;
        }
Example #5
0
        //clark 2011.3.23
        public rfid.Constants.Result load(
            rfid.Linkage transport,
            UInt32       readerHandle
        )
        {
            UInt32[ ] tmpBuf = new UInt32[ OEMCFG_AREA_MAP_SIZE_WORDS ];
            rfid.Constants.Result Result = rfid.Constants.Result.OK;

            Array.Clear(tmpBuf, 0, tmpBuf.Length);

            //MacReadOemData only load one ome at one time. load all ome to buf.
            for (ushort index = 0; index < OEMCFG_AREA_MAP_SIZE_WORDS; index++)
            {
                Result = transport.API_MacReadOemData(index,
                                                      ref tmpBuf[index]);

                if (rfid.Constants.Result.OK != Result)
                    return Result;
            }

            tmpBuf.CopyTo(oemDataBuffer, 0);

            return Result;
        }