Example #1
0
File: U2F.cs Project: Stift/u2flib
        /**
         * Initiates the registration of a device.
         *
         * @param appId the U2F AppID. Set this to the Web Origin of the login page, unless you need to
         * support logging in from multiple Web Origins.
         * @return a StartedRegistration, which should be sent to the client and temporary saved by the
         * server.
         */
        public static StartedRegistration StartRegistration(String appId)
        {
            byte[] challenge       = ChallengeGenerator.GenerateChallenge();
            String challengeBase64 = Utils.ByteArrayToBase64String(challenge);

            return(new StartedRegistration(challengeBase64, appId));
        }
Example #2
0
        public RegisterRequest GetRegistrationRequest(string accountName, string appId)
        {
            log.Info(">> getRegistrationRequest " + accountName);

            var challenge       = challengeGenerator.GenerateChallenge(accountName);
            var sessionData     = new EnrollSessionData(accountName, appId, challenge);
            var sessionId       = dataStore.StoreSessionData(sessionData);
            var challengeBase64 = WebSafeBase64Converter.ToBase64String(challenge);

            log.Info("-- Output --");
            log.Info("  sessionId: " + sessionId);
            log.Info("  challenge: " + challenge.ToHexString());
            log.Info("<< getRegistrationRequest " + accountName);

            return(new RegisterRequest(U2FConsts.U2Fv2, challengeBase64, appId, sessionId));
        }