use of com.google.u2f.key.messages.AuthenticateRequest in project OpenUnison by TremoloSecurity.
the class RawMessageCodec method decodeAuthenticateRequest.
public static AuthenticateRequest decodeAuthenticateRequest(byte[] data) throws U2FException {
try {
DataInputStream inputStream = new DataInputStream(new ByteArrayInputStream(data));
byte controlByte = inputStream.readByte();
byte[] challengeSha256 = new byte[32];
inputStream.readFully(challengeSha256);
byte[] appIdSha256 = new byte[32];
inputStream.readFully(appIdSha256);
byte[] keyHandle = new byte[inputStream.readUnsignedByte()];
inputStream.readFully(keyHandle);
if (inputStream.available() != 0) {
throw new U2FException("Message ends with unexpected data");
}
return new AuthenticateRequest(controlByte, challengeSha256, appIdSha256, keyHandle);
} catch (IOException e) {
throw new U2FException("Error when parsing raw AuthenticateRequest", e);
}
}
Aggregations