public SBlock() { _database = null; CorMatrix.Clear(); FuncMatrix.Clear(); VarCount = 0; }
public override void Init(List <byte> arg) // from interfaces { const int bias = 0; //S-Block record type: 'some args, Line1, Line2, ..., LineN'. No some args => Bias=0. if (arg.Count >= bias) { if (arg.Count - bias != 0) { VarCount = (int)Math.Log(arg.Count - bias, 2); // Matrix: 2**n x n } if (VarCount == this._length) { FuncMatrix = WayConverter.ListToMatrix(arg.Skip(bias).ToList(), VarCount); //Line0: y0..yn //Line1: y0..yn //.................... //Line2**n-1: y0..yn if (_database == null) { _database = new SBlockDB(); } var Note = _database.GetNoteFromDB(FuncMatrix); CorMatrix = Note.CorMatrix; DifMatrix = Note.DifMatrix; LStates = Note.LStates; DStates = Note.DStates; } else { throw new Exception("Argument length error"); } } }
public SPNetSettings(byte WordLength, byte SBoxSize, ISBlockDB DB = null) { this.WordLength = WordLength; this.SBoxSize = SBoxSize; this.SBoxCount = (byte)(this.WordLength / this.SBoxSize); this.db = DB; }
public virtual ISBlockDB GetSBlockDBInstance() { if (TheDB == null) { TheDB = new SBlockDB(); } return(TheDB); }
public virtual ISPNet GetSPNetInstance(SPNetSettings settings) //from interfaces { if (settings.db == null) { TheDB = new SBlockDB(); } TheNet = new SPNet(settings); return(TheNet); }
public SBlock(List <List <bool> > Matrix, SBlockDB database) { _database = database; CorMatrix.Clear(); FuncMatrix.Clear(); FuncMatrix = Matrix; VarCount = 0; var Note = _database.GetNoteFromDB(FuncMatrix); CorMatrix = Note.CorMatrix; DifMatrix = Note.DifMatrix; }
public virtual ISBlockDB GetSBlockDBInstance(FileStream FS, bool xml = false) //from interfaces { var arr = new byte[FS.Length - FS.Position]; FS.Read(arr, (int)FS.Position, arr.Length); arr = Unzip(Unzip(arr)); if (xml) { var xmlSerializer = new XmlSerializer(typeof(SBlockDB)); TheDB = (SBlockDB)xmlSerializer.Deserialize(FS); } else { using (var stream = new MemoryStream(arr)) { var formatter = new BinaryFormatter(); TheDB = (SBlockDB)formatter.Deserialize(stream); } } return(TheDB); }
public SLayer(ISBlockDB db, byte block_length, byte blocks_count) { type = LayerType.SLayer; Blocks = new List <Block>(blocks_count); Blocks.AddRange(Enumerable.Range(0, blocks_count).Select(i => new SBlock(db, block_length)).ToList()); }
void SetDB(SBlockDB database) { _database = database; }