Petar Popara wrote:
How can I get key (SECKEYPublicKey or SECKEYPrivateKey) length (example: 1024 bit, 2048 bit...)?

For private keys, call PK11_GetPrivateModulusLen. This functions invokes the PKCS #11 module where the private key resides to get the key's CKA_MODULUS attribute. It returns the length in bytes, so you need to multiply that by 8 to get the length in bits. This function is declared in "pk11pub.h" ("pk11func.h" in NSS 3.9.x or earlier) and defined in the nss3 shared library/DLL.

For public keys, call SECKEY_PublicKeyStrengthInBits.
There is also SECKEY_PublicKeyStrength, which returns
the length in bytes.  These two functions are declared
in "keyhi.h" and defined in the nss3 shared library/DLL.

For completeness (you didn't ask about this), call
PK11_GetKeyStrength to get the key length in bits of a
symmetric key (PK11SymKey).

Wan-Teh

_______________________________________________
mozilla-crypto mailing list
[email protected]
http://mail.mozilla.org/listinfo/mozilla-crypto

Reply via email to