public static void register(boolean newKeyAllowed) throws GeneralSecurityException {
    if (!TinkFipsUtil.AlgorithmFipsCompatibility.ALGORITHM_NOT_FIPS.isCompatible()) {
      throw new GeneralSecurityException(
          "Registering XChaCha20Poly1305 is not supported in FIPS mode");
    }
    XChaCha20Poly1305ProtoSerialization.register();
    MutablePrimitiveRegistry.globalInstance()
        .registerPrimitiveConstructor(X_CHA_CHA_20_POLY_1305_PRIMITIVE_CONSTRUCTOR);
    MutableParametersRegistry.globalInstance().putAll(namedParameters());
    MutableKeyCreationRegistry.globalInstance().add(KEY_CREATOR, XChaCha20Poly1305Parameters.class);
    MutableKeyDerivationRegistry.globalInstance()
        .add(KEY_DERIVER, XChaCha20Poly1305Parameters.class);
    KeyManagerRegistry.globalInstance().registerKeyManager(legacyKeyManager, newKeyAllowed);
  }
This instance of {@code KeyManager} generates new {@code XChaCha20Poly1305} keys and produces new
instances of {@code XChaCha20Poly1305}.
java_src/src/main/java/com/google/crypto/tink/aead/XChaCha20Poly1305KeyManager.java