public void AcceptBlock(ISBlock block) { if(HeadBlock == null) { HeadBlock = block; HeadBlock.PreviousBlockHash = null; } CurrentBlock = block; Blocks.Add(block); }
public GostManager(byte[] key, byte[] iv, byte[] message, CipherTypes cipherType = CipherTypes.Substitution, SBlockTypes sBlockType = SBlockTypes.GOST) { released = false; _subKeys = new List <uint>(); Key = key; IV = iv; Message = message; GenerateSubKeys(); _sBlock = SBlockFactory.SBlock(sBlockType); _cipher = CipherFactory.Cipher(_iv, _subKeys, cipherType, _sBlock); }
public void SetBlockHash(ISBlock parent) { if (parent != null) { PreviousBlockHash = parent.BlockHash; parent.NextBlock = this; } else { // Previous block is the genesis block. PreviousBlockHash = null; } BlockHash = CalculateBlockHash(PreviousBlockHash); }
protected virtual void Dispose(bool disposing) { if (!released) { if (disposing) { _sBlock = null; _cipher = null; _iv = null; _key = null; _message = null; _subKeys = null; } released = true; } }
public SBlock(int blockNumber, string claimNumber, decimal settlementAmount, DateTime settlementDate, string carRegistration, int mileage, ClaimType claimType, ISBlock parent) { BlockNumber = blockNumber; ClaimNumber = claimNumber; SettlementAmount = settlementAmount; SettlementDate = settlementDate; CarRegistration = carRegistration; Mileage = mileage; ClaimType = claimType; CreatedDate = DateTime.UtcNow; SetBlockHash(parent); }
public SubstitutionCipher(ISBlock sBlock) { _sBlock = sBlock; }
public CbfCipher(byte[] iv, ISBlock sblock) : base(sblock) { SetIV(iv); }
public static ICipher Cipher(byte[] iv, List <uint> subKeys, CipherTypes cipher, ISBlock sBlock) { return(cipher switch { CipherTypes.Substitution => new SubstitutionCipher(sBlock), CipherTypes.Cfb => new CbfCipher(iv, sBlock), CipherTypes.Xor => new XorCipher(iv, subKeys, sBlock), _ => throw new ArgumentException(nameof(cipher)), });
public MacGenerator(ISBlock sBlock) { substitution = new SubstitutionCipher(sBlock); }
public XorCipher(byte[] iv, List <uint> subKeys, ISBlock sBlock) : base(sBlock) { SetIV(iv, subKeys); }