Beispiel #1
0
        public static ISigningProvider GetSigningProvider(ISignArguments arguments)
        {
            switch (arguments.SigningProvider)
            {
            case SigningProviderType.FileName:
                return(new PrivateKeyFileSigningProvider(arguments.PrivateKeyFileName));

            case SigningProviderType.AzureKeyVault:
                return(new AzureKeyVaultSigningProvider(arguments.AzureKeyVaultConnectionString));

            default:
                throw new ArgumentOutOfRangeException(nameof(arguments), $"Unable to locate {nameof(ISigningProvider)} for {arguments.SigningProvider}");
            }
        }
Beispiel #2
0
        private static int RunSign(ISignArguments arguments, RunResult runResult)
        {
            Console.Out.WriteLine();
            Console.Out.WriteLine($"{nameof(RunSign)}");

            arguments.Validate();

            var inputData = runResult.HashedData.HasAny()
                ? runResult.HashedData
                : ByteArrayHelper.TranslateByteArray(arguments.InputData);

            Console.Out.WriteLine($"Using: {ByteArrayHelper.DescribeByteArray(inputData)}");

            var signingProvider = SigningProviderFactory.GetSigningProvider(arguments);

            runResult.SignedData = signingProvider.SignHash(inputData);

            Console.Out.WriteLine($"{nameof(RunResult.SignedData)}: {ByteArrayHelper.DescribeByteArray(runResult.SignedData)}");

            return(0);
        }