Ejemplo n.º 1
0
        private async Task <bool> ListenU2F(Dictionary <string, object> data)
        {
            var appId          = Uri.Parse((string)data["appId"]);
            var challenge      = Encoding.ASCII.GetBytes((string)data["challenge"]);
            var keys           = ((JArray)data["keys"]).ToObject <List <Dictionary <string, string> > >();
            var registeredKeys = new List <RegisteredKey>();

            foreach (var key in keys)
            {
                var keyHandle = new KeyHandle(
                    Encoding.ASCII.GetBytes(key["keyHandle"]),
                    key["version"] == "U2F_V2" ?  ProtocolVersion.V2 : ProtocolVersion.V1,
                    new List <Transport>()
                {
                    Transport.Nfc, Transport.Usb, Transport.BluetoothClassic, Transport.BluetoothLowEnergy
                }
                    );
                registeredKeys.Add(new RegisteredKey(keyHandle));
            }

            var u2FClient = Fido.GetU2fApiClient(ApplicationContext);

            var builder = new SignRequestParams.Builder();

            builder.SetAppId(appId);
            builder.SetDefaultSignChallenge(challenge);
            builder.SetRegisteredKeys(registeredKeys);
            var signRequest = builder.Build();

            var u2FPendingIntent = await u2FClient.GetSignIntentAsync(signRequest);

            if (u2FPendingIntent.HasPendingIntent)
            {
                u2FPendingIntent.LaunchPendingIntent(this, REQUEST_CODE_SIGN);
            }

            return(true);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// To iniciate the FIDO2 Service with the activity given
 /// </summary>
 public void start(AppCompatActivity application)
 {
     this.application    = application;
     this.fido2ApiClient = Fido.GetFido2ApiClient(this.application); // Start FIDO2 Client from the Android
 }