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

RE: [iaik-jce] JCE Applet Edition reporting iaik.java.security.SignatureException: Not in signing state.



Andreas,

Thanks for that, now that I have encrypted the String how do I decrypt it (I
do have the X509 certificate accompanying the private and the public keys)?

Regards

Dave
-----Original Message-----
From: iaik-jce-owner@iaik.tu-graz.ac.at
[mailto:iaik-jce-owner@iaik.tu-graz.ac.at]On Behalf Of Andreas Sterbenz
Sent: 22 September 1999 11:21
To: Dave Streeter - IICL Email; iaik-jce@iaik.tu-graz.ac.at
Subject: Re: [iaik-jce] JCE Applet Edition reporting
iaik.java.security.SignatureException: Not in signing state.


You can only either sign or verify, not both at the same time. The
procedure to use is initSign(), update(), sign() (and for verify
respectively).

 Andreas Sterbenz              mailto:Andreas.Sterbenz@iaik.tu-graz.ac.at

-----Ursprüngliche Nachricht-----
Von: Dave Streeter - IICL Email <dave.streeter@iicl.co.uk>
An: <iaik-jce@iaik.tu-graz.ac.at>
Gesendet: Mittwoch, 22. September 1999 11:21
Betreff: [iaik-jce] JCE Applet Edition reporting
iaik.java.security.SignatureException: Not in signing state.


> Attempt 2:
>
> I am trying to encrypt a String with an existing DSA private key, but
the
> following code:
>
> public static void main(String args[])
> {
>  try
>  {
>   iaik.java.security.Security.insertProviderAt(new
> iaik.security.provider.IAIK(), 1);
>   iaik.security.provider.IAIK.addAsProvider(true);
>   String password = "This is a test password numbered 0123456789";
>   iaik.security.dsa.DSAPrivateKey iiclPrivateDsaKey = new
> iaik.security.dsa.DSAPrivateKey(new java.io.FileInputStream(new
> java.io.File("O:\\Technical\\javakey\\iicl_priv")));
>   iaik.security.dsa.DSAPublicKey iiclPublicDsaKey = new
> iaik.security.dsa.DSAPublicKey(new java.io.FileInputStream(new
> java.io.File("O:\\Technical\\javakey\\iicl_pub")));
>   iaik.java.security.Signature dsaSignature =
> iaik.security.dsa.DSA.getInstance("DSA");
>   dsaSignature.initSign(iiclPrivateDsaKey);
>   dsaSignature.initVerify(iiclPublicDsaKey);
>   dsaSignature.update(password.getBytes());
>   byte[] signedPasswordBytes = dsaSignature.sign();
>   dsaSignature.update(password.getBytes());
>   if (!(dsaSignature.verify(signedPasswordBytes)))
>   {
>    System.out.println("StringEncrypt.main(): failed to verify");
>    System.exit(0);
>   }
>   String encryptedPassword = new String(signedPasswordBytes);
>   System.out.println(encryptedPassword);
>  }
>  catch (Exception e)
>  {
>   System.out.println("StringEncrypt.main(): failed with " +
e.getMessage());
>   e.printStackTrace();
>   System.exit(0);
>  }
> }
>
> gives the following error:
>
> StringEncrypt.main(): failed with Not in signing state.
> iaik.java.security.SignatureException: Not in signing state.
>  java.lang.Throwable(java.lang.String)
>  java.lang.Exception(java.lang.String)
>  iaik.java.security.SignatureException(java.lang.String)
>  byte [] iaik.java.security.Signature.sign()
>  void
>
uk.co.streeter.dave.cryptography.test.StringEncryptWithSignature.main(jav
a.l
> ang.String [])
>
> Please help.....
>
> Regards
>
> Dave Streeter
>
>
>



--
Mailinglist-archive at http://jcewww.iaik.tu-graz.ac.at/mailarchive/iaik-jce/maillist.html

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