In all cases where real property has been heretofore, or shall be hereafter, sold on execution or in any mortgage foreclosure proceeding, the purchaser at such sale, or his successor or successors in interest, may during the year or years of redemption, in case of the expiration during such year of any insurance policy on the premises sold, pay the premium necessary to procure a renewal of such policy; and in case of any taxes or assessments being delinquent, or in case any installment of interest or principal upon any prior or superior mortgage shall be due or become due during such period of redemption, the purchaser may pay the same when or after due, and in all such cases, the amount so paid, with interest thereon, shall be and constitute a part of the sum necessary to be paid for the redemption from such sale.
SDCL 44-8-17