Chromospheric magnetic field and density structure measurements using hard X-rays in a flaring coronal loop