In this paper we prove three results about the valuation of over-the-counter derivative portfolios under counterparty risk. First, we derive a generalized credit value adjustment (CVA) under the assumption that both parties can default. Second, we show how this CVA can be hedged in a simple bilateral credit model using single-name credit default swaps and vanilla options on the underlying portfolio. Third, we prove the conditions under which adding a CVA to the counterparty default risk-free mark-to-market value of a portfolio is equivalent to discounting the portfolio cashflows with the risky curve of the counterparty. The generalized CVA derived in this paper contains the standard bilateral CVA as well as nonstandard CVAs such as the so-called extinguisher and set-off CVAs as special cases.