private byte[] checkOwnerPassword(byte[] ownerPassword,byte[] firstDocIdValue,int keyBitLength,int revision,byte[] oValue,byte[] uValue,int pValue,boolean encryptMetadata) throws GeneralSecurityException, EncryptionUnsupportedByProductException, PDFParseException {
  final byte[] rc4KeyBytes=getInitialOwnerPasswordKeyBytes(ownerPassword,keyBitLength,revision);
  final Cipher rc4=createRC4Cipher();
  initDecryption(rc4,createRC4Key(rc4KeyBytes));
  final byte[] possibleUserPassword;
  if (revision == 2) {
    possibleUserPassword=crypt(rc4,oValue);
  }
 else   if (revision >= 3) {
    possibleUserPassword=new byte[32];
    System.arraycopy(oValue,0,possibleUserPassword,0,possibleUserPassword.length);
    rc4unshuffle(rc4,possibleUserPassword,rc4KeyBytes);
  }
 else {
    throw new EncryptionUnsupportedByProductException("Unsupported revision: " + revision);
  }
  return checkUserPassword(possibleUserPassword,firstDocIdValue,keyBitLength,revision,oValue,uValue,pValue,encryptMetadata);
}

private byte [ ] checkOwnerPassword ( byte [ ] ownerPassword , byte [ ] firstDocIdValue , int keyBitLength , int revision , byte [ ] oValue , byte [ ] uValue , int pValue , boolean encryptMetadata ) throws GeneralSecurityException , EncryptionUnsupportedByProductException , PDFParseException { final byte [ ] rc4KeyBytes = getInitialOwnerPasswordKeyBytes ( ownerPassword , keyBitLength , revision ) ; final Cipher rc4 = createRC4Cipher ( ) ; initDecryption ( rc4 , createRC4Key ( rc4KeyBytes ) ) ; final byte [ ] possibleUserPassword ; if ( revision == 2 ) { possibleUserPassword = crypt ( rc4 , oValue ) ; } else if ( revision >= 3 ) { possibleUserPassword = new byte [ 32 ] ; System . arraycopy ( oValue , 0 , possibleUserPassword , 0 , possibleUserPassword . length ) ; rc4unshuffle ( rc4 , possibleUserPassword , rc4KeyBytes ) ; } else { throw new EncryptionUnsupportedByProductException ( "Unsupported revision: " + revision ) ; } return checkUserPassword ( possibleUserPassword , firstDocIdValue , keyBitLength , revision , oValue , uValue , pValue , encryptMetadata ) ; }
check to see whether a given password is the owner password . corresponds to algorithm 3 . 6 of pdf reference version 1 . 7 .
