private byte[] calculateCMSKeyChecksum(byte[] key){
  byte[] result=new byte[8];
  sha1.update(key,0,key.length);
  sha1.doFinal(digest,0);
  System.arraycopy(digest,0,result,0,8);
  return result;
}

private byte [ ] calculateCMSKeyChecksum ( byte [ ] key ) { byte [ ] result = new byte [ 8 ] ; sha1 . update ( key , 0 , key . length ) ; sha1 . doFinal ( digest , 0 ) ; System . arraycopy ( digest , 0 , result , 0 , 8 ) ; return result ; }
some key wrap algorithms make use of the key checksum defined in cms [ cms - algorithms ] . this is used to provide an integrity check value for the key being wrapped . the algorithm is - compute the 20 octet sha - 1 hash on the key being wrapped . - use the first 8 octets of this hash as the checksum value . for details see http : / / www . w3 . org / tr / xmlenc - core / # sec - cmskeychecksum
