×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Nov 2008
    Posts
    4

    Preverify ERROR in Eclipse while using SATSA-crypto.jar

    I have created simple application to encrypt the string using Cipher class like below:
    This code snippet I got from the forums.nokia;
    In this The string "THIS IS A SECRET MESSAGE" is encrypted and decrypted using the key "SECRET!!" .



    Code:
    import java.security.InvalidKeyException;
    import java.security.NoSuchAlgorithmException;
     
    import javax.microedition.lcdui.Command;
    import javax.microedition.lcdui.CommandListener;
    import javax.microedition.lcdui.Displayable;
    import javax.microedition.lcdui.Form;
    import javax.microedition.lcdui.Item;
    import javax.microedition.lcdui.TextBox;
    import javax.microedition.lcdui.TextField;
     
    import javax.crypto.BadPaddingException;
    import javax.crypto.Cipher;
    import javax.crypto.IllegalBlockSizeException;
    import javax.crypto.NoSuchPaddingException;
    import javax.crypto.ShortBufferException;
    import javax.crypto.spec.SecretKeySpec;
     
     
     
    public class FirstForm extends Form implements CommandListener {
     
    	
    	TextField txtData=new TextField("Enter the Data","",10,TextField.ANY);
    	
    	Command cmdEncrypt=new Command("Encrypt",Command.SCREEN,1);
    	
    	public FirstForm(String arg0) 
    	{
    		super(arg0);
    		this.append(txtData);
    		this.addCommand(cmdEncrypt);
    		this.setCommandListener(this);
    		
    	}
     
    	
     
    	public void commandAction(Command cmd, Displayable frm) 
    	{
    		
    		if(cmd==this.cmdEncrypt)
    		{
    			
    			System.out.println("Command Is Pressed.......");
    			byte[] msg = "THIS IS A SECRET MESSAGE".getBytes();
    			byte[] enMsg = new byte[10000];
    			byte[] deMsg = new byte[10000];
    			 
    			//create new cipher using DES algorithm
    			try {
    				
    				Cipher c = Cipher.getInstance("DES");
    				 
    				//our raw byte[] key - please note that since we use DES algorithm,
    				//the key must be 8 bytes long
    				byte[] b = "SECRET!!".getBytes();
    				 
    				//init the cipher to encrypt the data
    				c.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(b,0,b.length,"DES"));
    				int numBytes = c.doFinal(msg, 0, msg.length, enMsg, 0);
    				System.out.println("Encrypted Message is"+enMsg); 
    				
    				
    				//init the cipher to decrypt the data
    				c.init(Cipher.DECRYPT_MODE, new SecretKeySpec(b,0,b.length,"DES"));
    				numBytes = c.doFinal(enMsg, 0, numBytes, deMsg, 0);
    				String s = new String(deMsg,0,numBytes);
    				System.out.println("Decrypted Message is"+s);
    				
    				
    			} catch (InvalidKeyException e) {
    				// TODO Auto-generated catch block
    				e.printStackTrace();
    			} catch (NoSuchAlgorithmException e) {
    				// TODO Auto-generated catch block
    				e.printStackTrace();
    			} catch (NoSuchPaddingException e) {
    				// TODO Auto-generated catch block
    				e.printStackTrace();
    			} catch (IllegalStateException e) {
    				// TODO Auto-generated catch block
    				e.printStackTrace();
    			} catch (ShortBufferException e) {
    				// TODO Auto-generated catch block
    				e.printStackTrace();
    			} catch (IllegalBlockSizeException e) {
    				// TODO Auto-generated catch block
    				e.printStackTrace();
    			} catch (BadPaddingException e) {
    				// TODO Auto-generated catch block
    				e.printStackTrace();
    			}
    			
    		}
     
    	}
     
    }

    after clicking on command button the Encrypted and decrypted sting is shown on the console
    I have tested this code with wtk2.5.2.
    This code works fine with sun'sWTK 2.5.2

    But when; I have created project with the eclippse and wtk22
    1) I added the satsa-crypto.jar in projrct->Properties->java-Builder-Path in "Library tab"
    2)I Had also checked the checkbox before satsa-crypto.jar "Order-Of-Export Tab"

    I am using the Ant Built
    After Building I got Error saying::
    Code:
    [j2mepolish] preverify:Error preverifying class u
    [j2mepolish] preverify:    VERIFIER ERROR u.a(ILm;Lw;)V:
    [j2mepolish] preverify:Cannot find class com/sun/midp/ssl/Key
    [j2mepolish] Preverify call failed: 1
    [j2mepolish] C:\WTK22\bin\preverify.exe -classpath D:\Java\J2ME-Polish\import\midp-2.0.jar;D:\Java\J2ME-Polish\import\cldc-1.0.jar; -d D:\nitins_workspace\Encrypt\build\real\Generic\midp2\de_DE\obfuscated -nofp -nofinalize -nonative D:\nitins_workspace\Encrypt\build\real\Generic\midp2\de_DE\obfuscated
     
    BUILD FAILED
    What may be the reason of this??

  2. #2
    Regular Contributor
    Join Date
    Jul 2008
    Location
    Faridabad(Delhi NCR)
    Posts
    343

    Re: Preverify ERROR in Eclipse while using SATSA-crypto.jar

    May BE eclipse didn find aditional APIs for Saste thats y its giving problem
    Anshu Chauhan
    J2me Developer

  3. #3
    Registered User
    Join Date
    Nov 2008
    Posts
    4

    Re: Preverify ERROR in Eclipse while using SATSA-crypto.jar

    Thanks for reply.
    can u tel me how to specify specify these API's.
    I already imported all the packages thae r req. for this.

  4. #4
    Nokia Developer Champion
    Join Date
    Apr 2003
    Location
    USA, CA
    Posts
    7,192

    Re: Preverify ERROR in Eclipse while using SATSA-crypto.jar

    WTK 2.2 only supports this set of Java APIs
    The J2ME Wireless Toolkit implements impressive capabilities which are exposed through standard APIs. The APIs are defined through the Java Community Process (JCP):

    * Connected Limited Device Configuration (CLDC) 1.1 (JSR 139)
    * Mobile Information Device Profile (MIDP) 2.0 (JSR 118)
    * Java Technology for the Wireless Industry (JTWI) 1.0 (JSR 185)
    * Wireless Messaging API (WMA) 2.0 (JSR 205)
    * Mobile Media API (MMAPI) 1.1 (JSR 135)
    * PDA Optional Packages for the J2ME Platform (JSR 75)
    * Java APIs for Bluetooth (JSR 82)
    * J2ME Web Services Specification (JSR 172)
    * Mobile 3D Graphics API for J2ME (JSR 184)
    If it works with WTK 2.5.2, why would you need to work with WTK2.2?

    Hartti

  5. #5
    Registered User
    Join Date
    Nov 2008
    Posts
    4

    Smile Re: Preverify ERROR in Eclipse while using SATSA-crypto.jar

    Thanks for the reply Hartti.

    why would you need to work with WTK2.2?
    becoz I have alredy did the project in eclipse+wtk2.2;
    1) My project uses "j2mePolish", Here is link below
    http://www.j2mepolish.org/cms/leftse...roduction.html
    2) I want to add the functionality of "Encryption" of some data which is clients requirement now.
    3)For this first i have created this class(code is posted at starting of this tread) separately using the simple notepad editor and tested it with "Sun java wireless Toolkit 2.5.2 for CLDC". This class alone works there fine; but when I have added the class in my project; I unable to build it with the "Eclipse+wtk2.2" as well as"Eclipse+wtk2.5.2"
    4) For building my project I am using Ant Build.

    It gives following error
    Code:
    [j2mepolish] preverifying for device [Generic/midp2].
    [j2mepolish] preverify:Error preverifying class com.sun.satsa.crypto.RSACipher
    [j2mepolish] Preverify call failed: 1
    [j2mepolish] C:\WTK22\bin\preverify.exe -classpath D:\Java\J2ME-Polish\import\midp-2.0.jar;D:\Java\J2ME-Polish\import\cldc-1.0.jar; -d D:\nitins_workspace\Encrypt\build\real\Generic\midp2\de_DE\classes -nofp -nofinalize -nonative D:\nitins_workspace\Encrypt\build\real\Generic\midp2\de_DE\classes
    [j2mepolish] preverify:    VERIFIER ERROR com/sun/satsa/crypto/RSACipher.init(ILjava/security/Key;Ljava/security/spec/AlgorithmParameterSpec;)V:
    [j2mepolish] preverify:Cannot find class com/sun/midp/ssl/Key
    
    BUILD FAILED

    Build fells with "Eclipse+wtk2.2" as well as"Eclipse+wtk2.5.2"
    I have already Imported all the Permissions (or Packages) required for using SATSA-crypto API's
    What may be the reason??

    Thanks
    waiting for reply..
    N.D.

Similar Threads

  1. -- Java development for S80 with Eclipse --
    By Kalypso in forum Mobile Java Tools & SDKs
    Replies: 3
    Last Post: 2011-03-17, 10:35
  2. Please HELP. Impossible Eclipse + Carbide.j
    By videador in forum Mobile Java Tools & SDKs
    Replies: 13
    Last Post: 2007-03-22, 06:06
  3. Eclipse 3.1.2 || Eclipse 3.2
    By rolecram in forum Mobile Java Tools & SDKs
    Replies: 8
    Last Post: 2007-03-12, 23:55
  4. Carbide.j 1.5 Eclipse 3.1 integration problem !
    By osman911 in forum Mobile Java Tools & SDKs
    Replies: 3
    Last Post: 2006-12-15, 10:32
  5. Nokia Connectivity Framework , Eclipse and a BT Dongle
    By shriansh in forum Bluetooth Technology
    Replies: 4
    Last Post: 2006-02-15, 19:04

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •