Esempio n. 1
0
 private void makeKeys() {
   PrimeGenerator pg = new PrimeGenerator(513, 10, sr);
   do {
     p = pg.getStrongPrime();
   } while (p.subtract(BigIntegerMath.ONE).mod(BigIntegerMath.THREE).equals(BigIntegerMath.ZERO));
   do {
     q = pg.getStrongPrime();
   } while (q.subtract(BigIntegerMath.ONE).mod(BigIntegerMath.THREE).equals(BigIntegerMath.ZERO));
   modulus = p.multiply(q);
   // Use 3 as enciphering exponent - OK since we are using salt
   decipherExp =
       BigIntegerMath.THREE.modInverse(
           p.subtract(BigIntegerMath.ONE).multiply(q.subtract(BigIntegerMath.ONE)));
   ciphertextBlockSize = (modulus.bitLength() - 1) / 8 + 1;
   // Maximum size of plaintext is 6 bytes less than ciphertext
   // 1 to get under modulus
   // 4 for the salt
   // 1 for a pad byte
   plaintextBlockSize = ciphertextBlockSize - 6;
 }