|
1 package net.java.otr4j.io.messages; |
|
2 |
|
3 import java.util.Arrays; |
|
4 |
|
5 import javax.crypto.interfaces.DHPublicKey; |
|
6 |
|
7 public class MysteriousT { |
|
8 // Fields. |
|
9 public int protocolVersion; |
|
10 public int messageType; |
|
11 public int flags; |
|
12 public int senderKeyID; |
|
13 public int recipientKeyID; |
|
14 public DHPublicKey nextDH; |
|
15 public byte[] ctr; |
|
16 public byte[] encryptedMessage; |
|
17 |
|
18 // Ctor. |
|
19 public MysteriousT(int protocolVersion, int flags, int senderKeyID, |
|
20 int recipientKeyID, DHPublicKey nextDH, byte[] ctr, |
|
21 byte[] encryptedMessage) { |
|
22 |
|
23 this.protocolVersion = protocolVersion; |
|
24 this.messageType = AbstractEncodedMessage.MESSAGE_DATA; |
|
25 this.flags = flags; |
|
26 this.senderKeyID = senderKeyID; |
|
27 this.recipientKeyID = recipientKeyID; |
|
28 this.nextDH = nextDH; |
|
29 this.ctr = ctr; |
|
30 this.encryptedMessage = encryptedMessage; |
|
31 } |
|
32 |
|
33 // Methods. |
|
34 @Override |
|
35 public int hashCode() { |
|
36 // TODO: Needs work. |
|
37 final int prime = 31; |
|
38 int result = 1; |
|
39 result = prime * result + Arrays.hashCode(ctr); |
|
40 result = prime * result + Arrays.hashCode(encryptedMessage); |
|
41 result = prime * result + flags; |
|
42 result = prime * result + messageType; |
|
43 result = prime * result + ((nextDH == null) ? 0 : nextDH.hashCode()); |
|
44 result = prime * result + protocolVersion; |
|
45 result = prime * result + recipientKeyID; |
|
46 result = prime * result + senderKeyID; |
|
47 return result; |
|
48 } |
|
49 |
|
50 @Override |
|
51 public boolean equals(Object obj) { |
|
52 // TODO: Needs work. |
|
53 if (this == obj) |
|
54 return true; |
|
55 if (obj == null) |
|
56 return false; |
|
57 if (getClass() != obj.getClass()) |
|
58 return false; |
|
59 MysteriousT other = (MysteriousT) obj; |
|
60 if (!Arrays.equals(ctr, other.ctr)) |
|
61 return false; |
|
62 if (!Arrays.equals(encryptedMessage, other.encryptedMessage)) |
|
63 return false; |
|
64 if (flags != other.flags) |
|
65 return false; |
|
66 if (messageType != other.messageType) |
|
67 return false; |
|
68 if (nextDH == null) { |
|
69 if (other.nextDH != null) |
|
70 return false; |
|
71 } else if (!nextDH.equals(other.nextDH)) |
|
72 return false; |
|
73 if (protocolVersion != other.protocolVersion) |
|
74 return false; |
|
75 if (recipientKeyID != other.recipientKeyID) |
|
76 return false; |
|
77 if (senderKeyID != other.senderKeyID) |
|
78 return false; |
|
79 return true; |
|
80 } |
|
81 |
|
82 } |