protected final byte[] getExtraBytes() { return getExtraBytes(cryptoAlgorithm); }
@Override public FreenetURI getURI() { return new FreenetURI("SSK", docName, pubKeyHash, cryptoKey, getExtraBytes()); }
@Override public FreenetURI getURI() { return new FreenetURI(pubKeyHash, cryptoKey, ClientSSK.getExtraBytes(cryptoAlgorithm), siteName, suggestedEdition); }
public FreenetURI getBaseSSK() { return new FreenetURI("SSK", siteName, pubKeyHash, cryptoKey, ClientSSK.getExtraBytes(cryptoAlgorithm)); }
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 FreenetURI turnMySSKIntoUSK(FreenetURI uri) { if(uri.getKeyType().equals("SSK") && Arrays.equals(uri.getRoutingKey(), pubKeyHash) && Arrays.equals(uri.getCryptoKey(), cryptoKey) && Arrays.equals(uri.getExtra(), ClientSSK.getExtraBytes(cryptoAlgorithm)) && uri.getDocName() != null && uri.getDocName().startsWith(siteName)) { String doc = uri.getDocName(); doc = doc.substring(siteName.length()); if(doc.length() < 2 || doc.charAt(0) != '-') return uri; doc = doc.substring(1); long edition; try { edition = Long.parseLong(doc); } catch (NumberFormatException e) { Logger.normal(this, "Trying to turn SSK back into USK: "+uri+" doc="+doc+" caught "+e, e); return uri; } if(!doc.equals(Long.toString(edition))) return uri; return new FreenetURI("USK", siteName, uri.getAllMetaStrings(), pubKeyHash, cryptoKey, ClientSSK.getExtraBytes(cryptoAlgorithm), edition); } return uri; }
if(cryptoAlgorithm != Key.ALGO_AES_PCFB_256_SHA256) throw new MalformedURLException("Unknown encryption algorithm "+cryptoAlgorithm); if(!Arrays.equals(extras, getExtraBytes())) throw new MalformedURLException("Wrong extra bytes"); if(pubKeyHash.length != NodeSSK.PUBKEY_HASH_SIZE)