Hi Mikheil, thank you for the example file.
the sheet protection algo is documented here: http://msdn.microsoft.com/en-us/library/dd920692(v=office.12).aspx below is my junit driver - the method is nearly identical to CryptoFunctions.hashPassword, but the order of hash/iterator is switched here ... So after I get a good idea of how to solve bug 54916, I probably apply this to the code base ... there's only one problem with it ... the official ecma schema, which is downloaded by the poi build, doesn't contain the hash/saltValue and spinCount attributes ... Have fun with it, Andi public void blatest() throws Exception { byte hashValue[] = Base64.decodeBase64("5MANCkOK6IY02H1LhiJ+ucR5ZHvoV7BwbINSx52iIhe4Xfg986k2l32ONsYpt8JPiy8U8kqPRKXIr7G8hfMWOw=="); byte saltValue[] = Base64.decodeBase64("R040EdN/Ec7il6MJ8JrRLQ=="); int spinCount = 100000; HashAlgorithm hashAlgo = HashAlgorithm.sha512; String password = "pwd"; MessageDigest hashAlg = CryptoFunctions.getMessageDigest(hashAlgo); hashAlg.update(saltValue); byte[] hash = hashAlg.digest(password.getBytes("UTF-16LE")); byte[] iterator = new byte[LittleEndianConsts.INT_SIZE]; try { for (int i = 0; i < spinCount; i++) { LittleEndian.putInt(iterator, 0, i); hashAlg.reset(); hashAlg.update(hash); hashAlg.update(iterator); hashAlg.digest(hash, 0, hash.length); // don't create hash buffer everytime new } } catch (DigestException e) { throw new EncryptedDocumentException("error in password hashing"); } assertThat(hashValue, equalTo(hash)); } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
