01: package org.bouncycastle.cms;
02:
03: import org.bouncycastle.crypto.PBEParametersGenerator;
04: import org.bouncycastle.crypto.generators.PKCS5S2ParametersGenerator;
05: import org.bouncycastle.crypto.params.KeyParameter;
06:
07: public class PKCS5Scheme2PBEKey extends CMSPBEKey {
08: public PKCS5Scheme2PBEKey(char[] password, byte[] salt,
09: int iterationCount) {
10: super (password, salt, iterationCount);
11: }
12:
13: byte[] getEncoded(String algorithmOid) {
14: PKCS5S2ParametersGenerator gen = new PKCS5S2ParametersGenerator();
15:
16: gen.init(PBEParametersGenerator.PKCS5PasswordToBytes(this
17: .getPassword()), this .getSalt(), this
18: .getIterationCount());
19:
20: return ((KeyParameter) gen
21: .generateDerivedParameters(CMSEnvelopedHelper.INSTANCE
22: .getKeySize(algorithmOid))).getKey();
23: }
24: }
|