/** * @param name A name chosen by the user who created the directory entry * @param destination */ public Contact(String name, EmailDestination destination) { this.name = name; this.destination = destination; nameHash = EmailIdentity.calculateHash(name); }
public void setName(String name) { this.name = name; nameHash = EmailIdentity.calculateHash(name); }
/** Finds a salt value such that scrypt(nameHash|destination, salt) ends with 10 zero bits */ public static Fingerprint generate(EmailIdentity identity) throws GeneralSecurityException { Hash nameHash = EmailIdentity.calculateHash(identity.getPublicName()); return generate(nameHash, identity); }
/** * Creates a new <code>Contact</code>. Calculates a salt value which takes some time; * also creates a signature. * * @param identity The email identity associated with the name * @param keyUpdateHandler For signing the packet * @param picture A browser-renderable picture * @param text * @param fingerprint * @throws GeneralSecurityException * @throws PasswordException */ public Contact(EmailIdentity identity, KeyUpdateHandler keyUpdateHandler, byte[] picture, String text, Fingerprint fingerprint) throws GeneralSecurityException, PasswordException { destination = identity; this.picture = picture; this.text = text; this.fingerprint = fingerprint; nameHash = EmailIdentity.calculateHash(identity.getPublicName()); sign(identity, keyUpdateHandler); }
/** Finds a salt value such that scrypt(nameHash|destination, salt) ends with 10 zero bits */ public static Fingerprint generate(Contact contact) throws GeneralSecurityException { EmailDestination destination = contact.getDestination(); Hash nameHash = EmailIdentity.calculateHash(contact.getName()); return generate(nameHash, destination); }
public Contact lookupInDirectory(String name) throws InterruptedException { Hash key = EmailIdentity.calculateHash(name); if(null == dht){ return null; } DhtResults results = dht.findOne(key, Contact.class); if (!results.isEmpty()) { DhtStorablePacket packet = results.getPackets().iterator().next(); if (packet instanceof Contact) { Contact contact = (Contact)packet; try { if (contact.verify()) return contact; } catch (GeneralSecurityException e) { log.error("Can't verify Contact", e); } } } return null; }
String salt = properties.getProperty(prefix + PREF_SALT); if (salt != null) { Hash nameHash = EmailIdentity.calculateHash(name); Fingerprint fingerprint = new Fingerprint(nameHash, identity, Base64.decode(salt.toCharArray())); identity.setFingerprint(fingerprint);