As far as I understand based on RFC 6376 everything after the CRLF between the headers and the body denotes what is the body. However when I run SHA256 on the body and then convert it to base64 I get a different value than my test email with the same content sent via gmail.
Lets take a look at my email body which is just a single word test in this case:
test
SHA256 hash when manually calculated: 9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08 DKIM bh header after converting to base64: OWY4NmQwODE4ODRjN2Q2NTlhMmZlYWEwYzU1YWQwMTVhM2JmNGYxYjJiMGI4MjJjZDE1ZDZjMTViMGYwMGEwOA==
gmail's DKIM bh value for same email body: g3zLYH4xKxcPrHOD18z9YfpQcnk/GaJedfustWU5uGs=
I notice all the other DKIM bh values I have seen have been this shorter length with / chars in them. When I decode their base64 I get a bunch of strange characters so I don't know what's going on there. Perhaps it has something to do with the DKIM l= value? I have never seen that DKIM value though, not even in gmail so I am not sure.
So to restate my question how do I get the correct bh value? Please do not tell me to use a library.