private CramerShoupCiphertext encrypt(BigInteger message, String label) { CramerShoupKeyPairGenerator kpGen = new CramerShoupKeyPairGenerator(); CramerShoupParametersGenerator pGen = new CramerShoupParametersGenerator(); pGen.init(2048, 1, RND); CramerShoupParameters params = pGen.generateParameters(DHStandardGroups.rfc3526_2048); CramerShoupKeyGenerationParameters param = new CramerShoupKeyGenerationParameters(RND, params); kpGen.init(param); keyPair = kpGen.generateKeyPair(); CramerShoupCoreEngine engine = new CramerShoupCoreEngine(); if (label != null) { engine.init(true, keyPair.getPublic(), label); } else { engine.init(true, keyPair.getPublic()); } CramerShoupCiphertext ciphertext = engine.encryptBlock(message); return ciphertext; }
public void init(KeyGenerationParameters param) { this.param = (CramerShoupKeyGenerationParameters) param; }