use of org.gudy.bouncycastle.crypto.CipherParameters in project BiglyBT by BiglySoftware.
the class CryptoManagerImpl method obfuscate.
@Override
public byte[] obfuscate(byte[] data) {
RC4Engine engine = new RC4Engine();
CipherParameters params = new KeyParameter(new SHA1Simple().calculateHash(getOBSID()));
engine.init(true, params);
byte[] temp = new byte[1024];
engine.processBytes(temp, 0, 1024, temp, 0);
final byte[] obs_value = new byte[data.length];
engine.processBytes(data, 0, data.length, obs_value, 0);
return (obs_value);
}
use of org.gudy.bouncycastle.crypto.CipherParameters in project BiglyBT by BiglySoftware.
the class JDKDSASigner method engineInitVerify.
@Override
protected void engineInitVerify(PublicKey publicKey) throws InvalidKeyException {
CipherParameters param = null;
if (publicKey instanceof ECKey) {
param = ECUtil.generatePublicKeyParameter(publicKey);
} else if (publicKey instanceof DSAKey) {
param = DSAUtil.generatePublicKeyParameter(publicKey);
} else {
try {
/*
byte[] bytes = publicKey.getEncoded();
publicKey = JDKKeyFactory.createPublicKeyFromDERStream(
new ByteArrayInputStream(bytes));
if (publicKey instanceof ECKey)
{
param = ECUtil.generatePublicKeyParameter(publicKey);
}
else if (publicKey instanceof DSAKey)
{
param = DSAUtil.generatePublicKeyParameter(publicKey);
}
else
{
*/
throw new InvalidKeyException("can't recognise key type in DSA based signer");
// }
} catch (Exception e) {
throw new InvalidKeyException("can't recognise key type in DSA based signer");
}
}
digest.reset();
signer.init(false, param);
}
use of org.gudy.bouncycastle.crypto.CipherParameters in project BiglyBT by BiglySoftware.
the class UDPConnectionSet method getCipher.
private RC4Engine getCipher(byte[] key) {
SecretKeySpec secret_key_spec = new SecretKeySpec(key, "RC4");
RC4Engine rc4_engine = new RC4Engine();
CipherParameters params_a = new KeyParameter(secret_key_spec.getEncoded());
// for RC4 enc/dec is irrelevant
rc4_engine.init(true, params_a);
// skip first 1024 bytes of stream to protected against a Fluhrer, Mantin and Shamir attack
byte[] temp = new byte[1024];
rc4_engine.processBytes(temp, 0, temp.length, temp, 0);
return (rc4_engine);
}
use of org.gudy.bouncycastle.crypto.CipherParameters in project BiglyBT by BiglySoftware.
the class JCEECDHKeyAgreement method engineDoPhase.
@Override
protected Key engineDoPhase(Key key, boolean lastPhase) throws InvalidKeyException, IllegalStateException {
if (privKey == null) {
throw new IllegalStateException("EC Diffie-Hellman not initialised.");
}
if (!lastPhase) {
throw new IllegalStateException("EC Diffie-Hellman can only be between two parties.");
}
if (!(key instanceof ECPublicKey)) {
throw new InvalidKeyException("EC Key Agreement doPhase requires ECPublicKey");
}
CipherParameters pubKey = ECUtil.generatePublicKeyParameter((PublicKey) key);
result = agreement.calculateAgreement(pubKey);
return null;
}
use of org.gudy.bouncycastle.crypto.CipherParameters in project BiglyBT by BiglySoftware.
the class JDKDigestSignature method engineInitVerify.
@Override
protected void engineInitVerify(PublicKey publicKey) throws InvalidKeyException {
if (!(publicKey instanceof RSAPublicKey)) {
throw new InvalidKeyException("Supplied key is not a RSAPublicKey instance");
}
CipherParameters param = RSAUtil.generatePublicKeyParameter((RSAPublicKey) publicKey);
digest.reset();
cipher.init(false, param);
}
Aggregations