Exemplo n.º 1
0
        public static byte[] PkcsPadding(byte[] srcData, int destSize)
        {
            int srcSize = srcData.Length;

            if ((srcSize + 11) > destSize)
            {
                throw new OverflowException();
            }

            int randSize = destSize - srcSize - 3;

            byte[] rand = Secure.Rand((uint)randSize);

            Buf b = new Buf();

            b.WriteByte(0x00);
            b.WriteByte(0x02);
            b.Write(rand);
            b.WriteByte(0x00);
            b.Write(srcData);

            return(b.ByteData);
        }
Exemplo n.º 2
0
        static void initMyTempDir()
        {
            try
            {
                deleteUnusedTempDir();
            }
            catch
            {
            }

            int num = 0;

            while (true)
            {
                byte[] rand = Secure.Rand(2);
                string tmp2 = Str.ByteToStr(rand);

                string tmp = Path.Combine(Env.tempDir, "NET_" + tmp2);

                if (IO.IsDirExists(tmp) == false && IO.MakeDir(tmp))
                {
                    Env.myTempDir = tmp;

                    break;
                }

                if ((num++) >= 100)
                {
                    throw new SystemException();
                }
            }

            string lockFileName = Path.Combine(Env.myTempDir, "LockFile.dat");

            lockFile = IO.FileCreate(lockFileName);
        }
Exemplo n.º 3
0
 public bool VerifyData(byte[] data, byte[] sign)
 {
     byte[] hash = Secure.HashSHA1(data);
     return(VerifyHash(hash, sign));
 }
Exemplo n.º 4
0
 public byte[] SignData(byte[] data)
 {
     byte[] hash = Secure.HashSHA1(data);
     return(SignHash(hash));
 }