public void RawAuthenticateResponse_Equals() { RawAuthenticateResponse rawAuthenticateResponse1 = RawAuthenticateResponse.FromBase64(_authenticateResponse.SignatureData); RawAuthenticateResponse rawAuthenticateResponse = RawAuthenticateResponse.FromBase64(_authenticateResponse.SignatureData); Assert.IsTrue(rawAuthenticateResponse1.Equals(rawAuthenticateResponse)); }
public void RawAuthenticateResponse_FromBase64() { RawAuthenticateResponse rawAuthenticateResponse = RawAuthenticateResponse.FromBase64(_authenticateResponse.SignatureData); Assert.IsNotNull(rawAuthenticateResponse); Assert.IsNotNull(rawAuthenticateResponse.UserPresence); Assert.IsNotNull(rawAuthenticateResponse.ToString()); Assert.IsTrue(rawAuthenticateResponse.UserPresence > 0); Assert.IsTrue(rawAuthenticateResponse.GetHashCode() > 0); Assert.IsTrue(rawAuthenticateResponse.Signature.Length > 0); }
public void RawAuthenticateResponse_PackBytesToSign() { RawAuthenticateResponse rawAuthenticateResponse = RawAuthenticateResponse.FromBase64(_authenticateResponse.SignatureData); byte[] signedBytes = RawAuthenticateResponse.PackBytesToSign( U2F.Crypto.Hash("testid"), rawAuthenticateResponse.UserPresence, rawAuthenticateResponse.Counter, U2F.Crypto.Hash(clientData.AsJson()) ); Assert.IsNotNull(signedBytes); Assert.IsTrue(signedBytes.Length > 0); }
/// <summary> /// Finishes a previously started authentication. /// </summary> /// <param name="startedAuthentication">The authentication the device started</param> /// <param name="response">response the response from the token/client.</param> /// <param name="deviceRegistration"></param> /// <param name="facets">A list of valid facets to verify against. (note: optional)</param> /// <returns>the new value of the DeviceRegistration's counter</returns> public static uint 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(); return(deviceRegistration.CheckAndUpdateCounter(authenticateResponse.Counter)); }