  By taking a variety of realistic hardware imperfections into consideration,
we propose an optimal power allocation (OPA) strategy to maximize the
instantaneous secrecy rate of a cooperative wireless network comprised of a
source, a destination and an untrusted amplify-and-forward (AF) relay. We
assume that either the source or the destination is equipped with a large-scale
multiple antennas (LSMA) system, while the rest are equipped with a single
antenna. To prevent the untrusted relay from intercepting the source message,
the destination sends an intended jamming noise to the relay, which is referred
to as destination-based cooperative jamming (DBCJ). Given this system model,
novel closed-form expressions are presented in the high signal-to-noise ratio
(SNR) regime for the ergodic secrecy rate (ESR) and the secrecy outage
probability (SOP). We further improve the secrecy performance of the system by
optimizing the associated hardware design. The results reveal that by
beneficially distributing the tolerable hardware imperfections across the
transmission and reception radio-frequency (RF) front ends of each node, the
system's secrecy rate may be improved. The engineering insight is that equally
sharing the total imperfections at the relay between the transmitter and the
receiver provides the best secrecy performance. Numerical results illustrate
that the proposed OPA together with the most appropriate hardware design
significantly increases the secrecy rate.
