예제 #1
0
 public static Blake2BTreeConfig CreateInterleaved(int parallelism)
 {
     var result = new Blake2BTreeConfig();
     result.FanOut = parallelism;
     result.MaxHeight = 2;
     result.IntermediateHashSize = 64;
     return result;
 }
예제 #2
0
        public static Blake2BTreeConfig CreateInterleaved(int parallelism)
        {
            Blake2BTreeConfig blake2BTreeConfig = new Blake2BTreeConfig();

            blake2BTreeConfig.FanOut               = parallelism;
            blake2BTreeConfig.MaxHeight            = 2;
            blake2BTreeConfig.IntermediateHashSize = 64;
            return(blake2BTreeConfig);
        }
예제 #3
0
        public static Blake2BTreeConfig CreateInterleaved(int parallelism)
        {
            var result = new Blake2BTreeConfig();

            result.FanOut               = parallelism;
            result.MaxHeight            = 2;
            result.IntermediateHashSize = 64;
            return(result);
        }
예제 #4
0
 public Blake2BTreeConfig Clone()
 {
     var result = new Blake2BTreeConfig();
     result.IntermediateHashSize = IntermediateHashSize;
     result.MaxHeight = MaxHeight;
     result.LeafSize = LeafSize;
     result.FanOut = FanOut;
     return result;
 }
예제 #5
0
        public Blake2BTreeConfig Clone()
        {
            Blake2BTreeConfig blake2BTreeConfig = new Blake2BTreeConfig();

            blake2BTreeConfig.IntermediateHashSize = IntermediateHashSize;
            blake2BTreeConfig.MaxHeight            = MaxHeight;
            blake2BTreeConfig.LeafSize             = LeafSize;
            blake2BTreeConfig.FanOut = FanOut;
            return(blake2BTreeConfig);
        }
예제 #6
0
        public Blake2BTreeConfig Clone()
        {
            var result = new Blake2BTreeConfig();

            result.IntermediateHashSize = IntermediateHashSize;
            result.MaxHeight            = MaxHeight;
            result.LeafSize             = LeafSize;
            result.FanOut = FanOut;
            return(result);
        }
예제 #7
0
        public static ulong[] ConfigB(Blake2BConfig config, Blake2BTreeConfig treeConfig)
        {
            bool isSequential = treeConfig == null;
            if (isSequential)
                treeConfig = SequentialTreeConfig;
            var rawConfig = new ulong[8];
            var result = new ulong[8];

            //digest length
            if (config.OutputSizeInBytes <= 0 | config.OutputSizeInBytes > 64)
                throw new ArgumentOutOfRangeException("config.OutputSize");
            rawConfig[0] |= (ulong)(uint)config.OutputSizeInBytes;

            //Key length
            if (config.Key != null)
            {
                if (config.Key.Length > 64)
                    throw new ArgumentException("config.Key", "Key too long");
                rawConfig[0] |= (ulong)((uint)config.Key.Length << 8);
            }
            // FanOut
            rawConfig[0] |= (uint)treeConfig.FanOut << 16;
            // Depth
            rawConfig[0] |= (uint)treeConfig.MaxHeight << 24;
            // Leaf length
            rawConfig[0] |= ((ulong)(uint)treeConfig.LeafSize) << 32;
            // Inner length
            if (!isSequential && (treeConfig.IntermediateHashSize <= 0 || treeConfig.IntermediateHashSize > 64))
                throw new ArgumentOutOfRangeException("treeConfig.TreeIntermediateHashSize");
            rawConfig[2] |= (uint)treeConfig.IntermediateHashSize << 8;
            // Salt
            if (config.Salt != null)
            {
                if (config.Salt.Length != 16)
                    throw new ArgumentException("config.Salt has invalid length");
                rawConfig[4] = Blake2BCore.BytesToUInt64(config.Salt, 0);
                rawConfig[5] = Blake2BCore.BytesToUInt64(config.Salt, 8);
            }
            // Personalization
            if (config.Personalization != null)
            {
                if (config.Personalization.Length != 16)
                    throw new ArgumentException("config.Personalization has invalid length");
                rawConfig[6] = Blake2BCore.BytesToUInt64(config.Personalization, 0);
                rawConfig[6] = Blake2BCore.BytesToUInt64(config.Personalization, 8);
            }

            return rawConfig;
        }
예제 #8
0
        public static ulong[] ConfigB(Blake2BConfig config, Blake2BTreeConfig treeConfig)
        {
            bool flag = treeConfig == null;

            if (flag)
            {
                treeConfig = SequentialTreeConfig;
            }
            ulong[] array  = new ulong[8];
            ulong[] array2 = new ulong[8];
            if ((config.OutputSizeInBytes <= 0) | (config.OutputSizeInBytes > 64))
            {
                throw new ArgumentOutOfRangeException("config.OutputSize");
            }
            ref ulong reference = ref array[0];
예제 #9
0
        public static ulong[] ConfigB(Blake2BConfig config, Blake2BTreeConfig treeConfig)
        {
            bool isSequential = treeConfig == null;

            if (isSequential)
            {
                treeConfig = SequentialTreeConfig;
            }
            var rawConfig = new ulong[8];
            var result    = new ulong[8];

            //digest length
            if (config.OutputSizeInBytes <= 0 | config.OutputSizeInBytes > 64)
            {
                throw new ArgumentOutOfRangeException("config.OutputSize");
            }
            rawConfig[0] |= (ulong)(uint)config.OutputSizeInBytes;

            //Key length
            if (config.Key != null)
            {
                if (config.Key.Length > 64)
                {
                    throw new ArgumentException("config.Key", "Key too long");
                }
                rawConfig[0] |= (ulong)((uint)config.Key.Length << 8);
            }
            // FanOut
            rawConfig[0] |= (uint)treeConfig.FanOut << 16;
            // Depth
            rawConfig[0] |= (uint)treeConfig.MaxHeight << 24;
            // Leaf length
            rawConfig[0] |= ((ulong)(uint)treeConfig.LeafSize) << 32;
            // Inner length
            if (!isSequential && (treeConfig.IntermediateHashSize <= 0 || treeConfig.IntermediateHashSize > 64))
            {
                throw new ArgumentOutOfRangeException("treeConfig.TreeIntermediateHashSize");
            }
            rawConfig[2] |= (uint)treeConfig.IntermediateHashSize << 8;
            // Salt
            if (config.Salt != null)
            {
                if (config.Salt.Length != 16)
                {
                    throw new ArgumentException("config.Salt has invalid length");
                }
                rawConfig[4] = Blake2BCore.BytesToUInt64(config.Salt, 0);
                rawConfig[5] = Blake2BCore.BytesToUInt64(config.Salt, 8);
            }
            // Personalization
            if (config.Personalization != null)
            {
                if (config.Personalization.Length != 16)
                {
                    throw new ArgumentException("config.Personalization has invalid length");
                }
                rawConfig[6] = Blake2BCore.BytesToUInt64(config.Personalization, 0);
                rawConfig[7] = Blake2BCore.BytesToUInt64(config.Personalization, 8);
            }

            return(rawConfig);
        }