Exemplo n.º 1
0
        public async Task <CTAPResponse> SetPIN(DevParam devParam, byte[] pinAuth, byte[] newPinEnc)
        {
            var cbor = CBORObject.NewMap();

            // 0x01:pinProtocol = 1固定
            cbor.Add(0x01, 1);

            // 0x02:subCommand = 0x03:setPIN
            cbor.Add(0x02, 0x03);

            // 0x03:keyAgreement : COSE_Key
            // これは、自分が生成したもの
            {
                var user = CBORObject.NewMap();
                user.Add(1, My_KeyAgreement.Kty);
                user.Add(3, My_KeyAgreement.Alg);
                user.Add(-1, My_KeyAgreement.Crv);
                user.Add(-2, My_KeyAgreement.X);
                user.Add(-3, My_KeyAgreement.Y);
                cbor.Add(0x03, user);
            }

            // 0x04:pinAuth
            cbor.Add(0x04, pinAuth);

            // 0x05:newPinEnc
            cbor.Add(0x05, newPinEnc);

            var resi = await sendCommandandResponse(devParam, 0x06, cbor);

            var response = new CTAPResponse(resi);

            return(response);
        }
Exemplo n.º 2
0
        public async Task <CTAPResponse> GetRetries(DevParam devParam)
        {
            var cbor = CBORObject.NewMap();

            // 0x01:pinProtocol = 1固定
            cbor.Add(0x01, 1);

            // 0x02:subCommand = 0x01:getRetries
            cbor.Add(0x02, 0x01);

            var resi = await sendCommandandResponse(devParam, 0x06, cbor);

            if (resi.ResponseDataCbor != null)
            {
                foreach (var key in resi.ResponseDataCbor.Keys)
                {
                    var keyVal = key.AsByte();
                    if (keyVal == 0x03)
                    {
                        RetryCount = resi.ResponseDataCbor[key].AsUInt16();
                        break;
                    }
                }
            }
            var response = new CTAPResponse(resi);

            return(response);
        }
Exemplo n.º 3
0
        public async Task <CTAPResponse> GetKeyAgreement(DevParam devParam)
        {
            var cbor = CBORObject.NewMap();

            // 0x01:pinProtocol = 1固定
            cbor.Add(0x01, 1);

            // 0x02:subCommand = 0x02:getKeyAgreement
            cbor.Add(0x02, 0x02);

            var resi = await sendCommandandResponse(devParam, 0x06, cbor);

            var response = new CTAPResponse(resi);

            if (resi.ResponseDataCbor != null)
            {
                Authenticator_KeyAgreement = new KeyAgreement(resi.ResponseDataCbor);
            }

            return(response);
        }