Place onions and garlic into a large saucepan, add water to cover. Place over high heat and bring to a boil, reduce heat to medium-low, cover, and simmer for 45 minutes. Add the ginger, and continue simmering for 5 more minutes.
Puree the onion in a food processor or blender in batches until smooth. Place a large saucepan over medium-high heat, pour in the diced tomatoes, and season with turmeric, cumin, garam masala, curry paste, and red pepper flakes. Bring to a simmer, then pour in the onion puree. Simmer for 45 minutes.