blob: c56844d10273b9ef75900f25650c4a6d4edb0fb1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
#pragma once
#include "Packet.h"
class ServerAuthDataPacket : public Packet
{
#if 0
private String serverId;
private PublicKey publicKey;
private byte[] nonce = new byte[]{};
public ServerAuthDataPacket() {
// Needed
}
public ServerAuthDataPacket(final String serverId, final PublicKey publicKey, final byte[] nonce) {
this.serverId = serverId;
this.publicKey = publicKey;
this.nonce = nonce;
}
@Override
public void read(DataInputStream dis) throws IOException {
serverId = readUtf(dis, 20);
publicKey = Crypt.byteToPublicKey(readBytes(dis));
nonce = readBytes(dis);
}
@Override
public void write(DataOutputStream dos) throws IOException {
writeUtf(serverId, dos);
writeBytes(dos, publicKey.getEncoded());
writeBytes(dos, nonce);
}
@Override
public void handle(PacketListener listener) {
listener.handleServerAuthData(this);
}
@Override
public int getEstimatedSize() {
return 2 + serverId.length() * 2 + 2 + publicKey.getEncoded().length + 2 + nonce.length;
}
public String getServerId() {
return serverId;
}
public PublicKey getPublicKey() {
return publicKey;
}
public byte[] getNonce() {
return nonce;
}
#endif
};
|