Any tips on how to easily fetch the key length of DKIM-Keys from DNS? Just by looking at the DNS entries I can't easily determine the key length ;)
k=rsa; … p=<a bunch of base64 data>
The base64 data is an RSA public key. You can print in textual form with something like, your-clipboard-paste-command | base64 -d | openssl rsa -pubin -noout -inform der -text
The first line of output will be something like, Public-Key: (2048 bit)
Which is the key length.If you fetch with `dig`, note that sometimes dig will do this:
example.com. 1800 IN TXT "k=rsa; t=s; p=blahblahblahblah" "blahblahblah"
I.e., it breaks it up with a `" "`; remove those, that's not part of the data. I.e., concat the strings dig returns, then parse out the p=, then base64 decode, then openssl.(You can also do what the article does, but without Python, which is jam that base64 between some PEM header guards like the article does, and then feed it to openssl. Same command, but you don't need the -inform der b/c the "in[put] form[at]" is now pem, which is the default.)