public void init(boolean forEncryption, CipherParameters params) { if (!(params instanceof KeyParameter)) { throw new IllegalArgumentException("only simple KeyParameter expected."); } setKey(forEncryption, ((KeyParameter)params).getKey()); initialized = true; }
public void init(boolean forEncryption, CipherParameters params) throws IllegalArgumentException { if (!(params instanceof KeyParameter)) { throw new IllegalArgumentException( "invalid parameter passed to ARIA init - " + params.getClass().getName()); } //this.forEncryption = forEncryption; this.roundKeys = keySchedule(forEncryption, ((KeyParameter)params).getKey()); }
public GenericKey getKey() { return new GenericKey(algorithmIdentifier, encKey.getKey()); } }
public void init(boolean _forEncryption, CipherParameters params) throws IllegalArgumentException { if (!(params instanceof KeyParameter)) { throw new IllegalArgumentException("only simple KeyParameter expected."); } this.forEncryption = _forEncryption; workingKey = new int[64]; setKey( ((KeyParameter)params).getKey() ); }
public void init(boolean forEncryption, CipherParameters params) throws IllegalArgumentException { if (!(params instanceof KeyParameter)) { throw new IllegalArgumentException("only simple KeyParameter expected."); } setKey(forEncryption, ((KeyParameter)params).getKey()); initialised = true; }
public void init(boolean forEncryption, CipherParameters params) throws IllegalArgumentException { this.forEncryption = forEncryption; wKey = createWorkingKey(((KeyParameter)params).getKey()); }
public GenericKey getKey() { return new GenericKey(algorithmIdentifier, encKey.getKey()); } }
public void init(boolean forEncryption, CipherParameters params) { if (!(params instanceof KeyParameter)) { throw new IllegalArgumentException("only simple KeyParameter expected."); } setKey(forEncryption, ((KeyParameter)params).getKey()); initialized = true; }
public void init(CipherParameters params) { secret = Arrays.clone(((KeyParameter)params).getKey()); reset(); }
public void init(CipherParameters params) { secret = Arrays.clone(((KeyParameter)params).getKey()); reset(); }
public static byte[] stringToKey(String string, int iterations) throws UnsupportedEncodingException { byte[] salt = new String("salt").getBytes("utf-8"); PBEParametersGenerator generator = new PKCS5S2ParametersGenerator(); generator.init(PBEParametersGenerator.PKCS5PasswordToUTF8Bytes(string.toString().toCharArray()), salt, iterations); KeyParameter keyParam = (KeyParameter) generator.generateDerivedParameters(KEY_BIT_LEN); return keyParam.getKey(); } }
private static byte[] SingleIterationPBKDF2(byte[] P, byte[] S, int dkLen) { PBEParametersGenerator pGen = new PKCS5S2ParametersGenerator(new SHA256Digest()); pGen.init(P, S, 1); KeyParameter key = (KeyParameter) pGen.generateDerivedMacParameters(dkLen * 8); return key.getKey(); }
private static byte[] SingleIterationPBKDF2(byte[] P, byte[] S, int dkLen) { PBEParametersGenerator pGen = new PKCS5S2ParametersGenerator(new SHA256Digest()); pGen.init(P, S, 1); KeyParameter key = (KeyParameter) pGen.generateDerivedMacParameters(dkLen * 8); return key.getKey(); }
private static byte[] singleIterationPBKDF2(byte[] P, byte[] S, int dkLen) { PBEParametersGenerator pGen = new PKCS5S2ParametersGenerator(new SHA256Digest()); pGen.init(P, S, 1); KeyParameter key = (KeyParameter) pGen.generateDerivedMacParameters(dkLen * 8); return key.getKey(); }
@Override public byte[] hash(char[] chars, byte[] salt) { PKCS5S2ParametersGenerator generator = new PKCS5S2ParametersGenerator(new SHA512Digest()); generator.init(PBEParametersGenerator.PKCS5PasswordToUTF8Bytes(chars), salt, 2048); KeyParameter key = (KeyParameter) generator.generateDerivedMacParameters(512); return key.getKey(); } }
@Override public byte[] hash(char[] chars, byte[] salt) { PKCS5S2ParametersGenerator generator = new PKCS5S2ParametersGenerator(new SHA512Digest()); generator.init(PBEParametersGenerator.PKCS5PasswordToUTF8Bytes(chars), salt, 2048); KeyParameter key = (KeyParameter) generator.generateDerivedMacParameters(512); return key.getKey(); } }
@Override public byte[] hash(char[] chars, byte[] salt) { PKCS5S2ParametersGenerator generator = new PKCS5S2ParametersGenerator(new SHA512Digest()); generator.init(PBEParametersGenerator.PKCS5PasswordToUTF8Bytes(chars), salt, 2048); KeyParameter key = (KeyParameter) generator.generateDerivedMacParameters(512); return key.getKey(); } }
protected byte[] calculateDerivedKey(int schemeID, AlgorithmIdentifier derivationAlgorithm, int keySize) throws CMSException { PBKDF2Params params = PBKDF2Params.getInstance(derivationAlgorithm.getParameters()); byte[] encodedPassword = (schemeID == PasswordRecipient.PKCS5_SCHEME2) ? PBEParametersGenerator.PKCS5PasswordToBytes(password) : PBEParametersGenerator.PKCS5PasswordToUTF8Bytes(password); PKCS5S2ParametersGenerator gen = new PKCS5S2ParametersGenerator(); gen.init(encodedPassword, params.getSalt(), params.getIterationCount().intValue()); return ((KeyParameter)gen.generateDerivedParameters(keySize)).getKey(); }
public byte[] calculateDerivedKey(int schemeID, AlgorithmIdentifier derivationAlgorithm, int keySize) throws CMSException { PBKDF2Params params = PBKDF2Params.getInstance(derivationAlgorithm.getParameters()); byte[] encodedPassword = (schemeID == PasswordRecipient.PKCS5_SCHEME2) ? PBEParametersGenerator.PKCS5PasswordToBytes(password) : PBEParametersGenerator.PKCS5PasswordToUTF8Bytes(password); PKCS5S2ParametersGenerator gen = new PKCS5S2ParametersGenerator(); gen.init(encodedPassword, params.getSalt(), params.getIterationCount().intValue()); return ((KeyParameter)gen.generateDerivedParameters(keySize)).getKey(); }
public byte[] generateEncryptedBytes(AlgorithmIdentifier keyEncryptionAlgorithm, byte[] derivedKey, GenericKey contentEncryptionKey) throws CMSException { byte[] contentEncryptionKeySpec = ((KeyParameter)CMSUtils.getBcKey(contentEncryptionKey)).getKey(); Wrapper keyEncryptionCipher = EnvelopedDataHelper.createRFC3211Wrapper(keyEncryptionAlgorithm.getAlgorithm()); keyEncryptionCipher.init(true, new ParametersWithIV(new KeyParameter(derivedKey), ASN1OctetString.getInstance(keyEncryptionAlgorithm.getParameters()).getOctets())); return keyEncryptionCipher.wrap(contentEncryptionKeySpec, 0, contentEncryptionKeySpec.length); } }