Get intermediate MessageDigest state?

David M. Lloyd david.lloyd at redhat.com
Fri May 23 01:49:26 UTC 2014


On 05/22/2014 07:34 PM, Bernd Eckenfels wrote:
> Hello,
>
> for some applications I need to safe and resume the state of a
> MessageDigest implementation (SHA1 and others). I wonder if there has
> been any discussion about exporting states from Digesters or Cipher
> Streams?
>
> For MD5 there is a implementation which supports this, but of course I
> would prefer JCE provider (especially if I can get a speed up with
> intrinsics)
>
> https://code.google.com/p/project-penny/wiki/RecMD5
>
> I can imagine first a getter/setter for the state, but also (with
> help of clone) using the digest() method could be possible (at least
> for some digest algorithms).

Using MessageDigest.clone() is the usual approach.  Theoretically 
though, some providers won't be cloneable; the only practical recourse 
in this case is to replay the whole of the input, unfortunately.


-- 
- DML



More information about the security-dev mailing list