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

AW: [iaik-jce] How to get RSAPrivate Key from PKCS#12 file, instead of Private Key ?



Hello,

cast to iaik.security.rsa.RSAPrivateKey or -- provider independent -- to
java.security.interfaces.RSAPrivateKey.

Regards,
Dieter Bratko

-----Ursprüngliche Nachricht-----
Von: iaik-jce-owner@iaik.tu-graz.ac.at
[mailto:iaik-jce-owner@iaik.tu-graz.ac.at]Im Auftrag von Joyce
Gesendet: Dienstag, 14. November 2000 16:28
An: iaik-jce@iaik.at
Betreff: [iaik-jce] How to get RSAPrivate Key from PKCS#12 file, instead
of Private Key ?


Hi all,

Since I would like to get modulus and exponent of RSA private key, I must
get RSAPrivateKey object from PKCS#12, instead of PrivateKey object.

I can get PrivateKey object:
	PKCS12 p12 = new PKCS12(new FileInputStream(PFXname));
      p12.decrypt(password);
      KeyBag kBag = p12.getKeyBag();
      PrivateKey privKey = (PrivateKey) (kBag != null ? kBag.getPrivateKey()
: null);
      if (privKey != null){
      	System.out.println(privKey);
      }

But, an error "java.lang.ClassCastException:
com.sun.rsajca.JSA_RSAPrivateKey " occurs if RSAPrivateKey class is casted.
	PKCS12 p12 = new PKCS12(new FileInputStream(PFXname));
      p12.decrypt(password);
      KeyBag kBag = p12.getKeyBag();
      RSAPrivateKey privKey = (RSAPrivateKey) (kBag != null ?
kBag.getPrivateKey() : null);
      if (privKey != null){
      	System.out.println(privKey);
      }

Does anyone know how to get ?
Please kindly advise.

Thanks in advanced.

Best Regards,
Joyce

--
Mailinglist-archive at
http://jcewww.iaik.at/mailarchive/iaik-jce/jcethreads.html

To unsubscribe send an email to listserv@iaik.at with the folowing content:
UNSUBSCRIBE iaik-jce




***************************************************************************
*                                                                         *
* IAIK S/MIME Mapper Security Info                                        *
* ===================================                                     *
*                                                                         *
* for message:                                                            *
*   From: "Dieter Bratko" <Dieter.Bratko@iaik.at>                         *
*   Date: Tue, 14 Nov 2000 17:58:32 +0100                                 *
*   Subject: AW: [iaik-jce] How to get RSAPrivate Key from PKCS#12 file, instead of Private Key ?*
*                                                                         *
* Message S/MIME properties:                                              *
*                                                                         *
*   Encrypted using:    not encrypted                                     *
*                                                                         *
*   Digitally signed:   yes                                               *
*   Signature valid:    yes                                               *
*   Signature trusted:  yes                                               *
*                                                                         *
*                                                                         *
* Compliance with policy for email addresses *@iaik.at:                   *
*                                                                         *
*   Encryption:         OK (None or better required)                      *
*                                                                         *
*   Digital Signature:  OK (digital signature required)                   *
*                                                                         *
***************************************************************************