harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ruth Cao" <ruoshe...@gmail.com>
Subject Re: [classlib][security]different behavior between Harmony and RI in MessageDigest.digest(byte[], int, int)
Date Tue, 23 Jan 2007 13:45:08 GMT
2007/1/23, Spark Shen <smallsmallorgan@gmail.com>:
>
> IMO, all these engineXXX methods are from it's super class
> MessageDigestSpi.
> And there is a paragraph on spec:


Yes. MessageDigestSpi contains several such methods. For instance,
engineDigest() is one of them.

However, MessageDigestSpi.engineDigest(byte[], int, int) is not an abstract
one. According to the impl code, it depends on the result on engineDigest().

So maybe my question should be "What behavior should engineDigest(byte[],
int, int) have when engineDigest() returns null?". So far RI throws NPE
while Harmony silently returns 0.

Any idea or comments?

<cite>
> Note that this class is abstract and extends from MessageDigestSpi for
> historical reasons. Application developers should only take notice of the
> methods defined in this MessageDigest class; all the methods in the
> superclass are intended for cryptographic service providers who wish to
> supply their own implementations of message digest algorithms.
> </cite>
>
> So, this exception thrown senario is implementation dependent. I'd prefer
> to
> regards it as non bug difference.
>
> Best regards
> 2007/1/23, Ruth Cao <ruoshen.c@gmail.com>:
> >
> > Hello all,
> >
> > I've found that MessageDigest_Impl1Test in security module, the
> following
> > test case[1] passes on Harmony but fails on *RI*. RI throws
> > NullPointerException here.
> >
> > Is it a non-bug difference or a bug? Would any security expert give some
> > suggestions?
> >
> > Thanks in advance.
> >
> > [1] public class MyMessageDigest1 extends MessageDigest {
> >
> >    public boolean runEngineReset = false;
> >    public boolean runEngineDigest = false;
> >    public boolean runEngineUpdate1 = false;
> >    public boolean runEngineUpdate2 = false;
> >
> >    public MyMessageDigest1() {
> >        super(null);
> >    }
> >
> >    public MyMessageDigest1(String algorithm) {
> >        super(algorithm);
> >    }
> >
> >    public void engineReset() {
> >        runEngineReset = true;
> >    }
> >
> >    public byte[] engineDigest() {
> >        runEngineDigest = true;
> >        return null;
> >    }
> >
> >    public void engineUpdate(byte arg0) {
> >        runEngineUpdate1 = true;
> >    }
> >
> >    public void engineUpdate(byte[] arg0, int arg1, int arg2) {
> >        runEngineUpdate2 = true;
> >    }
> > }
> >
> > public void testDigestbyteArrayintint() throws Exception {
> >        MyMessageDigest1 md = new MyMessageDigest1("ABC");
> >        byte[] b = {1, 2, 3, 4, 5};
> >        assertEquals("incorrect result", 0, md.digest(b, 2, 3));
> > //$NON-NLS-1$
> > }
> >
> > --
> > Best regards,
> >
> > Ruth Cao
> > China Software Development Lab, IBM
> >
> >
>
>
> --
> Spark Shen
> China Software Development Lab, IBM
>
>


-- 
Best regards,

Ruth Cao
China Software Development Lab, IBM

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message