Skip to content

Instantly share code, notes, and snippets.

@colemanjp
Created October 25, 2012 12:25
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save colemanjp/3952297 to your computer and use it in GitHub Desktop.
Save colemanjp/3952297 to your computer and use it in GitHub Desktop.
Check key length on dkim for our google apps domain

Check key length on dkim for our google apps domain

Get the public key for our selector

$ dig -t txt googleprd._domainkey.yale.edu

; <<>> DiG 9.9.1-P3-RedHat-9.9.1-9.P3.fc17 <<>> -t txt googleprd._domainkey.yale.edu
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 12280
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 4, ADDITIONAL: 5

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;googleprd._domainkey.yale.edu. IN      TXT

;; ANSWER SECTION:
googleprd._domainkey.yale.edu. 10800 IN TXT     "v=DKIM1\; k=rsa\; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDpIW0kMkNWgb44eGDpR1ktuixg72kxQUdGWSask4IkaUPN4l1WQb0dc/5xr/7kYxmtZWruFqX7Kf9uToyBPjescCkfJ1s6MfciCTgxgK7lgumuuAnOZ04BJ8PztQmvZTyXM/TqRz6+5TGbstqcQ1N+nBwOp8rj7Xclw8YVKlo2LwIDAQAB"

;; AUTHORITY SECTION:
yale.edu.               10800   IN      NS      serv1.net.yale.edu.
yale.edu.               10800   IN      NS      serv3.net.yale.edu.
yale.edu.               10800   IN      NS      serv4.net.yale.edu.
yale.edu.               10800   IN      NS      serv2.net.yale.edu.

;; ADDITIONAL SECTION:
serv1.net.yale.edu.     10800   IN      A       130.132.1.9
serv2.net.yale.edu.     10800   IN      A       130.132.1.10
serv3.net.yale.edu.     10800   IN      A       130.132.1.11
serv4.net.yale.edu.     10800   IN      A       130.132.89.9

;; Query time: 2 msec
;; SERVER: 130.132.1.9#53(130.132.1.9)
;; WHEN: Thu Oct 25 08:11:00 2012
;; MSG SIZE  rcvd: 453

Format it so that openssl can read it. Add line breaks at 78

$ cat /tmp/key
-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDpIW0kMkNWgb44eGDpR1ktuixg72kxQUdGWSask
4IkaUPN4l1WQb0dc /5xr/7kYxmtZWruFqX7Kf9uToyBPjescCkfJ1s6MfciCTgxgK7lgumuuAnOZ
04BJ8PztQmvZTyXM/TqRz6+5TGbstqcQ1N+nBwOp8rj7Xclw8YVKlo2LwIDAQAB
-----END PUBLIC KEY-----

Find the key length

$ openssl rsa -noout -text -pubin < /tmp/key
Public-Key: (1024 bit)
Modulus:
    00:e9:21:6d:24:32:43:56:81:be:38:78:60:e9:47:
    59:2d:ba:2c:60:ef:69:31:41:47:46:59:26:ac:93:
    82:24:69:43:cd:e2:5d:56:41:bd:1d:73:fe:71:af:
    fe:e4:63:19:ad:65:6a:ee:16:a5:fb:29:ff:6e:4e:
    8c:81:3e:37:ac:70:29:1f:27:5b:3a:31:f7:22:09:
    38:31:80:ae:e5:82:e9:ae:b8:09:ce:67:4e:01:27:
    c3:f3:b5:09:af:65:3c:97:33:f4:ea:47:3e:be:e5:
    31:9b:b2:da:9c:43:53:7e:9c:1c:0e:a7:ca:e3:ed:
    77:25:c3:c6:15:2a:5a:36:2f
Exponent: 65537 (0x10001)
@c0d3x27
Copy link

c0d3x27 commented Sep 23, 2020

hi im lost, in "Format it so that openssl can read it " how do i do this? i copy the P= part into a file(google.key) then what do i do?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment