Here are the examples of the java api class com.google.bitcoin.bouncycastle.crypto.CipherParameters taken from open source projects.
1. PSSSigner#init()
Project: bitcoin-android
File: PSSSigner.java
File: PSSSigner.java
public void init(boolean forSigning, CipherParameters param) { CipherParameters params; if (param instanceof ParametersWithRandom) { ParametersWithRandom p = (ParametersWithRandom) param; params = p.getParameters(); random = p.getRandom(); } else { params = param; if (forSigning) { random = new SecureRandom(); } } cipher.init(forSigning, params); RSAKeyParameters kParam; if (params instanceof RSABlindingParameters) { kParam = ((RSABlindingParameters) params).getPublicKey(); } else { kParam = (RSAKeyParameters) params; } emBits = kParam.getModulus().bitLength() - 1; if (emBits < (8 * hLen + 8 * sLen + 9)) { throw new IllegalArgumentException("key too small for specified hash and salt lengths"); } block = new byte[(emBits + 7) / 8]; reset(); }
2. EAXBlockCipher#init()
Project: bitcoin-android
File: EAXBlockCipher.java
File: EAXBlockCipher.java
public void init(boolean forEncryption, CipherParameters params) throws IllegalArgumentException { this.forEncryption = forEncryption; byte[] nonce, associatedText; CipherParameters keyParam; if (params instanceof AEADParameters) { AEADParameters param = (AEADParameters) params; nonce = param.getNonce(); associatedText = param.getAssociatedText(); macSize = param.getMacSize() / 8; keyParam = param.getKey(); } else if (params instanceof ParametersWithIV) { ParametersWithIV param = (ParametersWithIV) params; nonce = param.getIV(); associatedText = new byte[0]; macSize = mac.getMacSize() / 2; keyParam = param.getParameters(); } else { throw new IllegalArgumentException("invalid parameters passed to EAX"); } byte[] tag = new byte[blockSize]; mac.init(keyParam); tag[blockSize - 1] = hTAG; mac.update(tag, 0, blockSize); mac.update(associatedText, 0, associatedText.length); mac.doFinal(associatedTextMac, 0); tag[blockSize - 1] = nTAG; mac.update(tag, 0, blockSize); mac.update(nonce, 0, nonce.length); mac.doFinal(nonceMac, 0); tag[blockSize - 1] = cTAG; mac.update(tag, 0, blockSize); cipher.init(true, new ParametersWithIV(keyParam, nonceMac)); }
3. PKCS5S2ParametersGenerator#F()
Project: bitcoin-android
File: PKCS5S2ParametersGenerator.java
File: PKCS5S2ParametersGenerator.java
private void F(byte[] P, byte[] S, int c, byte[] iBuf, byte[] out, int outOff) { byte[] state = new byte[hMac.getMacSize()]; CipherParameters param = new KeyParameter(P); hMac.init(param); if (S != null) { hMac.update(S, 0, S.length); } hMac.update(iBuf, 0, iBuf.length); hMac.doFinal(state, 0); System.arraycopy(state, 0, out, outOff, state.length); if (c == 0) { throw new IllegalArgumentException("iteration count must be at least 1."); } for (int count = 1; count < c; count++) { hMac.init(param); hMac.update(state, 0, state.length); hMac.doFinal(state, 0); for (int j = 0; j != state.length; j++) { out[outOff + j] ^= state[j]; } } }
4. HC256Engine#init()
Project: bitcoin-android
File: HC256Engine.java
File: HC256Engine.java
/** * Initialise a HC-256 cipher. * * @param forEncryption whether or not we are for encryption. Irrelevant, as * encryption and decryption are the same. * @param params the parameters required to set up the cipher. * @throws IllegalArgumentException if the params argument is * inappropriate (ie. the key is not 256 bit long). */ public void init(boolean forEncryption, CipherParameters params) throws IllegalArgumentException { CipherParameters keyParam = params; if (params instanceof ParametersWithIV) { iv = ((ParametersWithIV) params).getIV(); keyParam = ((ParametersWithIV) params).getParameters(); } else { iv = new byte[0]; } if (keyParam instanceof KeyParameter) { key = ((KeyParameter) keyParam).getKey(); init(); } else { throw new IllegalArgumentException("Invalid parameter passed to HC256 init - " + params.getClass().getName()); } initialised = true; }
5. HC128Engine#init()
Project: bitcoin-android
File: HC128Engine.java
File: HC128Engine.java
/** * Initialise a HC-128 cipher. * * @param forEncryption whether or not we are for encryption. Irrelevant, as * encryption and decryption are the same. * @param params the parameters required to set up the cipher. * @throws IllegalArgumentException if the params argument is * inappropriate (ie. the key is not 128 bit long). */ public void init(boolean forEncryption, CipherParameters params) throws IllegalArgumentException { CipherParameters keyParam = params; if (params instanceof ParametersWithIV) { iv = ((ParametersWithIV) params).getIV(); keyParam = ((ParametersWithIV) params).getParameters(); } else { iv = new byte[0]; } if (keyParam instanceof KeyParameter) { key = ((KeyParameter) keyParam).getKey(); init(); } else { throw new IllegalArgumentException("Invalid parameter passed to HC128 init - " + params.getClass().getName()); } initialised = true; }