/** * @return true if the keypair has the same fingerprint as supplied */ public static boolean privateKeyHasFingerprint(RSAPrivateCrtKeySpec privateKey, String fingerprint) { return fingerprint(privateKey.getPublicExponent(), privateKey.getModulus()).equals(fingerprint); }
/** * @return true if the keypair has the same fingerprint as supplied */ public static boolean privateKeyHasFingerprint(RSAPrivateCrtKeySpec privateKey, String fingerprint) { return fingerprint(privateKey.getPublicExponent(), privateKey.getModulus()).equals(fingerprint); }
/** * @return true if the keypair has the same fingerprint as supplied */ public static boolean privateKeyHasFingerprint(RSAPrivateCrtKeySpec privateKey, String fingerprint) { return fingerprint(privateKey.getPublicExponent(), privateKey.getModulus()).equals(fingerprint); }
/** * @return true if the keypairs match */ public static boolean privateKeyMatchesPublicKey(RSAPrivateCrtKeySpec privateKey, RSAPublicKeySpec publicKey) { return privateKey.getPublicExponent().equals(publicKey.getPublicExponent()) && privateKey.getModulus().equals(publicKey.getModulus()); }
/** * @return true if the keypair has the same fingerprint as supplied */ public static boolean privateKeyHasFingerprint(RSAPrivateCrtKeySpec privateKey, String fingerprint) { return fingerprint(privateKey.getPublicExponent(), privateKey.getModulus()).equals(fingerprint); }
/** * @param privateKeyPEM * RSA private key in PEM format * @return fingerprint ex. {@code 2b:a9:62:95:5b:8b:1d:61:e0:92:f7:03:10:e9:db:d9} */ public static String fingerprintPrivateKey(String privateKeyPEM) { KeySpec privateKeySpec = privateKeySpec(privateKeyPEM); checkArgument(privateKeySpec instanceof RSAPrivateCrtKeySpec, "incorrect format expected RSAPrivateCrtKeySpec was %s", privateKeySpec); RSAPrivateCrtKeySpec certKeySpec = RSAPrivateCrtKeySpec.class.cast(privateKeySpec); return fingerprint(certKeySpec.getPublicExponent(), certKeySpec.getModulus()); }
/** * @param privateKeyPEM * RSA private key in PEM format * @return fingerprint ex. {@code 2b:a9:62:95:5b:8b:1d:61:e0:92:f7:03:10:e9:db:d9} */ public static String fingerprintPrivateKey(String privateKeyPEM) { KeySpec privateKeySpec = privateKeySpec(privateKeyPEM); checkArgument(privateKeySpec instanceof RSAPrivateCrtKeySpec, "incorrect format expected RSAPrivateCrtKeySpec was %s", privateKeySpec); RSAPrivateCrtKeySpec certKeySpec = RSAPrivateCrtKeySpec.class.cast(privateKeySpec); return fingerprint(certKeySpec.getPublicExponent(), certKeySpec.getModulus()); }
/** * @return true if the keypairs match */ public static boolean privateKeyMatchesPublicKey(RSAPrivateCrtKeySpec privateKey, RSAPublicKeySpec publicKey) { return privateKey.getPublicExponent().equals(publicKey.getPublicExponent()) && privateKey.getModulus().equals(publicKey.getModulus()); }
/** * @return true if the keypairs match */ public static boolean privateKeyMatchesPublicKey(RSAPrivateCrtKeySpec privateKey, RSAPublicKeySpec publicKey) { return privateKey.getPublicExponent().equals(publicKey.getPublicExponent()) && privateKey.getModulus().equals(publicKey.getModulus()); }
/** * @param privateKeyPEM * RSA private key in PEM format * @return fingerprint ex. {@code 2b:a9:62:95:5b:8b:1d:61:e0:92:f7:03:10:e9:db:d9} */ public static String fingerprintPrivateKey(String privateKeyPEM) { KeySpec privateKeySpec = privateKeySpec(privateKeyPEM); checkArgument(privateKeySpec instanceof RSAPrivateCrtKeySpec, "incorrect format expected RSAPrivateCrtKeySpec was %s", privateKeySpec); RSAPrivateCrtKeySpec certKeySpec = RSAPrivateCrtKeySpec.class.cast(privateKeySpec); return fingerprint(certKeySpec.getPublicExponent(), certKeySpec.getModulus()); }
/** * @return true if the keypairs match */ public static boolean privateKeyMatchesPublicKey(RSAPrivateCrtKeySpec privateKey, RSAPublicKeySpec publicKey) { return privateKey.getPublicExponent().equals(publicKey.getPublicExponent()) && privateKey.getModulus().equals(publicKey.getModulus()); }
/** * @param privateKeyPEM * RSA private key in PEM format * @return fingerprint ex. {@code 2b:a9:62:95:5b:8b:1d:61:e0:92:f7:03:10:e9:db:d9} */ public static String fingerprintPrivateKey(String privateKeyPEM) { KeySpec privateKeySpec = privateKeySpec(privateKeyPEM); checkArgument(privateKeySpec instanceof RSAPrivateCrtKeySpec, "incorrect format expected RSAPrivateCrtKeySpec was %s", privateKeySpec); RSAPrivateCrtKeySpec certKeySpec = RSAPrivateCrtKeySpec.class.cast(privateKeySpec); return fingerprint(certKeySpec.getPublicExponent(), certKeySpec.getModulus()); }
@Test public void testCanReadRsaAndCompareFingerprintOnPrivateRSAKey() throws IOException { String privKey = Strings2.toStringAndClose(getClass().getResourceAsStream("/test")); RSAPrivateCrtKeySpec key = (RSAPrivateCrtKeySpec) Pems.privateKeySpec(privKey); String fingerPrint = fingerprint(key.getPublicExponent(), key.getModulus()); assertEquals(fingerPrint, expectedFingerprint); }
@Test public void testCanReadRsaAndCompareFingerprintOnPrivateRSAKey() throws IOException { String privKey = Strings2.toStringAndClose(getClass().getResourceAsStream("/test")); RSAPrivateCrtKeySpec key = (RSAPrivateCrtKeySpec) Pems.privateKeySpec(privKey); String fingerPrint = fingerprint(key.getPublicExponent(), key.getModulus()); assertEquals(fingerPrint, expectedFingerprint); }
/** * 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(); }