You didn't have to consent to him searching your car. If he pulled you over for a driving infraction (random stop) that's where it begins and ends. They have to have a good reason to search your car. You can say no.
Ditto with his line of questioning. He CAN ask to see ID, check the mechanical condition of your car, check your insurance, ask if you've been drinking. That's about all he can ask unless someone specifically said they thought they saw weapons in your car.
Your Charter of Rights were violated my friend...