Secure Data Transmission Through Optimal Risk Management