question: 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 ; }
target:  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.