Skip to content

Commit

Permalink
add check for minimum key size, add negative test
Browse files Browse the repository at this point in the history
  • Loading branch information
n1ckl0sk0rtge committed Mar 18, 2022
1 parent e1d2ada commit 1e20740
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
Binary file modified build/classes/java/test/PseudonymTest.class
Binary file not shown.
Binary file modified build/tmp/compileTestJava/previous-compilation-data.bin
Binary file not shown.
7 changes: 5 additions & 2 deletions src/main/java/com/ibm/unlinkablepseudonyms/Pseudonym.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.ibm.unlinkablepseudonyms;

import org.apache.commons.codec.digest.DigestUtils;

import java.math.BigInteger;
import java.security.interfaces.RSAPrivateCrtKey;
import java.security.interfaces.RSAPublicKey;
Expand All @@ -23,7 +22,11 @@ public static byte[] convert(
byte[] cipher,
PRFSecretExponent currentSecretExponent,
PRFSecretExponent targetSecretExponent,
RSAPrivateCrtKey privateKey) {
RSAPrivateCrtKey privateKey) throws Exception {

if (privateKey.getModulus().bitLength() <= 256) {
throw new Exception("key size to small");
}

BigInteger phi = privateKey.getPrimeP().subtract(BigInteger.ONE).multiply(privateKey.getPrimeQ().subtract(BigInteger.ONE));
BigInteger value = (new BigInteger(cipher)).modPow(targetSecretExponent.asBigInt(), privateKey.getModulus());
Expand Down

0 comments on commit 1e20740

Please sign in to comment.