public static CryptoKey read(InputStream i, DSAGroup g) throws IOException { return new DSAPrivateKey(Util.readMPI(i), g); }
@Override public byte[] fingerprint() { return fingerprint(new BigInteger[] {x}); }
public FreenetURI getInsertURI() { return new FreenetURI("SSK", docName, privKey.getX().toByteArray(), cryptoKey, getInsertExtraBytes()); }
public static DSAPrivateKey create(SimpleFieldSet fs, DSAGroup group) throws IllegalBase64Exception { BigInteger y = new BigInteger(1, Base64.decode(fs.get("x"))); if(y.bitLength() > 512) throw new IllegalBase64Exception("Probably a pubkey"); return new DSAPrivateKey(y, group); }
public DSAPublicKey(DSAGroup g, DSAPrivateKey p) { this(g, g.getG().modPow(p.getX(), g.getP())); }
public static ClientKSK create(String keyword) { MessageDigest md256 = SHA256.getMessageDigest(); try { byte[] keywordHash; try { keywordHash = md256.digest(keyword.getBytes("UTF-8")); } catch (UnsupportedEncodingException e) { throw new Error("Impossible: JVM doesn't support UTF-8: " + e, e); } MersenneTwister mt = new MersenneTwister(keywordHash); DSAPrivateKey privKey = new DSAPrivateKey(Global.DSAgroupBigA, mt); DSAPublicKey pubKey = new DSAPublicKey(Global.DSAgroupBigA, privKey); byte[] pubKeyHash = md256.digest(pubKey.asBytes()); try { return new ClientKSK(keyword, pubKeyHash, pubKey, privKey, keywordHash); } catch (MalformedURLException e) { throw new Error(e); } } finally { SHA256.returnMessageDigest(md256); } }
dsa.init(true, new DSAPrivateKeyParameters(privKey.getX(), Global.getDSAgroupBigAParameters())); BigInteger[] sig = dsa.generateSignature(Global.truncateHash(overallHash));
public static InsertableClientSSK createRandom(RandomSource r, String docName) { byte[] ckey = new byte[CRYPTO_KEY_LENGTH]; r.nextBytes(ckey); DSAGroup g = Global.DSAgroupBigA; DSAPrivateKey privKey = new DSAPrivateKey(g, r); DSAPublicKey pubKey = new DSAPublicKey(g, privKey); try { byte[] pkHash = SHA256.digest(pubKey.asBytes()); return new InsertableClientSSK(docName, pkHash, pubKey, privKey, ckey, Key.ALGO_AES_PCFB_256_SHA256); } catch (MalformedURLException e) { throw new Error(e); } }
DSAPrivateKey privKey; try { privKey = new DSAPrivateKey(new BigInteger(1, uri.getRoutingKey()), g); } catch(IllegalArgumentException e) {
public void testSimple() throws IOException { final int keys = 10; PubkeyStore pk = new PubkeyStore(); new RAMFreenetStore<DSAPublicKey>(pk, keys); DSAGroup group = Global.DSAgroupBigA; Random random = new MersenneTwister(1010101); HashMap<ByteArrayWrapper, DSAPublicKey> map = new HashMap<ByteArrayWrapper, DSAPublicKey>(); for(int i=0;i<keys;i++) { DSAPrivateKey privKey = new DSAPrivateKey(group, random); DSAPublicKey key = new DSAPublicKey(group, privKey); byte[] hash = key.asBytesHash(); ByteArrayWrapper w = new ByteArrayWrapper(hash); map.put(w, key.cloneKey()); pk.put(hash, key, false); assertTrue(pk.fetch(hash, false, false, null).equals(key)); } int x = 0; for(Map.Entry<ByteArrayWrapper, DSAPublicKey> entry : map.entrySet()) { x++; assertTrue(pk.fetch(entry.getKey().get(), false, false, null).equals(entry.getValue())); } assert(x == keys); }
public void testSimple() { final int keys = 10; PubkeyStore pk = new PubkeyStore(); new RAMFreenetStore<DSAPublicKey>(pk, keys); GetPubkey pubkeys = new SimpleGetPubkey(pk); DSAGroup group = Global.DSAgroupBigA; Random random = new MersenneTwister(1010101); HashMap<ByteArrayWrapper, DSAPublicKey> map = new HashMap<ByteArrayWrapper, DSAPublicKey>(); for(int i=0;i<keys;i++) { DSAPrivateKey privKey = new DSAPrivateKey(group, random); DSAPublicKey key = new DSAPublicKey(group, privKey); byte[] hash = key.asBytesHash(); ByteArrayWrapper w = new ByteArrayWrapper(hash); map.put(w, key.cloneKey()); pubkeys.cacheKey(hash, key, false, false, false, false, false); assertTrue(pubkeys.getKey(hash, false, false, null).equals(key)); } int x = 0; for(Map.Entry<ByteArrayWrapper, DSAPublicKey> entry : map.entrySet()) { x++; assertTrue(pubkeys.getKey(entry.getKey().get(), false, false, null).equals(entry.getValue())); } assert(x == keys); }
random.nextBytes(ckey); DSAGroup g = Global.DSAgroupBigA; DSAPrivateKey privKey = new DSAPrivateKey(g, random); DSAPublicKey pubKey = new DSAPublicKey(g, privKey); byte[] pkHash = SHA256.digest(pubKey.asBytes());
random.nextBytes(ckey); DSAGroup g = Global.DSAgroupBigA; DSAPrivateKey privKey = new DSAPrivateKey(g, random); DSAPublicKey pubKey = new DSAPublicKey(g, privKey); byte[] pkHash = SHA256.digest(pubKey.asBytes());
random.nextBytes(ckey); DSAGroup g = Global.DSAgroupBigA; DSAPrivateKey privKey = new DSAPrivateKey(g, random); DSAPublicKey pubKey = new DSAPublicKey(g, privKey); byte[] pkHash = SHA256.digest(pubKey.asBytes());
random.nextBytes(ckey); DSAGroup g = Global.DSAgroupBigA; DSAPrivateKey privKey = new DSAPrivateKey(g, random); DSAPublicKey pubKey = new DSAPublicKey(g, privKey); byte[] pkHash = SHA256.digest(pubKey.asBytes()); DSAPrivateKey privKey2 = new DSAPrivateKey(g, random); DSAPublicKey pubKey2 = new DSAPublicKey(g, privKey2); byte[] pkHash2 = SHA256.digest(pubKey2.asBytes());
random.nextBytes(ckey); DSAGroup g = Global.DSAgroupBigA; DSAPrivateKey privKey = new DSAPrivateKey(g, random); DSAPublicKey pubKey = new DSAPublicKey(g, privKey); byte[] pkHash = SHA256.digest(pubKey.asBytes());