FAQ
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

--

Search Discussions

  • Shane Hansen at Oct 12, 2012 at 4:08 pm
    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?
    On Fri, Oct 12, 2012 at 1:31 AM, Paul van Brouwershaven wrote:

    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

    --

    --
  • Agl at Oct 13, 2012 at 9:13 pm

    On Friday, October 12, 2012 3:31:25 AM UTC-4, Paul van Brouwershaven wrote:

    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?
    The public key bitsize is obviously meaningless unless you know the
    algorithm so you can do a type switch on PublicKey and access it from
    there. (Of course, you have to handle the case where the type is unknown in
    order to be future proof.)


    Cheers

    AGL

    --

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedOct 12, '12 at 7:31a
activeOct 13, '12 at 9:13p
posts3
users3
websitegolang.org

People

Translate

site design / logo © 2021 Grokbase