You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Vladimir Ivanov (JIRA)" <ji...@apache.org> on 2006/08/11 07:00:13 UTC

[jira] Created: (HARMONY-1148) [classlib][security] compatibility: method MessageDigest.digest(..) throws different exception on RI and Harmony

[classlib][security] compatibility: method  MessageDigest.digest(..) throws different exception on RI and Harmony
-----------------------------------------------------------------------------------------------------------------

                 Key: HARMONY-1148
                 URL: http://issues.apache.org/jira/browse/HARMONY-1148
             Project: Harmony
          Issue Type: Bug
          Components: Classlib
            Reporter: Vladimir Ivanov
            Priority: Minor


The method MessageDigest.digest(byte[] buf, int offset, int len) thorws IllegalArgumentException for invalid params while RI throws DigestException/ ArrayIndexOutOfBoundsException.
Seems, it may be marked as 'non-bug diff'.

====================== test.java =========================
import java.security.*;

public class test  { 

    public static void main (String[] args) { 
        // len < 0
        try {                                 
            MessageDigest.getInstance("SHA").digest(new byte[] {2,2}, 0, -1);
        } catch (Exception e) {
            e.printStackTrace();
        } 
        // off < 0
        try {
            MessageDigest.getInstance("SHA").digest(new byte[] {2,2}, -100, 57);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
======================================================

Output:
C:\tmp\tmp17>C:\jrockit-jdk1.5.0-windows-ia32\bin\java.exe -cp . -showversion test
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
BEA WebLogic JRockit(R) (build dra-38972-20041208-2001-win-ia32, R25.0.0-75, GC: System optimized over throughput (initial strategy singleparpar))

java.security.DigestException: Length must be at least 20 for SHA-1digests
        at sun.security.provider.DigestBase.engineDigest(DigestBase.java:152)
        at java.security.MessageDigest$Delegate.engineDigest(MessageDigest.java:536)
        at java.security.MessageDigest.digest(MessageDigest.java:336)
        at test.main(test.java:8)
java.lang.ArrayIndexOutOfBoundsException
        at sun.security.provider.DigestBase.i2bBig(DigestBase.java:252)
        at sun.security.provider.SHA.implDigest(SHA.java:96)
        at sun.security.provider.DigestBase.engineDigest(DigestBase.java:161)
        at java.security.MessageDigest$Delegate.engineDigest(MessageDigest.java:536)
        at java.security.MessageDigest.digest(MessageDigest.java:336)
        at test.main(test.java:14)

C:\tmp\tmp17>C:\harmony\classlib1.5\deploy\jdk\jre\bin\java.exe -cp . -showversion test
java version 1.5 (subset)

(c) Copyright 1991, 2006 The Apache Software Foundation or its licensors, as applicable.
java.lang.IllegalArgumentException: Incorrect offset/len parameters
        at java.security.MessageDigest.digest(MessageDigest.java:25)
        at test.main(test.java:8)
java.lang.IllegalArgumentException: Incorrect offset/len parameters
        at java.security.MessageDigest.digest(MessageDigest.java:25)
        at test.main(test.java:14)


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Updated: (HARMONY-1148) [classlib][security] compatibility: method MessageDigest.digest(..) throws different exception on RI and Harmony

Posted by "Alexey Petrenko (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HARMONY-1148?page=all ]

Alexey Petrenko updated HARMONY-1148:
-------------------------------------

    Attachment: HARMONY-1148.diff

Fix for this issue.

> [classlib][security] compatibility: method  MessageDigest.digest(..) throws different exception on RI and Harmony
> -----------------------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-1148
>                 URL: http://issues.apache.org/jira/browse/HARMONY-1148
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Vladimir Ivanov
>            Priority: Minor
>         Attachments: HARMONY-1148.diff
>
>
> The method MessageDigest.digest(byte[] buf, int offset, int len) thorws IllegalArgumentException for invalid params while RI throws DigestException/ ArrayIndexOutOfBoundsException.
> Seems, it may be marked as 'non-bug diff'.
> ====================== test.java =========================
> import java.security.*;
> public class test  { 
>     public static void main (String[] args) { 
>         // len < 0
>         try {                                 
>             MessageDigest.getInstance("SHA").digest(new byte[] {2,2}, 0, -1);
>         } catch (Exception e) {
>             e.printStackTrace();
>         } 
>         // off < 0
>         try {
>             MessageDigest.getInstance("SHA").digest(new byte[] {2,2}, -100, 57);
>         } catch (Exception e) {
>             e.printStackTrace();
>         }
>     }
> }
> ======================================================
> Output:
> C:\tmp\tmp17>C:\jrockit-jdk1.5.0-windows-ia32\bin\java.exe -cp . -showversion test
> java version "1.5.0"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
> BEA WebLogic JRockit(R) (build dra-38972-20041208-2001-win-ia32, R25.0.0-75, GC: System optimized over throughput (initial strategy singleparpar))
> java.security.DigestException: Length must be at least 20 for SHA-1digests
>         at sun.security.provider.DigestBase.engineDigest(DigestBase.java:152)
>         at java.security.MessageDigest$Delegate.engineDigest(MessageDigest.java:536)
>         at java.security.MessageDigest.digest(MessageDigest.java:336)
>         at test.main(test.java:8)
> java.lang.ArrayIndexOutOfBoundsException
>         at sun.security.provider.DigestBase.i2bBig(DigestBase.java:252)
>         at sun.security.provider.SHA.implDigest(SHA.java:96)
>         at sun.security.provider.DigestBase.engineDigest(DigestBase.java:161)
>         at java.security.MessageDigest$Delegate.engineDigest(MessageDigest.java:536)
>         at java.security.MessageDigest.digest(MessageDigest.java:336)
>         at test.main(test.java:14)
> C:\tmp\tmp17>C:\harmony\classlib1.5\deploy\jdk\jre\bin\java.exe -cp . -showversion test
> java version 1.5 (subset)
> (c) Copyright 1991, 2006 The Apache Software Foundation or its licensors, as applicable.
> java.lang.IllegalArgumentException: Incorrect offset/len parameters
>         at java.security.MessageDigest.digest(MessageDigest.java:25)
>         at test.main(test.java:8)
> java.lang.IllegalArgumentException: Incorrect offset/len parameters
>         at java.security.MessageDigest.digest(MessageDigest.java:25)
>         at test.main(test.java:14)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Assigned: (HARMONY-1148) [classlib][security] compatibility: method MessageDigest.digest(..) throws different exception on RI and Harmony

Posted by "Mikhail Loenko (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HARMONY-1148?page=all ]

Mikhail Loenko reassigned HARMONY-1148:
---------------------------------------

    Assignee: Mikhail Loenko

> [classlib][security] compatibility: method  MessageDigest.digest(..) throws different exception on RI and Harmony
> -----------------------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-1148
>                 URL: http://issues.apache.org/jira/browse/HARMONY-1148
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Vladimir Ivanov
>         Assigned To: Mikhail Loenko
>            Priority: Minor
>         Attachments: HARMONY-1148.diff
>
>
> The method MessageDigest.digest(byte[] buf, int offset, int len) thorws IllegalArgumentException for invalid params while RI throws DigestException/ ArrayIndexOutOfBoundsException.
> Seems, it may be marked as 'non-bug diff'.
> ====================== test.java =========================
> import java.security.*;
> public class test  { 
>     public static void main (String[] args) { 
>         // len < 0
>         try {                                 
>             MessageDigest.getInstance("SHA").digest(new byte[] {2,2}, 0, -1);
>         } catch (Exception e) {
>             e.printStackTrace();
>         } 
>         // off < 0
>         try {
>             MessageDigest.getInstance("SHA").digest(new byte[] {2,2}, -100, 57);
>         } catch (Exception e) {
>             e.printStackTrace();
>         }
>     }
> }
> ======================================================
> Output:
> C:\tmp\tmp17>C:\jrockit-jdk1.5.0-windows-ia32\bin\java.exe -cp . -showversion test
> java version "1.5.0"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
> BEA WebLogic JRockit(R) (build dra-38972-20041208-2001-win-ia32, R25.0.0-75, GC: System optimized over throughput (initial strategy singleparpar))
> java.security.DigestException: Length must be at least 20 for SHA-1digests
>         at sun.security.provider.DigestBase.engineDigest(DigestBase.java:152)
>         at java.security.MessageDigest$Delegate.engineDigest(MessageDigest.java:536)
>         at java.security.MessageDigest.digest(MessageDigest.java:336)
>         at test.main(test.java:8)
> java.lang.ArrayIndexOutOfBoundsException
>         at sun.security.provider.DigestBase.i2bBig(DigestBase.java:252)
>         at sun.security.provider.SHA.implDigest(SHA.java:96)
>         at sun.security.provider.DigestBase.engineDigest(DigestBase.java:161)
>         at java.security.MessageDigest$Delegate.engineDigest(MessageDigest.java:536)
>         at java.security.MessageDigest.digest(MessageDigest.java:336)
>         at test.main(test.java:14)
> C:\tmp\tmp17>C:\harmony\classlib1.5\deploy\jdk\jre\bin\java.exe -cp . -showversion test
> java version 1.5 (subset)
> (c) Copyright 1991, 2006 The Apache Software Foundation or its licensors, as applicable.
> java.lang.IllegalArgumentException: Incorrect offset/len parameters
>         at java.security.MessageDigest.digest(MessageDigest.java:25)
>         at test.main(test.java:8)
> java.lang.IllegalArgumentException: Incorrect offset/len parameters
>         at java.security.MessageDigest.digest(MessageDigest.java:25)
>         at test.main(test.java:14)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira