@Override public ClientKey cloneKey() { return new ClientSSK(this); }
public ClientSSK getSSK(String string) { try { return new ClientSSK(string, pubKeyHash, ClientSSK.getExtraBytes(cryptoAlgorithm), null, cryptoKey); } catch (MalformedURLException e) { Logger.error(this, "Caught "+e+" should not be possible in USK.getSSK", e); throw new Error(e); } }
public USK(byte[] pubKeyHash, byte[] cryptoKey, byte[] extra, String siteName, long suggestedEdition) throws MalformedURLException { this.pubKeyHash = pubKeyHash; this.cryptoKey = cryptoKey; this.siteName = siteName; this.suggestedEdition = suggestedEdition; if(extra == null) throw new MalformedURLException("No extra bytes (third bit) in USK"); if(pubKeyHash == null) throw new MalformedURLException("No pubkey hash (first bit) in USK"); if(cryptoKey == null) throw new MalformedURLException("No crypto key (second bit) in USK"); // Verify extra bytes, get cryptoAlgorithm - FIXME this should be a static method or something? ClientSSK tmp = new ClientSSK(siteName, pubKeyHash, extra, null, cryptoKey); cryptoAlgorithm = tmp.cryptoAlgorithm; if(pubKeyHash.length != NodeSSK.PUBKEY_HASH_SIZE) throw new MalformedURLException("Pubkey hash wrong length: "+pubKeyHash.length+" should be "+NodeSSK.PUBKEY_HASH_SIZE); if(cryptoKey.length != ClientSSK.CRYPTO_KEY_LENGTH) throw new MalformedURLException("Decryption key wrong length: "+cryptoKey.length+" should be "+ClientSSK.CRYPTO_KEY_LENGTH); hashCode = Fields.hashCode(pubKeyHash) ^ Fields.hashCode(cryptoKey) ^ siteName.hashCode() ^ (int)suggestedEdition ^ (int)(suggestedEdition >> 32); }
public static BaseClientKey getBaseKey(FreenetURI origURI) throws MalformedURLException { String keyType = origURI.getKeyType(); if("CHK".equals(keyType)) return new ClientCHK(origURI); if("SSK".equals(keyType)) return new ClientSSK(origURI); if("KSK".equals(keyType)) return ClientKSK.create(origURI.getDocName()); if("USK".equals(keyType)) return USK.create(origURI); throw new MalformedURLException("Unknown keytype from "+origURI); }
ClientSSK ssk = new ClientSSK(uri); ark = new USK(ssk, arkNo); } else if(forDiffNodeRef && arkPubKey == null && myARK != null && arkNo > -1) {