01: package snow.crypto;
02:
03: import java.util.*;
04:
05: /** An identifier for a secret key.
06: */
07: public final class SecretKeyID {
08: public byte[] signature;
09: public int key_length;
10:
11: public SecretKeyID(byte[] signature, int key_length) {
12: this .signature = (signature != null ? signature.clone() : null);
13: this .key_length = key_length;
14: }
15:
16: public byte[] getKeySignature() {
17: if (signature == null)
18: return null;
19: // pass a copy
20: return signature.clone();
21: }
22:
23: public int getKeyLangth() {
24: return key_length;
25: }
26:
27: @Override
28: public boolean equals(Object o) {
29: if (!(o instanceof SecretKeyID)) {
30: System.out.println("Bad class, not SecretKeyID");
31: return false;
32: }
33: SecretKeyID k2 = (SecretKeyID) o;
34: if (k2.key_length != key_length) {
35: return false;
36: }
37: if (!Arrays.equals(k2.signature, signature)) {
38: return false;
39: }
40:
41: return true;
42: }
43:
44: @Override
45: public int hashCode() {
46: return signature[0] + 256 * signature[1];
47: }
48:
49: @Override
50: public String toString() {
51: return "l=" + this .key_length + ", sign={" + signature[0]
52: + ", " + signature[1] + ", " + signature[2] + ", "
53: + signature[3] + "}";
54: }
55:
56: }
|