29.07.2013 Views

Master of Science thesis Fighting Spam

Master of Science thesis Fighting Spam

Master of Science thesis Fighting Spam

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

}<br />

public static boolean verify(RSAPublicKey pub, org.logi.crypto.sign.Signature signed,<br />

Object data) throws Exception<br />

{<br />

ByteArrayOutputStream byteStream = new ByteArrayOutputStream();<br />

ObjectOutputStream out = new ObjectOutputStream(byteStream);<br />

out.writeObject(data);<br />

byte[] temp = byteStream.toByteArray();<br />

}<br />

byteStream.close();<br />

out.close();<br />

return verify(pub, signed, Fingerprint.create(temp, 0, temp.length, "SHA1"));<br />

public static Fingerprint merge(Object obj, Fingerprint fp) throws Exception<br />

{<br />

ByteArrayOutputStream byteStream = new ByteArrayOutputStream();<br />

ObjectOutputStream out = new ObjectOutputStream(byteStream);<br />

out.writeObject(obj);<br />

byte[] hashed = fp.getBytes();<br />

byte[] hashedObj = SHA1(byteStream.toByteArray()).getBytes();<br />

byte[] result = new byte[hashed.length + hashedObj.length];<br />

}<br />

for(int i = 0; i < hashed.length; i++)<br />

{<br />

result[i] = hashed[i];<br />

}<br />

for(int i = 0; i < hashedObj.length; i++)<br />

{<br />

result[hashed.length + i] = hashedObj[i];<br />

}<br />

return Fingerprint.create(result, 0, result.length, "SHA1");<br />

private static void testBlindSign2() throws Exception<br />

{<br />

Certificate cert = FileHandler.importCertificate(new<br />

File(Config.BLSCertificateName));<br />

RSAPublicKey publ = (RSAPublicKey) cert.getPublicKey();<br />

RSAPrivateKey priv = (RSAPrivateKey) FileHandler.readObject(new<br />

File(Config.BLSPrivateKeyName));<br />

RSABlindingFactor bf = createBlindingFactor();<br />

Coin coin = new Coin(Config.coinValue, 122434, System.currentTimeMillis(),<br />

Config.maxNumberOfUsages, null, null);<br />

bf));<br />

}<br />

BlindedCoin bcoin = coin.getBlindedCoin(publ, bf, cert);<br />

Debugger.debug(className, 3, "Ok? " + coin.signAndVerify(publ, priv, cert, bcoin,<br />

private static void testBlindSign() throws Exception<br />

{<br />

//generateRSAkeys();<br />

RSAPublicKey publ = (RSAPublicKey) FileHandler.importCertificate(new<br />

File(Config.BLSCertificateName)).<br />

getPublicKey();<br />

RSAPrivateKey priv = (RSAPrivateKey) FileHandler.readObject(new<br />

File(Config.BLSPrivateKeyName));<br />

Coin ballot = new Coin(Config.coinValue, 122434, System.currentTimeMillis(),<br />

Config.maxNumberOfUsages, null, null);<br />

// byte[] ballot = coin;<br />

389

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!