public U2FClientReferenceImpl(IClientCrypto crypto, IOriginVerifier appIdVerifier,
                               IChannelIdProvider channelIdProvider, IU2FServer server, IU2FKey key, IClock clock)
 {
     this.crypto            = crypto;
     this.appIdVerifier     = appIdVerifier;
     this.channelIdProvider = channelIdProvider;
     this.server            = server;
     this.key   = key;
     this.clock = clock;
 }
 public U2FClientReferenceImpl(IClientCrypto crypto, IOriginVerifier appIdVerifier,
     IChannelIdProvider channelIdProvider, IU2FServer server, IU2FKey key, IClock clock)
 {
     this.crypto = crypto;
     this.appIdVerifier = appIdVerifier;
     this.channelIdProvider = channelIdProvider;
     this.server = server;
     this.key = key;
     this.clock = clock;
 }
        public static KeyRegisterRequest RegistrationRequestToRegisterRequest(string origin,
                                                                              RegisterRequest registerRequest, JObject channelIdJson, out string clientData,
                                                                              IClientCrypto crypto)
        {
            clientData = ClientDataCodec.EncodeClientData(ClientDataCodec.RequestTypeRegister, registerRequest.Challenge,
                                                          origin, channelIdJson);
            var clientDataSha256 = crypto.ComputeSha256(clientData);
            var appIdSha256      = crypto.ComputeSha256(registerRequest.AppId);

            return(new KeyRegisterRequest(appIdSha256, clientDataSha256));
        }
 public static KeySignRequest SignRequestToAuthenticateRequest(string origin, SignRequest signRequest, JObject channelIdJson,
     out string clientData, IClientCrypto crypto)
 {
     clientData = ClientDataCodec.EncodeClientData(ClientDataCodec.RequestTypeAuthenticate, signRequest.Challenge,
         origin, channelIdJson);
     var clientDataSha256 = crypto.ComputeSha256(clientData);
     var appIdSha256 = crypto.ComputeSha256(signRequest.AppId);
     var keyHandle = WebSafeBase64Converter.FromBase64String(signRequest.KeyHandle);
     return new KeySignRequest(U2FVersion.V2,
         clientDataSha256, appIdSha256, keyHandle);
 }
Example #5
0
        public U2FClient([NotNull] ISender sender, [CanBeNull] CheckAppIdOrOrigin originChecker,
                         [CanBeNull] CheckAppIdOrOrigin appIdChecker, [NotNull] IKeyOperations keyOperations,
                         [NotNull] IClientCrypto crypto)
        {
            if (sender == null)
            {
                throw new ArgumentNullException(nameof(sender));
            }
            if (keyOperations == null)
            {
                throw new ArgumentNullException(nameof(keyOperations));
            }
            if (crypto == null)
            {
                throw new ArgumentNullException(nameof(crypto));
            }

            this.sender        = sender;
            this.originChecker = originChecker ?? NoAppIdOrOriginCheck;
            this.appIdChecker  = appIdChecker ?? NoAppIdOrOriginCheck;
            this.keyOperations = keyOperations;
            this.crypto        = crypto;
        }
Example #6
0
        public U2FClient([NotNull] ISender sender, [CanBeNull] CheckAppIdOrOrigin originChecker,
            [CanBeNull] CheckAppIdOrOrigin appIdChecker, [NotNull] IKeyOperations keyOperations,
            [NotNull] IClientCrypto crypto)
        {
            if (sender == null)
            {
                throw new ArgumentNullException(nameof(sender));
            }
            if (keyOperations == null)
            {
                throw new ArgumentNullException(nameof(keyOperations));
            }
            if (crypto == null)
            {
                throw new ArgumentNullException(nameof(crypto));
            }

            this.sender = sender;
            this.originChecker = originChecker ?? NoAppIdOrOriginCheck;
            this.appIdChecker = appIdChecker ?? NoAppIdOrOriginCheck;
            this.keyOperations = keyOperations;
            this.crypto = crypto;
        }
        public static KeySignRequest SignRequestToAuthenticateRequest(string origin, SignRequest signRequest, JObject channelIdJson,
                                                                      out string clientData, IClientCrypto crypto)
        {
            clientData = ClientDataCodec.EncodeClientData(ClientDataCodec.RequestTypeAuthenticate, signRequest.Challenge,
                                                          origin, channelIdJson);
            var clientDataSha256 = crypto.ComputeSha256(clientData);
            var appIdSha256      = crypto.ComputeSha256(signRequest.AppId);
            var keyHandle        = WebSafeBase64Converter.FromBase64String(signRequest.KeyHandle);

            return(new KeySignRequest(U2FVersion.V2,
                                      clientDataSha256, appIdSha256, keyHandle));
        }
Example #8
0
 public U2FClient([NotNull] ISender sender, [CanBeNull] CheckAppIdOrOrigin originChecker,
                  [CanBeNull] CheckAppIdOrOrigin appIdChecker, [NotNull] IKeyFactory keyFactory,
                  [NotNull] IClientCrypto crypto)
     : this(sender, originChecker, appIdChecker, new KeyOperations(keyFactory), crypto)
 {
 }
 public static KeyRegisterRequest RegistrationRequestToRegisterRequest(string origin,
     RegisterRequest registerRequest, JObject channelIdJson, out string clientData,
     IClientCrypto crypto)
 {
     clientData = ClientDataCodec.EncodeClientData(ClientDataCodec.RequestTypeRegister, registerRequest.Challenge,
         origin, channelIdJson);
     var clientDataSha256 = crypto.ComputeSha256(clientData);
     var appIdSha256 = crypto.ComputeSha256(registerRequest.AppId);
     return new KeyRegisterRequest(appIdSha256, clientDataSha256);
 }