Exemple #1
0
        private static void GenOscore(string[] cmds)
        {
            int    count     = int.Parse(cmds[1]);
            int    keyType   = int.Parse(cmds[2]);
            string algParams = cmds[3];

            for (int i = 0; i < count; i++)
            {
                OneKey key = OneKey.GenerateKey(null, CBORObject.FromObject(keyType), algParams);
                Console.WriteLine("*** " + key.EncodeToCBORObject().ToString());
            }
        }
Exemple #2
0
        static void Main(string[] args)
        {
            Options options = null;
            ParserResult <Options> optionResult = CommandLine.Parser.Default.ParseArguments <Options>(args)
                                                  .WithParsed(o => { options = o; })
                                                  .WithNotParsed(o => {
                Console.WriteLine("Invalid command line");
                Console.WriteLine(o.ToString());
                Environment.Exit(1);
            });


            Console.Title = options.Title;

#if false
            {
                //  Generate a pair of CWT messages signed by a third key.

                OneKey clientKey = OneKey.GenerateKey(AlgorithmValues.ECDSA_256, GeneralValues.KeyType_EC);
                OneKey serverKey = OneKey.GenerateKey(AlgorithmValues.ECDSA_256, GeneralValues.KeyType_EC);
                OneKey caKey     = OneKey.GenerateKey(AlgorithmValues.ECDSA_256, GeneralValues.KeyType_EC);

                CWT clientCwt = new CWT();
                clientCwt.Cnf        = new Confirmation(clientKey.PublicKey());
                clientCwt.SigningKey = caKey;
                CBORObject clientCwtCbor  = clientCwt.EncodeToCBOR();
                string     clientCwtStr   = clientCwtCbor.ToString();
                byte[]     clientCwtBytes = clientCwt.EncodeToBytes();

                CWT serverCwt = new CWT()
                {
                    Cnf        = new Confirmation(serverKey),
                    SigningKey = caKey
                };
                CBORObject serverCwtCbor  = serverCwt.EncodeToCBOR();
                string     serverCwtStr   = serverCwtCbor.ToString();
                byte[]     serverCwtBytes = serverCwt.EncodeToBytes();

                string caStr = caKey.EncodeToCBORObject().ToString();
            }
#endif

            LogManager.Instance = new FileLogManager(Console.Out);


            FillDispatchTable(dispatchTable);
            Oscore.Register(dispatchTable);
#if DEV_VERSION
            Groups.FillDispatchTable(dispatchTable);
#endif

#if DO_ACE
            AceAuthz.AddCommands(dispatchTable);

            //  Setup plain OAuth
            AceAuthzHandler = new AceAuthz();
#endif
#if DO_RD
            ResourceDirectory.AddCommands(dispatchTable);
#endif



            if (options.Script != null)
            {
                TextReader x = new StreamReader(options.Script);
                RunScript(x);
                x.Dispose();
            }


            RunScript(Console.In);
        }