harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vladimir Ivanov (JIRA)" <j...@apache.org>
Subject [jira] Created: (HARMONY-1148) [classlib][security] compatibility: method MessageDigest.digest(..) throws different exception on RI and Harmony
Date Fri, 11 Aug 2006 05:00:13 GMT
[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

        

Mime
View raw message