Optimum forensic and counter-forensic strategies for source identification with training data