@Test public void fromExponents() throws Exception { RSAKeyPair rsaPair = RSAKeyPair.fromExponents(rsaSpec.e, rsaSpec.p, rsaSpec.q); assertArrayEquals(rsaPair.n, rsaSpec.n); assertArrayEquals(rsaPair.e, rsaSpec.e); assertArrayEquals(rsaPair.d, rsaSpec.d); assertArrayEquals(rsaPair.p, rsaSpec.p); assertArrayEquals(rsaPair.q, rsaSpec.q); assertArrayEquals(rsaPair.dP, rsaSpec.dP); assertArrayEquals(rsaPair.dQ, rsaSpec.dQ); assertArrayEquals(rsaPair.qInv, rsaSpec.qInv); }
public static RSAKeyPair fromExponents(byte[] e, byte[] p, byte[] q) { final BigInteger eInt = BigIntegers.fromUnsignedByteArray(e), pInt = BigIntegers.fromUnsignedByteArray(p), qInt = BigIntegers.fromUnsignedByteArray(q), nInt = pInt.multiply(qInt), mInt = pInt.subtract(BigInteger.ONE).multiply(qInt.subtract(BigInteger.ONE)), dInt = eInt.modInverse(mInt), dPInt = dInt.remainder(pInt.subtract(BigInteger.ONE)), dQInt = dInt.remainder(qInt.subtract(BigInteger.ONE)), qInvInt = qInt.modInverse(pInt); final byte[] n = BigIntegers.asUnsignedByteArray(nInt), d = BigIntegers.asUnsignedByteArray(dInt), dP = BigIntegers.asUnsignedByteArray(dPInt), dQ = BigIntegers.asUnsignedByteArray(dQInt), qInv = BigIntegers.asUnsignedByteArray(qInvInt); return new RSAKeyPair(n, e, d, p, q, dP, dQ, qInv); }
RSAKeyPair { public static RSAKeyPair fromExponents(byte[] e, byte[] p, byte[] q) { final BigInteger eInt = BigIntegers.fromUnsignedByteArray(e), pInt = BigIntegers.fromUnsignedByteArray(p), qInt = BigIntegers.fromUnsignedByteArray(q), nInt = pInt.multiply(qInt), mInt = pInt.subtract(BigInteger.ONE).multiply(qInt.subtract(BigInteger.ONE)), dInt = eInt.modInverse(mInt), dPInt = dInt.remainder(pInt.subtract(BigInteger.ONE)), dQInt = dInt.remainder(qInt.subtract(BigInteger.ONE)), qInvInt = qInt.modInverse(pInt); final byte[] n = BigIntegers.asUnsignedByteArray(nInt), d = BigIntegers.asUnsignedByteArray(dInt), dP = BigIntegers.asUnsignedByteArray(dPInt), dQ = BigIntegers.asUnsignedByteArray(dQInt), qInv = BigIntegers.asUnsignedByteArray(qInvInt); return new RSAKeyPair(n, e, d, p, q, dP, dQ, qInv); } }
RSAKeyPair { public static RSAKeyPair fromExponents(byte[] e, byte[] p, byte[] q) { final BigInteger eInt = BigIntegers.fromUnsignedByteArray(e), pInt = BigIntegers.fromUnsignedByteArray(p), qInt = BigIntegers.fromUnsignedByteArray(q), nInt = pInt.multiply(qInt), mInt = pInt.subtract(BigInteger.ONE).multiply(qInt.subtract(BigInteger.ONE)), dInt = eInt.modInverse(mInt), dPInt = dInt.remainder(pInt.subtract(BigInteger.ONE)), dQInt = dInt.remainder(qInt.subtract(BigInteger.ONE)), qInvInt = qInt.modInverse(pInt); final byte[] n = BigIntegers.asUnsignedByteArray(nInt), d = BigIntegers.asUnsignedByteArray(dInt), dP = BigIntegers.asUnsignedByteArray(dPInt), dQ = BigIntegers.asUnsignedByteArray(dQInt), qInv = BigIntegers.asUnsignedByteArray(qInvInt); return new RSAKeyPair(n, e, d, p, q, dP, dQ, qInv); } RSAKeyPair(byte[] n, byte[] e, byte[] d, byte[] p, byte[] q, byte[] dP, byte[] dQ, byte[] qInv); }
RSAKeyPair { public static RSAKeyPair fromExponents(byte[] e, byte[] p, byte[] q) { final BigInteger eInt = BigIntegers.fromUnsignedByteArray(e), pInt = BigIntegers.fromUnsignedByteArray(p), qInt = BigIntegers.fromUnsignedByteArray(q), nInt = pInt.multiply(qInt), mInt = pInt.subtract(BigInteger.ONE).multiply(qInt.subtract(BigInteger.ONE)), dInt = eInt.modInverse(mInt), dPInt = dInt.remainder(pInt.subtract(BigInteger.ONE)), dQInt = dInt.remainder(qInt.subtract(BigInteger.ONE)), qInvInt = qInt.modInverse(pInt); final byte[] n = BigIntegers.asUnsignedByteArray(nInt), d = BigIntegers.asUnsignedByteArray(dInt), dP = BigIntegers.asUnsignedByteArray(dPInt), dQ = BigIntegers.asUnsignedByteArray(dQInt), qInv = BigIntegers.asUnsignedByteArray(qInvInt); return new RSAKeyPair(n, e, d, p, q, dP, dQ, qInv); } RSAKeyPair(byte[] n, byte[] e, byte[] d, byte[] p, byte[] q, byte[] dP, byte[] dQ, byte[] qInv); static RSAKeyPair fromExponents(byte[] e, byte[] p, byte[] q); }
RSAKeyPair { public static RSAKeyPair fromExponents(byte[] e, byte[] p, byte[] q) { final BigInteger eInt = BigIntegers.fromUnsignedByteArray(e), pInt = BigIntegers.fromUnsignedByteArray(p), qInt = BigIntegers.fromUnsignedByteArray(q), nInt = pInt.multiply(qInt), mInt = pInt.subtract(BigInteger.ONE).multiply(qInt.subtract(BigInteger.ONE)), dInt = eInt.modInverse(mInt), dPInt = dInt.remainder(pInt.subtract(BigInteger.ONE)), dQInt = dInt.remainder(qInt.subtract(BigInteger.ONE)), qInvInt = qInt.modInverse(pInt); final byte[] n = BigIntegers.asUnsignedByteArray(nInt), d = BigIntegers.asUnsignedByteArray(dInt), dP = BigIntegers.asUnsignedByteArray(dPInt), dQ = BigIntegers.asUnsignedByteArray(dQInt), qInv = BigIntegers.asUnsignedByteArray(qInvInt); return new RSAKeyPair(n, e, d, p, q, dP, dQ, qInv); } RSAKeyPair(byte[] n, byte[] e, byte[] d, byte[] p, byte[] q, byte[] dP, byte[] dQ, byte[] qInv); static RSAKeyPair fromExponents(byte[] e, byte[] p, byte[] q); final byte[] n; final byte[] e; final byte[] d; final byte[] p; final byte[] q; final byte[] dP; final byte[] dQ; final byte[] qInv; }