class HexaPDF::Encryption::StandardEncryptionDictionary

the encryption key and a set of permissions.
Contains additional fields that are used for storing the information needed for retrieving
The specialized encryption dictionary for the StandardSecurityHandler.

def perform_validation

Validates the fields special for this encryption dictionary.
def perform_validation
  super
  case value[:R]
  when 2, 3, 4
    if value[:U].length != 32 || value[:O].length != 32
      yield("Invalid size for /U or /O values for revisions <= 4", false)
    end
  when 6
    if !key?(:OE) || !key?(:UE) || !key?(:Perms)
      yield("Value of /OE, /UE or /Perms is missing for dictionary revision 6", false)
      return
    end
    [:U, :O].each do |f|
      if value[f].length != 48
        yield("Invalid size (#{value[f].length} instead of 48) for /#{f} for revisions 6",
              value[f].length > 48 && value[f][48..-1].squeeze("\x00").length == 1)
        value[f].slice!(48..-1)
      end
    end
    if value[:UE].length != 32 || value[:OE].length != 32 || value[:Perms].length != 16
      yield("Invalid size for /UE, /OE or /Perms values for revisions 6", false)
    end
  end
end