private BigInteger DecodePrimaryKey(byte[] decodeKey, byte[] primaryKey)
        {
            var engine = new Gost28147Engine();
            var param  = new ParametersWithSBox(
                new KeyParameter(decodeKey),
                Gost28147Engine.GetSBox("E-A"));

            engine.Init(false, param);

            var buf = new byte[32];

            engine.ProcessBlock(primaryKey, 0, buf, 0);
            engine.ProcessBlock(primaryKey, 8, buf, 8);
            engine.ProcessBlock(primaryKey, 16, buf, 16);
            engine.ProcessBlock(primaryKey, 24, buf, 24);

            return(new BigInteger(1, buf.Reverse().ToArray()));
        }
Example #2
0
        private BigInteger DecodePrimaryKey(byte[] decodeKey, byte[] primaryKey)
        {
            Gost28147Engine engine = new Gost28147Engine();

            byte[] sbox =
                ProviderType == ProviderType.CryptoPro_2001
                    ? Gost28147Engine.GetSBox("E-A")
                    : Gost28147_TC26ParamSetZ;

            ParametersWithSBox param = new ParametersWithSBox(
                new KeyParameter(decodeKey), sbox);

            engine.Init(false, param);

            byte[] buf = new byte[primaryKey.Length];
            for (int i = 0; i < primaryKey.Length; i += 8)
            {
                engine.ProcessBlock(primaryKey, i, buf, i);
            }

            return(new BigInteger(1, buf.Reverse().ToArray()));
        }