Ejemplo n.º 1
0
        private static void RegisterAESImplementation(IContainer container)
        {
            var encryptionConfiguration =
                new InvokerElement <Initializer>("Initializer")
                .Invokes <BlockLoop>("BlockLoop")
                .Invokes <CipherBlockChaining>("CBC")
                .InvokesMultiple(
                    new InvokerElement <InputBlockToStateMatrix>("StateMapper"),
                    new InvokerElement <CopyKeyIntoKeySchedule>("KeyScheduleInit"),
                    new InvokerElement <ComputeKeyScheduleConditional>("KeyScheduleLoop")
                    .InvokesMultiple(new InvokerElement <ComputeKeyScheduleLogic>("KeyScheduleLogic")
                                     .InvokesMultiple(
                                         new InvokerElement <IsEven>("KeyScheduleConditional")
                                         .Invokes <RotateWord>("RotateWord")
                                         .Invokes <SubWord>("SubWord1")
                                         .Invokes <ShiftRoundConstant>("ShiftRoundConstant"),
                                         new InvokerElement <Is256BitKey>("KeySchedule256BitKeyConditional")
                                         .Invokes <SubWord>("SubWord2"),
                                         new InvokerElement <XOrWithPrevious>("KeyScheduleComplete"))),
                    new InvokerElement <AddRoundKey>("RoundKey1"),
                    new InvokerElement <RoundConditional>("RoundConditional")
                    .InvokesMultiple(
                        new InvokerElement <SubBytes>("SubBytes"),
                        new InvokerElement <ShiftRows>("ShiftRows"),
                        new InvokerElement <IfNotLastRound>("IfNotLastRound").Invokes <MixColumns>("MixColumns"),
                        new InvokerElement <AddRoundKey>("RoundKey2").Invokes <IncrementIndex>("IncrementIndex")),
                    new InvokerElement <StateToOutputBlock>("StateToOutputBlock"),
                    new InvokerElement <ResultBuilder>("Result"));


            container.RegisterInvoker <(byte[] plaintext, byte[] iv, byte[] key), byte[]>(encryptionConfiguration);
        }
Ejemplo n.º 2
0
        public static IInvokerConfigElement <object> Invokes <TTarget>(this IInvokerConfigElement <object> invokerConfiguration, string name = null)
            where TTarget : class
        {
            var child = new InvokerElement <TTarget>(name ?? typeof(TTarget).Name, parent: invokerConfiguration);

            if (invokerConfiguration.Children == null)
            {
                invokerConfiguration.Children = new IInvokerConfigElement <object>[] { };
            }

            invokerConfiguration.Children = invokerConfiguration.Children.Append(child).ToArray();
            return(child);
        }
        public async Task TestInvokerInfrastructure()
        {
            var unityContainer = new UnityContainer();
            var container      = new UnityContainerWrapper(unityContainer);

            var configuration =
                new InvokerElement <ClassForTesting.Initializer>("Init")
                .Invokes <LoopConditional>("Loop")
                .InvokesMultiple(
                    new InvokerElement <If>("If").Invokes <IfLogic>("IfLogic"),
                    new InvokerElement <Else>("Else").Invokes <ElseLogic>("ElseLogic"))
                .Invokes <Return>();

            container.RegisterInvoker <string>(configuration);
            var invoker = container.Resolve <IInvoker <string> >();

            await invoker.Invoke(Task.FromResult("HelloWorld!").AsITask());
        }