public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "qianzwang at yahoo dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libgcj/23768] New: doFinal() methods in javax.crypto.Cipher incorrectly resetting cipher state
Date: Wed, 07 Sep 2005 18:34:00 -0000	[thread overview]
Message-ID: <20050907183426.23768.qianzwang@yahoo.com> (raw)

The JCE spec for Cipher.doFinal states:

"Upon finishing, this method resets this cipher object to the state it was in
when previously initialized via a call to init. That is, the object is reset and
available to encrypt or decrypt (depending on the operation mode that was
specified in the call to init) more data."

However, the various doFinal() methods of the Cipher class reset the cipher to
an uninitialized state.  Subsequent calls to update() or doFinal() result in an
IllegalStateException.

The Cipher class contains the following in several doFinal methods:

    ...
    if (state != ENCRYPT_MODE && state != DECRYPT_MODE)
      {
        throw new IllegalStateException("neither encrypting nor decrypting");
      }
    state = INITIAL_STATE;
    ...

The state of the cipher should not be set to INITIAL_STATE after doFinal but
remain either in ENCRYPT_MODE or DECRYPT_MODE.  All of the doFinal methods are
affected by this bug.

This is my first bug report here, so please let me know if more information is
needed such as an executable example.  I'm also not sure (since I didn't see it
in the bug writing guidelines) whether I sould attach a patch for this bug.

The same problem also exists in the latest Classpath codebase.

-- 
           Summary: doFinal() methods in javax.crypto.Cipher incorrectly
                    resetting cipher state
           Product: gcc
           Version: 4.0.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: libgcj
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: qianzwang at yahoo dot com
                CC: gcc-bugs at gcc dot gnu dot org,java-prs at gcc dot gnu
                    dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23768


             reply	other threads:[~2005-09-07 18:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-07 18:34 qianzwang at yahoo dot com [this message]
2005-09-07 18:36 ` [Bug classpath/23768] " pinskia at gcc dot gnu dot org
2005-09-07 18:36 ` pinskia at gcc dot gnu dot org
2005-09-08  5:49 ` csm at gnu dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050907183426.23768.qianzwang@yahoo.com \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).