Example #1
0
        private byte[] DoEncrypt(DoCalculateionDelegate method, byte[] src, Pkcs1PadType type)
        {
            try
            {
                int bl = this.GetBlockSize();

                byte[]     paddedBytes = this.pkcs1pad(src, bl, type);
                BigInteger m           = new BigInteger(paddedBytes);
                if (m == 0)
                {
                    return(null);
                }

                BigInteger c = method(m);
                if (c == 0)
                {
                    return(null);
                }

                return(c.getBytes());
            }
            catch
            {
                return(null);
            }
        }
Example #2
0
File: RsaKey.cs Project: sgf/Yupi
        private byte[] DoDecrypt(DoCalculateionDelegate method, byte[] src, Pkcs1PadType type)
        {
            try
            {
                BigInteger c = new BigInteger(src);

                BigInteger m = method(c);

                if (m == 0)
                {
                    return(null);
                }

                int    bl   = GetBlockSize();
                byte[] data = m.ToByteArray();

                Array.Reverse(data);

                byte[] bytes = Pkcs1Unpad(data, bl, type);

                return(bytes);
            }
            catch
            {
                return(null);
            }
        }
Example #3
0
        private byte[] DoEncrypt(DoCalculateionDelegate Method, byte[] Src, Pkcs1PadType type)
        {
            try
            {
                int        Bl          = GetBlockSize();
                byte[]     PaddedBytes = pkcs1pad(Src, Bl, type);
                BigInteger M           = new BigInteger(PaddedBytes);

                if (M == 0)
                {
                    return(null);
                }

                BigInteger C = Method(M);

                if (C == 0)
                {
                    return(null);
                }

                return(C.getBytes());
            }
            catch
            {
                return(null);
            }
        }
Example #4
0
File: RsaKey.cs Project: sgf/Yupi
        private byte[] DoEncrypt(DoCalculateionDelegate method, byte[] src, Pkcs1PadType type)
        {
            try
            {
                int bl = GetBlockSize();

                byte[] paddedBytes = Pkcs1Pad(src, bl, type);

                Array.Reverse(paddedBytes);

                BigInteger m = new BigInteger(paddedBytes);

                if (m == 0)
                {
                    return(null);
                }

                BigInteger c    = method(m);
                byte[]     data = c.ToByteArray();

                if (data[data.Length - 1] == 0)
                {
                    Array.Resize(ref data, data.Length - 1);
                }

                Array.Reverse(data);

                return(c == 0 ? null : data);
            }
            catch
            {
                return(null);
            }
        }
Example #5
0
        private byte[] DoDecrypt(DoCalculateionDelegate method, byte[] src, Pkcs1PadType type)
        {
            try
            {
                var c = new BigInteger(src);
                var m = method(c);
                if (m == 0)
                {
                    return(null);
                }

                var bl    = GetBlockSize();
                var bytes = pkcs1unpad(m.getBytes(), bl);
                return(bytes);
            }
            catch
            {
                return(null);
            }
        }
Example #6
0
        private byte[] DoDecrypt(DoCalculateionDelegate method, byte[] src, Pkcs1PadType type)
        {
            try
            {
                BigInteger c = new BigInteger(src);
                BigInteger m = method(c);
                if (m == 0)
                {
                    return(null);
                }

                int bl = this.GetBlockSize();

                byte[] bytes = this.pkcs1unpad(m.getBytes(), bl, type);

                return(bytes);
            }
            catch
            {
                return(null);
            }
        }
Example #7
0
        private byte[] DoDecrypt(DoCalculateionDelegate Method, byte[] Src, Pkcs1PadType Type)
        {
            try
            {
                BigInteger C = new BigInteger(Src);
                BigInteger M = Method(C);

                if (M == 0)
                {
                    return(null);
                }

                int    Bl    = GetBlockSize();
                byte[] Bytes = pkcs1unpad(M.getBytes(), Bl, Type);

                return(Bytes);
            }
            catch
            {
                return(null);
            }
        }
Example #8
0
        private byte[] DoDecrypt(DoCalculateionDelegate method, byte[] src, Pkcs1PadType type)
        {
            try
            {
                BigInteger c = new BigInteger(src);

                BigInteger m = method(c);

                if (m == 0)
                    return null;

                int bl = GetBlockSize();
                byte[] data = m.ToByteArray();

                Array.Reverse(data);

                byte[] bytes = Pkcs1Unpad(data, bl, type);

                return bytes;
            }
            catch
            {
                return null;
            }
        }
Example #9
0
        private byte[] DoEncrypt(DoCalculateionDelegate method, byte[] src, Pkcs1PadType type)
        {
            try
            {
                int bl = GetBlockSize();

                byte[] paddedBytes = Pkcs1Pad(src, bl, type);

                Array.Reverse(paddedBytes);

                BigInteger m = new BigInteger(paddedBytes);

                if (m == 0)
                    return null;

                BigInteger c = method(m);
                byte[] data = c.ToByteArray();

                if (data[data.Length - 1] == 0)
                    Array.Resize(ref data, data.Length - 1);

                Array.Reverse(data);

                return c == 0 ? null : data;
            }
            catch
            {
                return null;
            }
        }
Example #10
0
        private byte[] DoEncrypt(DoCalculateionDelegate method, byte[] src, Pkcs1PadType type)
        {
            try
            {
                int bl = this.GetBlockSize();

                byte[] paddedBytes = this.pkcs1pad(src, bl, type);
                BigInteger m = new BigInteger(paddedBytes);
                if (m == 0)
                {
                    return null;
                }

                BigInteger c = method(m);
                if (c == 0)
                {
                    return null;
                }

                return c.getBytes();
            }
            catch
            {
                return null;
            }
        }
Example #11
0
        private byte[] DoDecrypt(DoCalculateionDelegate method, byte[] src, Pkcs1PadType type)
        {
            try
            {
                BigInteger c = new BigInteger(src);
                BigInteger m = method(c);
                if (m == 0)
                {
                    return null;
                }

                int bl = this.GetBlockSize();

                byte[] bytes = this.pkcs1unpad(m.getBytes(), bl, type);

                return bytes;
            }
            catch
            {
                return null;
            }
        }