Hello Again !
I did what you told me but it's not working :/
For now I got my function to set my publicKey wich will be use to encode the credentials,
setPublicKey (publicKey) {
publicKey = crypto.publicDecrypt(this._verifyKey, Buffer.from(publicKey));
this.publicKey = `-----BEGIN PUBLIC KEY-----\n${publicKey.toString('base64')}\n-----END PUBLIC KEY-----`;
}
Then I use this.publicKey to encode my credentials,
cipherRsa (username, password, certificate = null) {
const input = new ByteArray();
input.writeUTFBytes(this.salt);
input.writeBytes(this.AESKey);
// TODO
/*if (certificate) {
input.writeUnsignedInt(certificate.id);
input.writeUTFBytes(certificate.hash);
}*/
input.writeByte(username.length);
input.writeUTFBytes(username);
input.writeUTFBytes(password);
return crypto.publicEncrypt(this.publicKey, input.buffer);
}
It's working well, the problem Is, the credentials array It gives me contains number that are upper than 127. So when I arrive at my function to serialize the IdentificationMessage It throw me an Error when It tried to writeByte on credentials ...
I don't understand what I did wrong so If you or anyone could help me that would be great :)
Thanks you have a nice day !
[UPDATE]
I final got a response from the Server saying me,
{
"__type__": "IdentificationFailedMessage",
"reason": 2
}
So now i'm sure my serialize is working well !