[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1616
  • Last Modified:

PGP cryptix - RuntimeException: NYI

Hi
getting this weird error,
searched the web for an solution but it wont work no mather how i do :S

Downloaded "Java(TM) Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files 5.0" but it doesnt seem to work with my jdk1.5.0_16

Could anyone help with this?
Exception in thread "main" java.lang.RuntimeException: NYI
        at cryptix.jce.provider.elgamal.ElGamalCipher.engineGetParameters(ElGamalCipher.java:120)
        at javax.crypto.Cipher.a(DashoA13*..)
        at javax.crypto.Cipher.init(DashoA13*..)
        at cryptix.openpgp.algorithm.PGPElGamal.encrypt(PGPElGamal.java:550)
        at cryptix.openpgp.packet.PGPPublicKeyEncryptedSessionKeyPacket.encrypt(PGPPublicKeyEncryptedSessionKeyPacket.ja
va:153)
        at cryptix.openpgp.provider.PGPEncryptedMessageBuilder.engineBuild(PGPEncryptedMessageBuilder.java:283)
        at cryptix.message.EncryptedMessageBuilder.build(EncryptedMessageBuilder.java:253)
        at se.cybercomgroup.pm.safe2go.payment.batch.sftp.pgp.EncryptAndSign.main(EncryptAndSign.java:174)

Open in new window

0
Rinkle
Asked:
Rinkle
  • 6
  • 3
1 Solution
 
objectsCommented:
what is it you are trying to do?  appears it is not implemented

0
 
RinkleAuthor Commented:
im trying to run the cryptix examplecode suplied with teh examples: EncryptAndSign.java

package se.cybercomgroup.pm.safe2go.payment.batch.sftp.pgp;
 
/* $Id: EncryptAndSign.java,v 1.3 2005/03/13 17:46:35 woudt Exp $
*
* Copyright (C) 1999-2005 The Cryptix Foundation Limited.
* All rights reserved.
* 
* Use, modification, copying and distribution of this software is subject 
* the terms and conditions of the Cryptix General Licence. You should have 
* received a copy of the Cryptix General License along with this library; 
* if not, you can download a copy from http://www.cryptix.org/ .
*/
 
import cryptix.message.EncryptedMessageBuilder;
import cryptix.message.KeyBundleMessage;
import cryptix.message.LiteralMessageBuilder;
import cryptix.message.Message;
import cryptix.message.MessageException;
import cryptix.message.MessageFactory;
import cryptix.message.SignedMessageBuilder;
 
import cryptix.openpgp.PGPArmouredMessage;
 
import cryptix.pki.KeyBundle;
import cryptix.pki.KeyBundleException;
 
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
 
import java.security.NoSuchAlgorithmException;
import java.security.UnrecoverableKeyException;
 
import java.util.Collection;
 
 
/**
* Detailed example for encrypting and signing a message.
* This example assumes that the GenerateAndWriteKey example has been run first.
*
* @author  Edwin Woudt <edwin@cryptix.org>
* @version $Revision: 1.3 $
*/
public class EncryptAndSign {
 
   public static void main (String[] args) {
 
	   System.out.println("BAM BAM BAM BAM BAM BAM BAM BAM");
       //**********************************************************************
       // Dynamically register both the Cryptix JCE and Cryptix OpenPGP 
       // providers. 
       //**********************************************************************
       java.security.Security.addProvider(
    		   new cryptix.jce.provider.CryptixCrypto() );
       java.security.Security.addProvider(
    		   new cryptix.openpgp.provider.CryptixOpenPGP() );
           
       
       //**********************************************************************
       // First read the keys. 
       //**********************************************************************
       KeyBundle publicBob   = null;
       KeyBundle secretAlice = null;
       
       try {
 
           FileInputStream in; Collection msgs; KeyBundleMessage kbm;
           
           MessageFactory mf = MessageFactory.getInstance("OpenPGP");
 
           in = new FileInputStream("P:\\publicpgp.asc");
           msgs = mf.generateMessages(in);
           kbm = (KeyBundleMessage)msgs.iterator().next();
           publicBob = kbm.getKeyBundle();
           in.close();
       
           in = new FileInputStream("P:\\secretpgp.asc");
           msgs = mf.generateMessages(in);
           kbm = (KeyBundleMessage)msgs.iterator().next();
           secretAlice = kbm.getKeyBundle();
           in.close();
       
       } catch (IOException ioe) {
           System.err.println("IOException... You did remember to run the "+
               "GenerateAndWriteKey example first, right?");
           ioe.printStackTrace();
           System.exit(-1);
       } catch (NoSuchAlgorithmException nsae) {
           System.err.println("Cannot find the OpenPGP MessageFactory. "+
               "This usually means that the Cryptix OpenPGP provider is not "+
               "installed correctly.");
           nsae.printStackTrace();
           System.exit(-1);
       } catch (MessageException me) {
           System.err.println("Reading keybundle failed.");
           me.printStackTrace();
           System.exit(-1);
       }
 
 
       //**********************************************************************
       //  Build the literal message.
       //**********************************************************************
       Message msg = null;
       
       try {
           String data = "This is a test message.\n" +
                         "This is another line.\n" +
                         "This is Rijad beating the  out of Niclas!";
           LiteralMessageBuilder lmb = 
               LiteralMessageBuilder.getInstance("OpenPGP");
           lmb.init(data);
           msg = lmb.build();
       } catch (NoSuchAlgorithmException nsae) {
           System.err.println("Cannot find the OpenPGP LiteralMessageBuilder."+
               " This usually means that the Cryptix OpenPGP provider is not "+
               "installed correctly.");
           nsae.printStackTrace();
           System.exit(-1);
       } catch (MessageException me) {
           System.err.println("Creating the literal message failed.");
           me.printStackTrace();
           System.exit(-1);
       }
       
 
       //**********************************************************************
       // Sign the message.
       //
       // Note that signing usually comes before encryption, such that
       // unauthorized parties cannot see who signed the message.
       //**********************************************************************
       try {
       
           SignedMessageBuilder smb = 
               SignedMessageBuilder.getInstance("OpenPGP");
           
           // use the following line for compatibility with older PGP versions
 
           // SignedMessageBuilder smb = 
           //     SignedMessageBuilder.getInstance("OpenPGP/V3");
           
           smb.init(msg);
           smb.addSigner(secretAlice, "passphrase".toCharArray());
 
           msg = smb.build();
       
       } catch (NoSuchAlgorithmException nsae) {
           System.err.println("Cannot find the OpenPGP SignedMessageBuilder. "+
               "This usually means that the Cryptix OpenPGP provider is not "+
               "installed correctly.");
           nsae.printStackTrace();
           System.exit(-1);
       } catch (UnrecoverableKeyException uke) {
           System.err.println("Incorrect passphrase.");
           uke.printStackTrace();
           System.exit(-1);
       } catch (MessageException me) {
           System.err.println("Generating the message failed.");
           me.printStackTrace();
           System.exit(-1);
       }
 
 
       //**********************************************************************
       // Encrypt the message.
       //**********************************************************************
       try {
           
           EncryptedMessageBuilder emb = 
               EncryptedMessageBuilder.getInstance("OpenPGP");
           emb.init(msg);
           emb.addRecipient(publicBob);
           msg = emb.build();
       
       } catch (NoSuchAlgorithmException nsae) {
           System.err.println("Cannot find the OpenPGP "+
               "EncryptedMessageBuilder. "+
               "This usually means that the Cryptix OpenPGP provider is not "+
               "installed correctly.");
           nsae.printStackTrace();
           System.exit(-1);
       } catch (MessageException me) {
           System.err.println("Creating the encrypted message failed.");
           me.printStackTrace();
           System.exit(-1);
       }
       
 
       //**********************************************************************
       // Armour the message and write it to disk
       //**********************************************************************
       try {
           
           PGPArmouredMessage armoured;
       
           armoured = new PGPArmouredMessage(msg);
           FileOutputStream out = new FileOutputStream("P:\\encrypted-signed.asc");
           out.write(armoured.getEncoded());
           out.close();
       
       } catch (MessageException me) {
           System.err.println("Writing the encrypted message failed.");
           me.printStackTrace();
           System.exit(-1);
       } catch (IOException ioe) {
           System.err.println("Writing the encrypted message failed.");
           ioe.printStackTrace();
           System.exit(-1);
       }
       
   }
 
}

Open in new window

0
 
objectsCommented:
are you using the openpgp snapshot?
http://www.cryptix.org/cryptix-openpgp-20050418-snap.zip

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
RinkleAuthor Commented:
jep thats the one im using :)
0
 
objectsCommented:
is downgrading your jdk an option?
cryptix is fairly dead afaik so doubt its keeping up with newer jre's.

0
 
objectsCommented:
what did you do with the policy files?
local_policy.jar and US_export_policy.jar need to go in *any* jre's lib/security that needs them
remember you may have multiple jre's installed
0
 
RinkleAuthor Commented:
Ive added them to *all* jre :S

downgrading jdk is not an option, using something other than cryptix is tho.
ive been looking at bouncycastle but dodnt get clever on hor you use it :S
0
 
objectsCommented:
some examples using bountycastle here
http://mindprod.com/jgloss/bouncycastle.html

0
 
CEHJCommented:
0
 
objectsCommented:
I'll see if I can get an example running over here in the morning.


0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 6
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now