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

[iaik-jce] very simple problem for you



Title: very simple problem for you

Hi guys!
Would you help me?   Please!!!
For your experienced eyes it is easy to find what's wrong.
By any chance have you got an applet demo? IAIK_JCE demo is fine and very helpful.
I attached zip file which contains everything and you don't have to set up any IDE. Unpack it and try to run in IE try.html.

<<to_iaik.zip>>
I tested IAIK encryption/decryption in IDE (VisualAge, Jbuilder ) and it works fine. I need to develop an applet, but I ran into problem. I followed all your docs according the applet issues, so I eliminated package java.security and use iaik.java.security.* instead. I tried to write a very simple applet, which only adds IAIK as a provider:

<HTML>
<HEAD>
<TITLE>Try it</TITLE>
<script language=JavaScript>
<!--
function start()
{
   alert(document.testAppl.smpfun());
}
-->
</SCRIPT>
</HEAD>
<BODY >
<APPLET code=Hello.class name="testAppl" archive=ae.jar width = 0 height = 0>
</APPLET>
</BODY>
</HTML>

where ae.jar is applet edition jar file (I renamed iaik_jce_full_ae.jar).
and got this message: com.ms.security.SecurityExceptionEx(iaik/security/provider/IAIK_addAsProvider): Unable to access system properties


<<...>>

Applet text is next:

import java.awt.Graphics;
import java.applet.*;
import java.util.*;
import iaik.java.security.*;
import javax.crypto.*;
import javax.crypto.spec.*;
import iaik.security.provider.IAIK;
import iaik.security.rsa.*;

public class Hello extends java.applet.Applet
{
   public void paint(Graphics screen)
   {
           //screen.drawString("Hello aaa",5,40);
   }     
public String smpfun()
{
        Tst_Ae();
        return "smpfun from Hello";
}
public void Tst_Ae()
{
        IAIK.addAsProvider(true);  // HERE it fails, but works fine not in an applet
        try
        {
                Cipher rsa1 = null;
                rsa1 = Cipher.getInstance("RSA/ECB/PKCS1Padding", "IAIK");
        }
        catch (iaik.java.security.NoSuchAlgorithmException e)
        {
                throw new RuntimeException(e.toString());
        }
        catch (iaik.java.security.NoSuchProviderException e)
        {
                throw new RuntimeException(e.toString());
        }
        catch (javax.crypto.NoSuchPaddingException e)
        {
                throw new RuntimeException(e.toString());
        }
}
}

This is so far the only problem, on resolving it we are going to purchase from you all neccessary stuff.

Thank you.
Regards Alex Varlamov.
www.e-certify.com
Missisauga
Ontario
Canada

to_iaik.zip