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

RE: [iaik-jce] Way to add security provider ??



On way is to set the provider like this:
IAIK provider = new IAIK();
Security.addProvider(provider);

that works fine with my code
but is'nt that the same as your line
Security.addProvider((IAIK) new iaik.security.provider.IAIK());
??


-----Original Message-----
From: joyce
To: iaik-jce@iaik.at
Sent: 11/30/00 10:49 AM
Subject: [iaik-jce] Way to add security provider ??

Dear all,

A signed applet is written to read private key from a PKCS#12 file. Two
methods are used to set security provider. Both of them run properly in
JBuilder Enterprise 4.0. But some problems in appletviewer

(1) Mehtod 1:
   iaik.security.provider.IAIK.addAsProvider(true);

Runtime error occurs
    class iaik.pkcs.PKCSException - iaik.java.security.NoSuchAlgorithm
    Exception: No implementation for PbeWithSHAAnd3-KeyTripleDES-CBC

(2) Method 2:
    Security.addProvider((IAIK) new iaik.security.provider.IAIK());

Compile error occurs:
    addProvider(java.security.Provider) in java.security.Security cannot
be applied to
(iaik.security.provider.IAIK) Security.addProvider ((IAIK) new IAIK());


Please kindly tell me the right way to set security provider.

Thanks in advanced.

Regards,
Joyce

*************************
Applet Code :

import java.applet.*;
import java.io.*;
import java.awt.*;

// read x509Certificate and PKCS#12 files
import java.math.*;
import java.security.cert.*;
import java.security.interfaces.*;
import iaik.pkcs.pkcs8.*;
import iaik.pkcs.pkcs12.*;
import iaik.security.rsa.*;
import iaik.pkcs.*;
import iaik.asn1.*;
import iaik.asn1.structures.*;
import java.security.Security;
import iaik.security.provider.IAIK;

public class ReadFileNS extends Applet {
  public void init() {
    // **** set security provider - Method 1 *******
   iaik.security.provider.IAIK.addAsProvider(true);

    // **** set security provider - Method 2  ********
    //Security.addProvider((IAIK) new iaik.security.provider.IAIK());

    try {
      StringWriter sw = new StringWriter();
      sw.write("Hello\n");
        java.security.interfaces.RSAPrivateKey privKey = null;
        try {
          PKCS12 p12 = new PKCS12(new FileInputStream(PFX));
          if (p12 != null) {
               p12.decrypt(password);
               KeyBag kBag = p12.getKeyBag();
               if (kBag != null) {
                  privKey = (java.security.interfaces.RSAPrivateKey)
kBag.getPrivateKey();
                  if (privKey != null) {
                      BigInteger valPrivMod = privKey.getModulus();
                      sw.write("Modulus(bn): " + valPrivMod + "\n");
                  }
              }
         }
      setLayout (new BorderLayout());
      add (new TextArea (sw.toString()), BorderLayout.CENTER);
    } catch (Exception ex) {
      System.out.println("ReadFileNS(): " + ex.getClass() + " - " +
ex.getMessage());
    }
  }
}


--
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

--
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