/** * @return a KeyManager for the given {@code typeUrl}, {@code primitiveName} and version at least * {@code minVersion} (if it exists in the catalogue). */ @Override public KeyManager<PublicKeySign> getKeyManager( String typeUrl, String primitiveName, int minVersion) throws GeneralSecurityException { KeyManager<PublicKeySign> keyManager; switch (primitiveName.toLowerCase()) { case "publickeysign": keyManager = publicKeySignKeyManager(typeUrl); break; default: throw new GeneralSecurityException( String.format("No support for primitive '%s'.", primitiveName)); } if (keyManager.getVersion() < minVersion) { throw new GeneralSecurityException( String.format( "No key manager for key type '%s' with version at least %d.", typeUrl, minVersion)); } return keyManager; }
/** * Tries to register with the {@link Registry} all instances of {@link * com.google.crypto.tink.Catalogue} needed to handle PublicKeySign and PublicKeyVerify key types * supported in Tink. * * @since 1.2.0 */ public static void register() throws GeneralSecurityException { Registry.addCatalogue(PUBLIC_KEY_SIGN_CATALOGUE_NAME, new PublicKeySignCatalogue()); Registry.addCatalogue(PUBLIC_KEY_VERIFY_CATALOGUE_NAME, new PublicKeyVerifyCatalogue()); Config.register(LATEST); } }