@Override public SSKBlock construct(byte[] data, byte[] headers, byte[] routingKey, byte[] fullKey, boolean canReadClientCache, boolean canReadSlashdotCache, BlockMetadata meta, DSAPublicKey knownPublicKey) throws SSKVerifyException { if(data == null || headers == null) throw new SSKVerifyException("Need data and headers"); if(fullKey == null) throw new SSKVerifyException("Need full key to reconstruct an SSK"); NodeSSK key; key = NodeSSK.construct(fullKey); if(knownPublicKey != null) key.setPubKey(knownPublicKey); else if(!key.grabPubkey(pubkeyCache, canReadClientCache, canReadSlashdotCache, meta)) throw new SSKVerifyException("No pubkey found"); SSKBlock block = new SSKBlock(data, headers, key, false); return block; }
Logger.minor(this, "Fetched pubkey: " + pubKey); try { sskKey.setPubKey(pubKey); } catch (SSKVerifyException e) { Logger.error(this, "Error setting pubkey: " + e, e);
/** @return True unless the pubkey is broken and we should try another node */ private boolean handleSSKPubKey(Message msg, PeerNode next) { if(logMINOR) Logger.minor(this, "Got pubkey on "+uid); byte[] pubkeyAsBytes = ((ShortBuffer)msg.getObject(DMT.PUBKEY_AS_BYTES)).getData(); try { if(pubKey == null) pubKey = DSAPublicKey.create(pubkeyAsBytes); ((NodeSSK)key).setPubKey(pubKey); return true; } catch (SSKVerifyException e) { pubKey = null; Logger.error(this, "Invalid pubkey from "+source+" on "+uid+" ("+e.getMessage()+ ')', e); int t = timeSinceSent(); node.failureTable.onFailed(key, next, htl, t, t); next.noLongerRoutingTo(origTag, false); return false; // try next node } catch (CryptFormatException e) { Logger.error(this, "Invalid pubkey from "+source+" on "+uid+" ("+e+ ')'); int t = timeSinceSent(); node.failureTable.onFailed(key, next, htl, t, t); next.noLongerRoutingTo(origTag, false); return false; // try next node } }
((NodeSSK)key).setPubKey(pubKey); } catch (SSKVerifyException e) { Logger.error(this, "Bogus SSK data from "+pn+" for offer for "+key+" : "+e, e);
key.setPubKey(pubKey); block = new SSKBlock(data, headers, key, false); } catch (SSKVerifyException e1) {