public byte[] Generate(byte[] agreed) { IMac prfMac; if (prfAlgorithm == FipsPrfAlgorithm.AesCMac) { Internal.IBlockCipher aesEng = FipsAes.ENGINE_PROVIDER.CreateEngine(EngineUsage.GENERAL); aesEng.Init(true, new KeyParameter(salt ?? new byte[16])); prfMac = new CMac(aesEng); prfMac.Init(null); } else { prfMac = FipsShs.CreateHmac((DigestAlgorithm)prfAlgorithm.BaseAlgorithm); prfMac.Init(new KeyParameter(salt ?? new byte[((HMac)prfMac).GetUnderlyingDigest().GetByteLength()])); } byte[] mac = Macs.DoFinal(prfMac, agreed, 0, agreed.Length); // ZEROIZE Arrays.Fill(agreed, (byte)0); return(mac); }
/// <summary> /// Initialize the structure with parameters for any supported type of Mac generator /// </summary> /// /// <param name="MacType">The type of Mac generator; Cmac, Hmac, or Vmac</param> /// <param name="KeySize">The mac/cipher key size in bytes</param> /// <param name="IvSize">Size of the Mac Initialization Vector</param> /// <param name="HmacEngine">The <see cref="VTDev.Libraries.CEXEngine.Crypto.Enumeration.Digests">Digest</see> engine used in the Hmac</param> /// <param name="EngineType">The symmetric block cipher <see cref="VTDev.Libraries.CEXEngine.Crypto.Enumeration.SymmetricEngines">Engine</see> type</param> /// <param name="RoundCount">The number of diffusion <see cref="VTDev.Libraries.CEXEngine.Crypto.Enumeration.RoundCounts">Rounds</see></param> /// <param name="BlockSize">The cipher <see cref="VTDev.Libraries.CEXEngine.Crypto.Enumeration.BlockSizes">Block Size</see></param> /// <param name="KdfEngine">The <see cref="VTDev.Libraries.CEXEngine.Crypto.Enumeration.Digests">Digest</see> engine used to power the key schedule Key Derivation Function in HX and M series ciphers</param> public MacDescription(Macs MacType, int KeySize, int IvSize, Digests HmacEngine = Digests.SHA512, BlockCiphers EngineType = BlockCiphers.Rijndael, RoundCounts RoundCount = RoundCounts.R14, BlockSizes BlockSize = BlockSizes.B128, Digests KdfEngine = Digests.SHA512) { this.MacType = (int)MacType; this.KeySize = KeySize; this.IvSize = IvSize; this.HmacEngine = (int)HmacEngine; this.EngineType = (int)EngineType; this.RoundCount = (int)RoundCount; this.BlockSize = (int)BlockSize; this.KdfEngine = (int)KdfEngine; }
public bool HasTestPassed(EngineProvider provider) { byte[] input16 = Hex.Decode("6bc1bee22e409f96e93d7e117393172a"); byte[] output_k128_m16 = Hex.Decode("c0b9bbee139722ab"); IMac mac = new CMac(provider.CreateEngine(EngineUsage.GENERAL), 64); //128 bytes key KeyParameter key = new KeyParameter(Hex.Decode("0102020404070708080b0b0d0d0e0e101013131515161619")); byte[] output = Macs.DoFinal(mac, key, input16, 0, input16.Length); return(Arrays.AreEqual(FipsKats.Values[FipsKats.Vec.TripleDesCMacTag], output)); }
public bool HasTestPassed(EngineProvider provider) { byte[] keyBytes128 = Hex.Decode("2b7e151628aed2a6abf7158809cf4f3c"); byte[] input16 = Hex.Decode("6bc1bee22e409f96e93d7e117393172a"); byte[] output_k128_m16 = Hex.Decode("070a16b46b4d4144f79bdd9dd04a287c"); IMac mac = new CMac(provider.CreateEngine(EngineUsage.GENERAL), 128); //128 bits key KeyParameter key = new KeyParameter(keyBytes128); byte[] output = Macs.DoFinal(mac, key, input16, 0, input16.Length); return(Arrays.AreEqual(FipsKats.Values[FipsKats.Vec.AesCMacTag], output)); }
private async void Guardar() { try { Cursor = Cursors.WaitCursor; var trimestreResult = macsViewModelsBindingSource.DataSource as List <MacsViewModels>; List <Macs> MacsAdapter = new List <Macs>(); if (trimestreResult.Count > 0) { trimestreResult.ForEach(x => { var models = new Macs { MacsID = x.MacsID, nota1 = x.nota1, nota2 = x.nota2, nota3 = x.nota3, nota4 = x.nota4, nota5 = x.nota5, nota6 = x.nota6, nota7 = x.nota7, nota8 = x.nota8, AlunosID = x.AlunosID, TrimestreID = x.TrimestreID, }; MacsAdapter.Add(models); }); } if ((await MacsControllers.GetInstacia().InsertAll(MacsAdapter)).IsSucess) { XtraMessageBox.Show("Serviço Inserido com Sucesso!...", "Sucesso", MessageBoxButtons.OK, MessageBoxIcon.Information); ListGeral(); } else { XtraMessageBox.Show("Este Valor já existe tente novamente", "Má conclusão", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (System.Exception exception) { MessageBox.Show("Erro " + exception, "Erro de SQL", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { Cursor = Cursors.Default; } }
public async Task <Response> Delete(Macs alunos) { using (AppProfessorContext context = new AppProfessorContext()) { using (Transation_Scoper db = new Transation_Scoper(context)) { var result = await db.DoDelete(alunos).EndTransaction(); return(new Response { IsSucess = result.estado, list = alunos, Messgems = result.Exception, }); } } }
private static byte[] CalculateAssemblyHMac() { Assembly assembly = Assembly.GetExecutingAssembly(); Check(assembly.GetModules().Length == 1); string path = assembly.ManifestModule.FullyQualifiedName; byte[] data = File.ReadAllBytes(path); IMac mac = new HMac(new Sha512Digest()); mac.Init(new KeyParameter(MacKey)); int macPos; var ranges = AnalyzePEData(data, out macPos); Check(macPos >= 0); int pos = 0; foreach (var range in ranges) { if (pos < range.Start) { mac.BlockUpdate(data, pos, range.Start - pos); } if (range.Data != null) { mac.BlockUpdate(range.Data, 0, range.Data.Length); } int rangeEnd = range.Start + range.Length; if (pos < rangeEnd) { pos = rangeEnd; } } if (pos < data.Length) { mac.BlockUpdate(data, pos, data.Length - pos); } return(Macs.DoFinal(mac)); }
public Schedule(ProblemInstance prob, Random rnd = null, string slotAllocation = "FirstSlotChosen") { _prob = prob; Sequence = new List<Dispatch>(prob.Dimension); _jobs = new Jobs[_prob.NumJobs]; _macs = new Macs[_prob.NumMachines]; ReadyJobs = new List<int>(_prob.NumJobs); for (int job = 0; job < _prob.NumJobs; job++) { ReadyJobs.Add(job); int totalWork = 0; for (int a = 0; a < _prob.NumMachines; a++) totalWork += _prob.Procs[job, a]; _jobs[job] = new Jobs(job, totalWork, _prob.NumMachines); _totProcTime += totalWork; // total work for all jobs (is equivalent to total work for all machines) } for (int mac = 0; mac < _prob.NumMachines; mac++) { int totalWork = 0; for (int j = 0; j < _prob.NumJobs; j++) totalWork += _prob.Procs[j, mac]; _macs[mac] = new Macs(mac, totalWork); } _slotAllocation = slotAllocation.Substring(0, 5).ToLower().Equals("first") ? (Func<int[], int, int, int>) FirstSlotChosen : SmallestSlotChosen; if (rnd == null) { int seed = (int) DateTime.Now.Ticks; _random = new Random(seed); } else _random = rnd; }
private object ChosseDevice(DEVICED_TYPD deviceType, string[] macOrDevice) { object _target = null; switch (deviceType) { case DEVICED_TYPD.MACS: _target = new Macs(macOrDevice); break; case DEVICED_TYPD.DEVICE_ONE: _target = new DeviceId_1(macOrDevice[0]); break; case DEVICED_TYPD.DEVICE_TWO: _target = new DeviceId_2(macOrDevice[0], macOrDevice[1]); break; case DEVICED_TYPD.DEVICE_THREE: _target = new DeviceId_3(macOrDevice[0], macOrDevice[1], macOrDevice[2]); break; } return(_target); }
public byte[] Collect() { return(Macs.DoFinal(mac)); }
public bool HasTestPassed(IMac hMac) { byte[] result = Macs.DoFinal(hMac, new KeyParameter(key), stdHMacVector, 0, stdHMacVector.Length); return(Arrays.AreEqual(result, kat)); }
public Macs Clone() { Macs clone = new Macs(Index, TotProcTime) { WorkRemaining = WorkRemaining, JobCount = JobCount, Makespan = Makespan, TotSlack = TotSlack, ETime = new int[JobCount], STime = new int[JobCount], Slacks = new int[JobCount] }; Array.Copy(ETime, clone.ETime, JobCount); Array.Copy(STime, clone.STime, JobCount); Array.Copy(Slacks, clone.Slacks, JobCount); return clone; }