President Kennedy and his brother, the attorney general, struggled to control Hoover’s power over secrets.