public async Task <U2FAuthenticationResponse> AuthenticateAsync(byte[] challenge, AppId applicationId, KeyHandle keyHandle, CancellationToken cancellationToken = default(CancellationToken)) { if (challenge == null) { throw new ArgumentNullException("challenge"); } if (challenge.Length != 32) { throw new ArgumentException("Challenge should be 32 bytes"); } if (applicationId == null) { throw new ArgumentNullException("applicationId"); } var data = new byte[64 + 1 + keyHandle.Length]; Array.Copy(challenge, 0, data, 0, 32); Array.Copy(applicationId.GetBytes(true), 0, data, 32, 32); data[64] = (byte)keyHandle.Length; Array.Copy(keyHandle.GetBytes(true), 0, data, 65, keyHandle.Length); var result = await this.ExchangeApdu(INS_SIGN, 0x03, 0x00, data, cancellationToken).ConfigureAwait(false); return(new U2FAuthenticationResponse(result)); }
public async Task <U2FRegistrationResponse> RegisterAsync(byte[] challenge, AppId applicationId, CancellationToken cancellationToken = default(CancellationToken)) { if (challenge == null) { throw new ArgumentNullException("challenge"); } if (challenge.Length != 32) { throw new ArgumentException("Challenge should be 32 bytes"); } if (applicationId == null) { throw new ArgumentNullException("applicationId"); } var data = new byte[64]; Array.Copy(challenge, 0, data, 0, 32); Array.Copy(applicationId.GetBytes(true), 0, data, 32, 32); var result = await this.ExchangeApdu(INS_ENROLL, 0x03, 0x00, data, cancellationToken).ConfigureAwait(false); return(new U2FRegistrationResponse(result)); }
public U2FRegistrationResponse Register(byte[] challenge, AppId applicationId, CancellationToken cancellationToken = default(CancellationToken)) { if(challenge == null) throw new ArgumentNullException("challenge"); if(challenge.Length != 32) throw new ArgumentException("Challenge should be 32 bytes"); if(applicationId == null) throw new ArgumentNullException("applicationId"); var data = new byte[64]; Array.Copy(challenge, 0, data, 0, 32); Array.Copy(applicationId.GetBytes(true), 0, data, 32, 32); var result = this.ExchangeApdu(INS_ENROLL, 0x03, 0x00, data, cancellationToken); return new U2FRegistrationResponse(result); }
public U2FAuthenticationResponse Authenticate(byte[] challenge, AppId applicationId, KeyHandle keyHandle, CancellationToken cancellationToken = default(CancellationToken)) { if(challenge == null) throw new ArgumentNullException("challenge"); if(challenge.Length != 32) throw new ArgumentException("Challenge should be 32 bytes"); if(applicationId == null) throw new ArgumentNullException("applicationId"); var data = new byte[64 + 1 + keyHandle.Length]; Array.Copy(challenge, 0, data, 0, 32); Array.Copy(applicationId.GetBytes(true), 0, data, 32, 32); data[64] = (byte)keyHandle.Length; Array.Copy(keyHandle.GetBytes(true), 0, data, 65, keyHandle.Length); var result = this.ExchangeApdu(INS_SIGN, 0x03, 0x00, data, cancellationToken); return new U2FAuthenticationResponse(result); }