public boolean samePubKeyHash(NodeSSK k) { return Arrays.equals(k.getPubKeyHash(), pubKeyHash); } }
SSKInsertHandler(NodeSSK key, byte[] data, byte[] headers, short htl, PeerNode source, long id, Node node, long startTime, InsertTag tag, boolean canWriteDatastore, boolean forkOnCacheable, boolean preferInsert, boolean ignoreLowBackoff, boolean realTimeFlag) { this.node = node; this.uid = id; this.source = source; this.startTime = startTime; this.key = key; this.htl = htl; this.data = data; this.headers = headers; this.tag = tag; this.canWriteDatastore = canWriteDatastore; byte[] pubKeyHash = key.getPubKeyHash(); pubKey = node.getPubKey.getKey(pubKeyHash, false, false, null); canCommit = false; logMINOR = Logger.shouldLog(LogLevel.MINOR, this); this.forkOnCacheable = forkOnCacheable; this.preferInsert = preferInsert; this.ignoreLowBackoff = ignoreLowBackoff; this.realTimeFlag = realTimeFlag; }
/** * Fetch or create an SSKInsertSender for a given key/htl. * @param key The key to be inserted. * @param htl The current HTL. We can't coalesce inserts across * HTL's. * @param uid The UID of the caller's request chain, or a new * one. This is obviously not used if there is already an * SSKInsertSender running. * @param source The node that sent the InsertRequest, or null * if it originated locally. * @param ignoreLowBackoff * @param preferInsert */ public SSKInsertSender makeInsertSender(SSKBlock block, short htl, long uid, InsertTag tag, PeerNode source, boolean fromStore, boolean canWriteClientCache, boolean canWriteDatastore, boolean forkOnCacheable, boolean preferInsert, boolean ignoreLowBackoff, boolean realTimeFlag) { NodeSSK key = block.getKey(); if(key.getPubKey() == null) { throw new IllegalArgumentException("No pub key when inserting"); } getPubKey.cacheKey(key.getPubKeyHash(), key.getPubKey(), false, canWriteClientCache, canWriteDatastore, false, writeLocalToDatastore); Logger.minor(this, "makeInsertSender("+key+ ',' +htl+ ',' +uid+ ',' +source+",...,"+fromStore); SSKInsertSender is = null; is = new SSKInsertSender(block, uid, tag, htl, source, this, fromStore, canWriteClientCache, forkOnCacheable, preferInsert, ignoreLowBackoff, realTimeFlag); is.start(); return is; }
DSAPublicKey pubKey = sskKey.getPubKey(); if (pubKey == null) { pubKey = getPubKey.getKey(sskKey.getPubKeyHash(), canReadClientCache, offersOnly, null); if (logMINOR) Logger.minor(this, "Fetched pubkey: " + pubKey);
getPubKey.cacheKey((block.getKey()).getPubKeyHash(), (block.getKey()).getPubKey(), deep, canWriteClientCache, canWriteDatastore, forULPR || useSlashdotCache, writeLocalToDatastore); if(canWriteClientCache) { sskClientcache.put(block, overwrite, false);
SSKBlock sskBlock = (SSKBlock) block.getBlock(); store.put(sskBlock, false, false); pubkeyCache.cacheKey(sskBlock.getKey().getPubKeyHash(), sskBlock.getKey().getPubKey(), false, false, false, false, false); tests.add(test); sskBlocks.add(block);
SSKBlock sskBlock = (SSKBlock) block.getBlock(); store.put(sskBlock, false, false); pubkeyCache.cacheKey(sskBlock.getKey().getPubKeyHash(), sskBlock.getKey().getPubKey(), false, false, false, false, false); tests.add(test); sskBlocks.add(block);
public void testSimpleSSK() throws IOException, KeyCollisionException, SSKVerifyException, KeyDecodeException, SSKEncodeException, InvalidCompressionCodecException { File f = new File(tempDir, "saltstore"); FileUtil.removeAll(f); final int keys = 5; PubkeyStore pk = new PubkeyStore(); new RAMFreenetStore<DSAPublicKey>(pk, keys); GetPubkey pubkeyCache = new SimpleGetPubkey(pk); SSKStore store = new SSKStore(pubkeyCache); SaltedHashFreenetStore<SSKBlock> saltStore = SaltedHashFreenetStore.construct(f, "testSaltedHashFreenetStoreSSK", store, weakPRNG, 20, false, SemiOrderedShutdownHook.get(), true, true, ticker, null); saltStore.start(null, true); RandomSource random = new DummyRandomSource(12345); for(int i=0;i<5;i++) { String test = "test" + i; ClientSSKBlock block = encodeBlockSSK(test, random); SSKBlock sskBlock = (SSKBlock) block.getBlock(); store.put(sskBlock, false, false); ClientSSK key = block.getClientKey(); NodeSSK ssk = (NodeSSK) key.getNodeKey(); pubkeyCache.cacheKey(ssk.getPubKeyHash(), ssk.getPubKey(), false, false, false, false, false); SSKBlock verify = store.fetch(ssk, false, false, false, false, null); String data = decodeBlockSSK(verify, key); assertEquals(test, data); } saltStore.close(); }
ClientSSKBlock block = ik.encode(bucket, false, false, (short)-1, bucket.size(), random, Compressor.DEFAULT_COMPRESSORDESCRIPTOR, false); SSKBlock sskBlock = (SSKBlock) block.getBlock(); pubkeyCache.cacheKey(sskBlock.getKey().getPubKeyHash(), sskBlock.getPubKey(), false, false, false, false, false); try { store.put(sskBlock, false, false);
ClientSSK key = block.getClientKey(); NodeSSK ssk = (NodeSSK) key.getNodeKey(); pubkeyCache.cacheKey(ssk.getPubKeyHash(), ssk.getPubKey(), false, false, false, false, false);
ClientSSKBlock block = ik.encode(bucket, false, false, (short)-1, bucket.size(), random, Compressor.DEFAULT_COMPRESSORDESCRIPTOR, false); SSKBlock sskBlock = (SSKBlock) block.getBlock(); pubkeyCache.cacheKey(sskBlock.getKey().getPubKeyHash(), sskBlock.getPubKey(), false, false, false, false, false); try { store.put(sskBlock, false, false);
ClientSSKBlock block = ik.encode(bucket, false, false, (short)-1, bucket.size(), random, Compressor.DEFAULT_COMPRESSORDESCRIPTOR, false); SSKBlock sskBlock = (SSKBlock) block.getBlock(); pubkeyCache.cacheKey(sskBlock.getKey().getPubKeyHash(), sskBlock.getPubKey(), false, false, false, false, false); try { store.put(sskBlock, false, false); block = ik2.encode(bucket, false, false, (short)-1, bucket.size(), random, Compressor.DEFAULT_COMPRESSORDESCRIPTOR, false); SSKBlock sskBlock2 = (SSKBlock) block.getBlock(); pubkeyCache.cacheKey(sskBlock2.getKey().getPubKeyHash(), sskBlock2.getPubKey(), false, false, false, false, false);
pubkeyCache.cacheKey(sskBlock.getKey().getPubKeyHash(), sskBlock.getKey().getPubKey(), false, false, false, false, false);
pubkeyCache.cacheKey(sskBlock.getKey().getPubKeyHash(), sskBlock.getKey().getPubKey(), false, false, false, false, false); NodeSSK ssk = (NodeSSK) key.getNodeKey(); SSKBlock verify = store.fetch(ssk, false, false, false, false, null);