/// <summary> /// Verify a message with password based MAC protection. /// </summary> /// <param name="pkMacBuilder">MAC builder that can be used to construct the appropriate MacCalculator</param> /// <param name="password">the MAC password</param> /// <returns>true if the passed in password and MAC builder verify the message, false otherwise.</returns> /// <exception cref="InvalidOperationException">if algorithm not MAC based, or an exception is thrown verifying the MAC.</exception> public bool Verify(PKMacBuilder pkMacBuilder, char[] password) { if (!CmpObjectIdentifiers.passwordBasedMac.Equals(pkiMessage.Header.ProtectionAlg.Algorithm)) { throw new InvalidOperationException("protection algorithm is not mac based"); } PbmParameter parameter = PbmParameter.GetInstance(pkiMessage.Header.ProtectionAlg.Parameters); pkMacBuilder.SetParameters(parameter); IBlockResult result = (IBlockResult)Process(pkMacBuilder.Build(password).CreateCalculator()); return(Arrays.ConstantTimeAreEqual(result.Collect(), this.pkiMessage.Protection.GetBytes())); }
internal BlockTraceResult(StackBlockBase <TOperationEvent> stackBlock, IBlockResult blockResult) { Tag = stackBlock.Tag; Input = stackBlock.Input; Result = blockResult.Result; InnerStackTrace = stackBlock.InnerStackTrace ?? Enumerable.Empty <BlockTraceResult <TOperationEvent> >(); Events = stackBlock.Events.ToList(); if (blockResult.ExecutionTime == null) { Time = new ExecutionTime(); } else { Time = blockResult.ExecutionTime; } }
/// <summary> /// Handle current block result and set next block to execute /// </summary> /// <param name="block">The execution block</param> /// <param name="blockResult">The execution block result</param> public void HandleBlockResultAndSetNext(StackBlockBase <TInput, TState, TOperationEvent> block, IBlockResult blockResult) { PreviousBlockSpec = CurrentBlockSpec; //Add to stack trace //Should we add trace to empty event blocks? To event blocks? StackTrace.Add(new BlockTraceResult <TOperationEvent>(block, blockResult)); //Handle Reset state in case of reset State = blockResult.Target.FlowTarget == BlockFlowTarget.Reset ? (blockResult.Target.ResetStateSet ? (TState)Convert.ChangeType(blockResult.Target.State, typeof(TState)) : default(TState)) : block.StackState; //Check fail state if (options.FailOnException && block.Events.HasUnhandledErrors) { IsFail = true; } //Override result is only applicable on Complete. Cache here in case of finally OverrideResult = blockResult.Target.OverrideResult; //Set next input NextInput = blockResult.GetNextInput(); //Get next block to execute CurrentBlockSpec = IsFail ? blocks.GotoEnd(CurrentBlockSpec.Index) : GetNext(CurrentBlockSpec, blockResult.Target); //If complete set overriden result if any if (CurrentBlockSpec == null && OverrideResult.HasValue) { //Set last result LastResult = OverrideResult; blockResult.OverrideResult(OverrideResult); } else { //Set last result LastResult = blockResult.Result; } }
public Result(IBlockResult sigResult, IBlockResult digResult) { this.sigResult = sigResult; this.digResult = digResult; }