public void Setup()
        {
            StartedAuthentication startedAuthentication =
                new StartedAuthentication(TestConts.SERVER_CHALLENGE_SIGN_BASE64, TestConts.APP_ID_ENROLL,
                                          TestConts.KEY_HANDLE_BASE64);
            _authenticateResponse = new AuthenticateResponse(TestConts.CLIENT_DATA_AUTHENTICATE_BASE64,
                                                                                 TestConts.SIGN_RESPONSE_DATA_BASE64,
                                                                                 TestConts.KEY_HANDLE_BASE64);

            clientData = _authenticateResponse.GetClientData();
            clientData.CheckContent(AuthenticateTyp, startedAuthentication.Challenge, null);
        }
        public void AuthenticateResponse_ConstructsProperly()
        {
            AuthenticateResponse authenticateResponse = new AuthenticateResponse(TestConts.CLIENT_DATA_AUTHENTICATE_BASE64,
                                                                                 TestConts.SIGN_RESPONSE_DATA_BASE64,
                                                                                 TestConts.KEY_HANDLE_BASE64);

            Assert.IsNotNull(authenticateResponse);
            Assert.IsNotNull(authenticateResponse.ToJson());
            Assert.IsNotNull(authenticateResponse.GetClientData());
            Assert.IsTrue(authenticateResponse.GetHashCode() != 0);
            Assert.AreEqual(JsonData, authenticateResponse.ToJson());
            Assert.AreEqual(TestConts.SIGN_RESPONSE_DATA_BASE64, authenticateResponse.SignatureData);
            Assert.AreEqual(TestConts.KEY_HANDLE_BASE64, authenticateResponse.KeyHandle);
        }
예제 #3
0
파일: U2F.cs 프로젝트: mvidacovich/u2flib
        /**
        * Finishes a previously started authentication.
        *
        * @param startedAuthentication
        * @param response the response from the token/client.
        * @return the new value of the DeviceRegistration's counter.
        */
        public static void FinishAuthentication(StartedAuthentication startedAuthentication,
                                                              AuthenticateResponse response,
                                                              DeviceRegistration deviceRegistration,
                                                              HashSet<String> facets = null)
        {
            ClientData clientData = response.GetClientData();
            clientData.CheckContent(AuthenticateTyp, startedAuthentication.Challenge, facets);

            RawAuthenticateResponse authenticateResponse = RawAuthenticateResponse.FromBase64(response.SignatureData);
            authenticateResponse.CheckSignature(startedAuthentication.AppId, clientData.AsJson(), deviceRegistration.PublicKey);
            authenticateResponse.CheckUserPresence();

            deviceRegistration.CheckAndUpdateCounter(authenticateResponse.Counter);
        }