// key pair is in 'kp' KeyFactory kf = KeyFactory.getInstance("RSA"); RSAPrivateCrtKeySpec ks = kf.getKeySpec( kp.getPrivate(), RSAPrivateCrtKeySpec.class); System.out.println("<RSAKeyValue>"); System.out.println(" <Modulus>" + ks.getModulus() + "</Modulus>"); System.out.println(" <Exponent>" + ks.getPublicExponent() + "</Exponent>"); System.out.println(" <P>" + ks.getPrimeP() + "</P>"); System.out.println(" <Q>" + ks.getPrimeQ() + "</Q>"); System.out.println(" <DP>" + ks.getPrimeExponentP() + "</DP>"); System.out.println(" <DQ>" + ks.getPrimeExponentQ() + "</DQ>"); System.out.println(" <InverseQ>" + ks.getCrtCoefficient() + "</InverseQ>"); System.out.println(" <D>" + ks.getPrivateExponent() + "</D>"); System.out.println("</RSAKeyValue>");
private void checkPrivateKey(final RSAPrivateCrtKeySpec spec) { final List<String> missing = new ArrayList<>(); if (spec.getPrivateExponent() == null) missing.add("d"); if (spec.getPrimeP() == null) missing.add("p"); if (spec.getPrimeQ() == null) missing.add("q"); if (spec.getPrimeExponentP() == null) missing.add("dp"); if (spec.getPrimeExponentQ() == null) missing.add("dq"); if (spec.getCrtCoefficient() == null) missing.add("qi"); /** * We want them to supply either all or none of the private key data */ if (missing.size() == 6) return; // they've supplied none - good if (missing.size() == 0) return; // they've supplied all - good /** * They supplied just some. This doesn't work and isn't likely what they want */ throw new InvalidJwkKeySpecException("rsa", missing); }
final BigInteger primeQ = rsaKeySpec.getPrimeQ(); final BigInteger primeExponentP = rsaKeySpec.getPrimeExponentP(); final BigInteger primeExponentQ = rsaKeySpec.getPrimeExponentQ(); final BigInteger crtCoefficient = rsaKeySpec.getCrtCoefficient();
final BigInteger primeQ = rsaKeySpec.getPrimeQ(); final BigInteger primeExponentP = rsaKeySpec.getPrimeExponentP(); final BigInteger primeExponentQ = rsaKeySpec.getPrimeExponentQ(); final BigInteger crtCoefficient = rsaKeySpec.getCrtCoefficient();
final BigInteger primeQ = rsaKeySpec.getPrimeQ(); final BigInteger primeExponentP = rsaKeySpec.getPrimeExponentP(); final BigInteger primeExponentQ = rsaKeySpec.getPrimeExponentQ(); final BigInteger crtCoefficient = rsaKeySpec.getCrtCoefficient();
final BigInteger primeQ = rsaKeySpec.getPrimeQ(); final BigInteger primeExponentP = rsaKeySpec.getPrimeExponentP(); final BigInteger primeExponentQ = rsaKeySpec.getPrimeExponentQ(); final BigInteger crtCoefficient = rsaKeySpec.getCrtCoefficient();
/** * construct a private key from an RSAPrivateCrtKeySpec * * @param spec the spec to be used in construction. */ JCERSAPrivateCrtKey( RSAPrivateCrtKeySpec spec) { this.modulus = spec.getModulus(); this.publicExponent = spec.getPublicExponent(); this.privateExponent = spec.getPrivateExponent(); this.primeP = spec.getPrimeP(); this.primeQ = spec.getPrimeQ(); this.primeExponentP = spec.getPrimeExponentP(); this.primeExponentQ = spec.getPrimeExponentQ(); this.crtCoefficient = spec.getCrtCoefficient(); }
/** * construct a private key from an RSAPrivateCrtKeySpec * * @param spec the spec to be used in construction. */ JCERSAPrivateCrtKey( RSAPrivateCrtKeySpec spec) { this.modulus = spec.getModulus(); this.publicExponent = spec.getPublicExponent(); this.privateExponent = spec.getPrivateExponent(); this.primeP = spec.getPrimeP(); this.primeQ = spec.getPrimeQ(); this.primeExponentP = spec.getPrimeExponentP(); this.primeExponentQ = spec.getPrimeExponentQ(); this.crtCoefficient = spec.getCrtCoefficient(); }
/** * construct a private key from an RSAPrivateCrtKeySpec * * @param spec the spec to be used in construction. */ JCERSAPrivateCrtKey( RSAPrivateCrtKeySpec spec) { this.modulus = spec.getModulus(); this.publicExponent = spec.getPublicExponent(); this.privateExponent = spec.getPrivateExponent(); this.primeP = spec.getPrimeP(); this.primeQ = spec.getPrimeQ(); this.primeExponentP = spec.getPrimeExponentP(); this.primeExponentQ = spec.getPrimeExponentQ(); this.crtCoefficient = spec.getCrtCoefficient(); }
/** * construct a private key from an RSAPrivateCrtKeySpec * * @param spec the spec to be used in construction. */ JCERSAPrivateCrtKey( RSAPrivateCrtKeySpec spec) { this.modulus = spec.getModulus(); this.publicExponent = spec.getPublicExponent(); this.privateExponent = spec.getPrivateExponent(); this.primeP = spec.getPrimeP(); this.primeQ = spec.getPrimeQ(); this.primeExponentP = spec.getPrimeExponentP(); this.primeExponentQ = spec.getPrimeExponentQ(); this.crtCoefficient = spec.getCrtCoefficient(); }
/** * construct a private key from an RSAPrivateCrtKeySpec * * @param spec the spec to be used in construction. */ BCRSAPrivateCrtKey( RSAPrivateCrtKeySpec spec) { this.modulus = spec.getModulus(); this.publicExponent = spec.getPublicExponent(); this.privateExponent = spec.getPrivateExponent(); this.primeP = spec.getPrimeP(); this.primeQ = spec.getPrimeQ(); this.primeExponentP = spec.getPrimeExponentP(); this.primeExponentQ = spec.getPrimeExponentQ(); this.crtCoefficient = spec.getCrtCoefficient(); }
/** * construct a private key from an RSAPrivateCrtKeySpec * * @param spec the spec to be used in construction. */ JCERSAPrivateCrtKey( RSAPrivateCrtKeySpec spec) { this.modulus = spec.getModulus(); this.publicExponent = spec.getPublicExponent(); this.privateExponent = spec.getPrivateExponent(); this.primeP = spec.getPrimeP(); this.primeQ = spec.getPrimeQ(); this.primeExponentP = spec.getPrimeExponentP(); this.primeExponentQ = spec.getPrimeExponentQ(); this.crtCoefficient = spec.getCrtCoefficient(); }
/** * construct a private key from an RSAPrivateCrtKeySpec * * @param spec the spec to be used in construction. */ JCERSAPrivateCrtKey( RSAPrivateCrtKeySpec spec) { this.modulus = spec.getModulus(); this.publicExponent = spec.getPublicExponent(); this.privateExponent = spec.getPrivateExponent(); this.primeP = spec.getPrimeP(); this.primeQ = spec.getPrimeQ(); this.primeExponentP = spec.getPrimeExponentP(); this.primeExponentQ = spec.getPrimeExponentQ(); this.crtCoefficient = spec.getCrtCoefficient(); }
/** * construct a private key from an RSAPrivateCrtKeySpec * * @param spec the spec to be used in construction. */ BCRSAPrivateCrtKey( RSAPrivateCrtKeySpec spec) { this.modulus = spec.getModulus(); this.publicExponent = spec.getPublicExponent(); this.privateExponent = spec.getPrivateExponent(); this.primeP = spec.getPrimeP(); this.primeQ = spec.getPrimeQ(); this.primeExponentP = spec.getPrimeExponentP(); this.primeExponentQ = spec.getPrimeExponentQ(); this.crtCoefficient = spec.getCrtCoefficient(); }
/** * construct a private key from an RSAPrivateCrtKeySpec * * @param spec the spec to be used in construction. */ BCRSAPrivateCrtKey( RSAPrivateCrtKeySpec spec) { this.modulus = spec.getModulus(); this.publicExponent = spec.getPublicExponent(); this.privateExponent = spec.getPrivateExponent(); this.primeP = spec.getPrimeP(); this.primeQ = spec.getPrimeQ(); this.primeExponentP = spec.getPrimeExponentP(); this.primeExponentQ = spec.getPrimeExponentQ(); this.crtCoefficient = spec.getCrtCoefficient(); }
/** * construct a private key from an RSAPrivateCrtKeySpec * * @param spec the spec to be used in construction. */ BCRSAPrivateCrtKey( RSAPrivateCrtKeySpec spec) { this.modulus = spec.getModulus(); this.publicExponent = spec.getPublicExponent(); this.privateExponent = spec.getPrivateExponent(); this.primeP = spec.getPrimeP(); this.primeQ = spec.getPrimeQ(); this.primeExponentP = spec.getPrimeExponentP(); this.primeExponentQ = spec.getPrimeExponentQ(); this.crtCoefficient = spec.getCrtCoefficient(); }
/** * construct a private key from an RSAPrivateCrtKeySpec * * @param spec the spec to be used in construction. */ JCERSAPrivateCrtKey( RSAPrivateCrtKeySpec spec) { this.modulus = spec.getModulus(); this.publicExponent = spec.getPublicExponent(); this.privateExponent = spec.getPrivateExponent(); this.primeP = spec.getPrimeP(); this.primeQ = spec.getPrimeQ(); this.primeExponentP = spec.getPrimeExponentP(); this.primeExponentQ = spec.getPrimeExponentQ(); this.crtCoefficient = spec.getCrtCoefficient(); }
/** * construct a private key from an RSAPrivateCrtKeySpec * * @param spec the spec to be used in construction. */ BCRSAPrivateCrtKey( RSAPrivateCrtKeySpec spec) { this.modulus = spec.getModulus(); this.publicExponent = spec.getPublicExponent(); this.privateExponent = spec.getPrivateExponent(); this.primeP = spec.getPrimeP(); this.primeQ = spec.getPrimeQ(); this.primeExponentP = spec.getPrimeExponentP(); this.primeExponentQ = spec.getPrimeExponentQ(); this.crtCoefficient = spec.getCrtCoefficient(); }
/** * construct a private key from an RSAPrivateCrtKeySpec * * @param spec the spec to be used in construction. */ JCERSAPrivateCrtKey( RSAPrivateCrtKeySpec spec) { this.modulus = spec.getModulus(); this.publicExponent = spec.getPublicExponent(); this.privateExponent = spec.getPrivateExponent(); this.primeP = spec.getPrimeP(); this.primeQ = spec.getPrimeQ(); this.primeExponentP = spec.getPrimeExponentP(); this.primeExponentQ = spec.getPrimeExponentQ(); this.crtCoefficient = spec.getCrtCoefficient(); }
/** * construct a private key from an RSAPrivateCrtKeySpec * * @param spec the spec to be used in construction. */ BCRSAPrivateCrtKey( RSAPrivateCrtKeySpec spec) { this.modulus = spec.getModulus(); this.publicExponent = spec.getPublicExponent(); this.privateExponent = spec.getPrivateExponent(); this.primeP = spec.getPrimeP(); this.primeQ = spec.getPrimeQ(); this.primeExponentP = spec.getPrimeExponentP(); this.primeExponentQ = spec.getPrimeExponentQ(); this.crtCoefficient = spec.getCrtCoefficient(); }