Let's assume I was interviewing you.
What you should say
The classic question comes up, "Why did you leave your previous employer?" It was perfectly fair to say "My employer knowingly asked me to do something illegal, I refused then resigned."
That really is a 100% justifiable reason with no further explanation required.
To be honest even if you wanted skirt the illegal part and say "I was asked to do some things are generally considered both immoral and unethical, I refused then resigned." I'd probably just ask for an example. (just to make sure considering it immoral was something reasonable)
What you should not say
Now because this it treading into someone's reputation who's already doing something illegal I would avoid details. Just confirm "Legal consult advised me to not follow my employer's request as it was almost certainly illegal" (Basically your saying "My lawyer said it was illegal" without actual saying your employer did something illegal). Sadly in places like the US saying anything specific like "Company X was committing fraud" can potentially put you in legal hot water.
Essentially, until such time Company X is found guilty of a crime you cannot say they committed that crime without risking defamation. (potentially for several reasons but we'll go with "innocent until proven guilty")
Time gap
Three months after leaving a job short notice to protect yourself legally? Yeah, that's not even a blip on the radar. I've known many fantastic employees who I've hired who just took a few months off working. Travel, personal development, kids, etc all good reasons. I also know really good people who were in no rush to take any job, they were picky about what jobs they'd even consider. Again, all good reasons. I'd ask why the gap just to watch for red flags, but you could say "I wanted to take a little while for myself before taking another job" and it's all good in my book.
My opinion
In the event I was hiring you this would all speak very well to me. I was never asked to do anything illegal perse, but I have been asked to do things that treaded dangerously into legally "grey" areas where if it wasn't illegal... it probably should be. In refusing to do what isn't right you've demonstrated strong moral character, I know that doesn't mean much in some places, but to me this is a very desirable trait in an employee. I find people who stand for what's right, tend to be people I can count on to be honest and stand up to me when I'm being impractical or unreasonable in expectations. (and I need that rushed code is terrible code)