private static void KdcJoin(string[] cmds) { if (cmds.Length != 3) { Console.WriteLine("Incorrect number of parameters"); return; } if ((Program._CurrentOscore == null) || (Program._CurrentOscore.UserData == null) || !(Program._CurrentOscore.UserData is GroupData)) { Console.WriteLine("Can't use the current OSCORE context"); return; } GroupData groupData = (GroupData)Program._CurrentOscore.UserData; OneKey signKey = OneKey.GenerateKey(null, GeneralValues.KeyType_OKP, "Ed25519"); byte[] signature = Signer.Sign(groupData.SignNonce, groupData.SignInfo[0], signKey); CBORObject join = CBORObject.NewMap(); CBORObject j2 = CBORObject.NewMap(); j2.Add(Confirmation.ConfirmationIds.COSE_Key, signKey.AsCBOR()); join.Add("type", 1); join.Add("client_cred", j2); join.Add("client_cred_verify", signature); Request request = new Request(Method.POST) { URI = new Uri(cmds[1]), Payload = @join.EncodeToBytes(), ContentType = MediaType.ApplicationCbor, OscoreContext = Program._CurrentOscore }; request.Send(); Response response = request.WaitForResponse(); if (response == null || response.StatusCode != StatusCode.Changed) { Console.WriteLine("Error in the response"); return; } CBORObject respBody = CBORObject.DecodeFromBytes(response.Payload); }
/// <summary> /// Create conformation object from a key /// </summary> /// <param name="key"></param> public Confirmation(OneKey key) { _data.Add("COSE_Key", key.AsCBOR()); }