You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by Hölzl, Dominik <Do...@fabasoft.com> on 2020/02/24 12:04:41 UTC

HSMF enhancements

Hello!

Can somebody please have a look https://github.com/apache/poi/pull/167?

Thank you and regards,
Dominik Hölzl


AW: AW: HSMF enhancements

Posted by Hölzl, Dominik <Do...@fabasoft.com>.
Hello!

Thank you!
I didn't know that, your CRC32-code works perfectly. All Unit-Tests are OK with it.

Regards,
Dominik

Von: Andreas Beeker <ki...@apache.org>
Gesendet: Dienstag, 3. März 2020 23:32
An: dev@poi.apache.org
Betreff: Re: AW: HSMF enhancements

Hello Dominik,

thank you very much for your explanations!

I'll replace the crc code by the following - we have commons codec anyway as a dependency, j.u.z.CRC32 can be used likewise:


static private long calculateCRC32(byte[] buf, int off, int len) {

    PureJavaCrc32 crc = new PureJavaCrc32();

    // set initial crc value to 0

    crc.update( new byte[] {-1,-1,-1,-1}, 0, 4);

    crc.update(buf, off, len);

    return ~crc.getValue() & 0xFFFFFFFFL;

}

I haven't finished with the rest yet, but the next release will anyway take a while ...

Andi.


Re: AW: HSMF enhancements

Posted by Andreas Beeker <ki...@apache.org>.
Hello Dominik,

thank you very much for your explanations!

I'll replace the crc code by the following - we have commons codec anyway as a dependency, j.u.z.CRC32 can be used likewise:

static private long calculateCRC32(byte[] buf, int off, int len) {
    PureJavaCrc32 crc = new PureJavaCrc32(); // set initial crc value to 0 crc.update( new byte[] {-1,-1,-1,-1}, 0, 4); crc.update(buf, off, len); return ~crc.getValue() & 0xFFFFFFFFL; }


I haven't finished with the rest yet, but the next release will anyway take a while ...

Andi.


AW: HSMF enhancements

Posted by Hölzl, Dominik <Do...@fabasoft.com>.
> -----Ursprüngliche Nachricht-----

> Von: Andreas Beeker <ki...@apache.org>

> Gesendet: Montag, 2. März 2020 00:24

> An: POI Developers List <de...@poi.apache.org>

> Cc: Hölzl, Dominik <Do...@fabasoft.com>

> Betreff: Re: HSMF enhancements

>

> Hello Dominik,

>

> I'm having a look at the patch.

>

> Where is the CRC32 code from? ... and please point me to the

> documentation of the GUID logic.

>

> Thank you and best wishes,

> Andi

>

> On 24.02.20 13:04, Hölzl, Dominik wrote:

> > Hello!

> >

> > Can somebody please have a look

> https://github.com/apache/poi/pull/167?

> >

> > Thank you and regards,

> > Dominik Hölzl

> >

> >

>





Hello!



The GUID-logic is exactly documented here:



https://docs.microsoft.com/en-us/openspecs/exchange_server_protocols/ms-oxmsg/b046868c-9fbf-41ae-9ffb-8de2bd4eec82



(Chapter 2.2.3 Named Property Mapping Storage)



As there is no explicit documentation on the CRC-32 parameters there (2.2.3.2.2.1 Stream ID Equation - the only hint is "X25" which seems to be a dead end), I grabbed this from here:



https://github.com/yorkshiretwist/ReadAnOutlookMsg/blob/master/OutlookStorage.cs

(Seems to be originated from https://github.com/jukka/jtnef/blob/master/src/net/freeutils/tnef/CompressedRTFInputStream.java)



The only thing I needed from there were the CRC-32 parameters, which are poly=0x04C11DB7 (which is the "default" CRC-32 value), init=0x00000000, xor=0x00000000, revin=true, revout=true.

This leads to the check value of 0x2DFD2D88 which can e.g. be tested here: http://www.zorc.breitbandkatze.de/crc.html



Public CRC32 algorithm implementation is broadly available.

https://en.wikipedia.org/wiki/Cyclic_redundancy_check



Regards,

Dominik



Re: HSMF enhancements

Posted by Andreas Beeker <ki...@apache.org>.
Hello Dominik,

I'm having a look at the patch.

Where is the CRC32 code from? ... and please point me to the documentation of the GUID logic.

Thank you and best wishes,
Andi

On 24.02.20 13:04, Hölzl, Dominik wrote:
> Hello!
>
> Can somebody please have a look https://github.com/apache/poi/pull/167?
>
> Thank you and regards,
> Dominik Hölzl
>
>



Re: HSMF enhancements

Posted by Andreas Beeker <ki...@apache.org>.
Hello Dominik,

thank you for your patch!

I've applied a modified version of it via #1874990 [1].

The reasons for my modifications are:
- remove the custom CRC32 code:
   I don't want to mix technical code with module specific code ... thankfully it could be calculated with off the shelf CRC32 classes anyway.
- use enums instead of String constants (... where we didn't have already a lot of legacy constants)
- try to break the cyclomatic complexity:
   wherever I see lots of nested ifs, I introduce private methods to limit the scope of variables
- In the ByteChunkDeferred class, the linked node can be read multiple times and we don't face exhausted InputStreams.

Best wishes,
Andi


[1] https://svn.apache.org/viewvc?view=revision&revision=1874990

On 24.02.20 13:04, Hölzl, Dominik wrote:
> Hello!
>
> Can somebody please have a look https://github.com/apache/poi/pull/167?
>
> Thank you and regards,
> Dominik Hölzl
>
>