Preheat oven to 350°.
Coat an 8-inch square baking pan with cooking spray; dust with 2 teaspoons flour. Lightly spoon 1 cup flour into a dry measuring cup; level with a knife. Combine flour, cocoa, baking soda, and salt, stirring with a whisk.
Place butter in a large bowl; beat with a mixer at medium speed until smooth. Add vanilla; beat well. Add granulated sugar, 1/4 cup at a time, beating well after each addition. Beat at medium-high speed 3 minutes. Add eggs, one at a time, beating well after each addition.
Beating at low speed, add flour mixture and buttermilk alternately to sugar mixture, beginning and ending with flour mixture; beat just until smooth.
Pour batter into prepared pan. Bake at 350° for 32 minutes or until a wooden pick inserted in center comes out clean. Cool in pan 10 minutes on a wire rack; remove from pan. Cool completely on wire rack. Sift powdered sugar over top of cake, if desired.