GetBytes() public method

public GetBytes ( bool @unsafe = false ) : byte[]
@unsafe bool
return byte[]
コード例 #1
0
        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));
        }
コード例 #2
0
        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);
        }