[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

AW: [iaik-jce] Getting Public Key Length



Hello,

use something like:
    
   int keyLength = -1;
    if (publicKey instanceof java.security.interfaces.RSAPublicKey) {
      keyLength  = ((RSAPublicKey) key).getModulus().bitLength() ;
    } else if {
    if (publicKey instanceof java.security.interfaces.DSAPublicKey) {
      keyLength = ((DSAPublicKey) key).getParams().getP().bitLength() ;
    } else if {
    if (publicKey instanceof javax.crypto.interfaces.DHPublicKey) {
      keyLength = ((DHPublicKey) key).getParams().getP().bitLength() ;
    }

Regards,
Dieter Bratko

>  -----Ursprüngliche Nachricht-----
> Von: 	iaik-jce-owner@iaik.tu-graz.ac.at
> [mailto:iaik-jce-owner@iaik.tu-graz.ac.at] 
> Gesendet:	Freitag, 19. Januar 2001 09:35
> An:	iaik-jce@iaik.at
> Betreff:	[iaik-jce] Getting Public Key Length
> 
> Hello,
> 	Can anyone suggest how to determine the PublicKey Length (any public
> key algorithm), given a Public Key. When I saw the API, in RSAPublicKey
> class methods are there to determine the modulus, exponent etc. I have not
> seen any method to determine the key length. I don't whether it can be
> determined from modulus and exponents. If so, may I know how to determine
> it. Any help on this is highly appreciable as it is a urgent requirement
> for me. Thanks in Advance. Regards
> 
> ============================================
> P.K.B. Hari Gopal                Tel No:
> Senior Engineer                   Off: 3000401-2161 (extn)
> CMC Limited                       Res:3036834
> Gachibowli                          E-Mail:
> Hyderabad                          Off:hgopal@cmcltd.com
>                                           Per:hari_gopal@rocketmail.com
> ============================================
>  << Datei: Security Info - IAIK SMimeMapper.htm >> 

winmail.dat

smime.p7s