public void U2F_StartRegistration() { var results = U2F.StartRegistration(TestConts.APP_ID_ENROLL); Assert.IsNotNull(results); Assert.IsNotNull(results.Challenge); Assert.IsNotNull(results.Version); Assert.AreEqual(results.AppId, TestConts.APP_ID_ENROLL); }
public ServerRegisterResponse GenerateServerChallenge(string username) { if (string.IsNullOrWhiteSpace(username)) { return(null); } StartedRegistration startedRegistration = U2F.StartRegistration(DemoAppId); _userRepository.SaveUserAuthenticationRequest(username, startedRegistration.AppId, startedRegistration.Challenge, startedRegistration.Version); return(new ServerRegisterResponse { AppId = startedRegistration.AppId, Challenge = startedRegistration.Challenge, Version = startedRegistration.Version }); }
public ServerRegisterResponse GenerateServerRegistration(string userName, string password) { if (string.IsNullOrWhiteSpace(userName) || string.IsNullOrWhiteSpace(password)) { return(null); } StartedRegistration startedRegistration = U2F.StartRegistration(DemoAppId); string hashedPassword = HashPassword(password); _userRepository.AddUser(userName, hashedPassword); _userRepository.AddAuthenticationRequest(userName, startedRegistration.AppId, startedRegistration.Challenge, startedRegistration.Version); return(new ServerRegisterResponse { AppId = startedRegistration.AppId, Challenge = startedRegistration.Challenge, Version = startedRegistration.Version }); }
public static async Task <DeviceRegistration> RegisterAsync(IHidDevice hidDevice, string appId, string facet, CancellationToken?cancellationToken = null) { cancellationToken = cancellationToken ?? CancellationToken.None; if (hidDevice == null || !hidDevice.IsConnected) { throw new ArgumentException("Hid device not connected", nameof(hidDevice)); } using (var u2fHidDevice = await U2FHidDevice.OpenAsync(hidDevice)) { var startRegistration = U2F.StartRegistration(appId); Log.Debug("Touch token to register"); var registerResponse = await WaitForTokenInputAsync(() => U2Fv2.RegisterAsync(u2fHidDevice, startRegistration, facet), cancellationToken.Value); var deviceRegistration = U2F.FinishRegistration(startRegistration, registerResponse); Log.Debug("Registered"); return(deviceRegistration); } }