1 package snow.crypto; 2 3 4 import java.util.*; 5 6 8 public final class SecretKeyID 9 { 10 public byte[] signature; 11 public int key_length; 12 13 public SecretKeyID (byte[] signature, int key_length) 14 { 15 this.signature = (signature!=null ? signature.clone() : null); 16 this.key_length = key_length; 17 } 18 19 public byte[] getKeySignature() 20 { 21 if(signature==null) return null; 22 return signature.clone(); 24 } 25 26 public int getKeyLangth() { return key_length; } 27 28 public boolean equals(Object o) 29 { 30 if(!(o instanceof SecretKeyID)) 31 { 32 System.out.println("Bad class, not SecretKeyID"); 33 return false; 34 } 35 SecretKeyID k2 = (SecretKeyID) o; 36 if(k2.key_length != key_length) 37 { 38 return false; 39 } 40 if(!Arrays.equals( k2.signature, signature)) 41 { 42 return false; 43 } 44 45 return true; 46 } 47 48 public int hashCode() 49 { 50 return signature[0]+256*signature[1]; 51 } 52 53 54 55 public String toString() 56 { 57 return "l="+this.key_length+", sign={" + signature[0]+", "+signature[1] 58 +", "+signature[2]+", "+signature[3] + "}"; 59 } 60 61 } | Popular Tags |