x509 certificate public key bit size

387 views
Skip to first unread message

Paul van Brouwershaven

unread,
Oct 12, 2012, 3:31:25 AM10/12/12
to golan...@googlegroups.com
I'm try to get the bit size of the public key part of a certificate but for some reason this is not listed by default in the go x509 Certificate struct.

http://golang.org/pkg/crypto/x509/#Certificate

Does anyone know an other (easy) way to calculate the key size of a certificate?

Thanks,

Paul

Shane Hansen

unread,
Oct 12, 2012, 12:00:25 PM10/12/12
to Paul van Brouwershaven, golan...@googlegroups.com
There's no trivial way to do this that I'm aware of.
The currently supported types for Certifice.PublicKey are
crypto.rsa.PublicKey and crypto.dsa.PublicKey.

You can look at the PublicKey.N.BitLen() field which is a big.Int to determine size.

Seems like a method that would be worth adding to the Certificate struct, or maybe there's a simpler way?

--
 
 

Reply all
Reply to author
Forward
0 new messages