module Pliney::AppleCodeSignature

Constants

FADEMAGIC

Public Class Methods

from_path(fname) click to toggle source
# File lib/pliney/apple_code_signature.rb, line 244
def self.from_path(fname)
    return from_stream(File.open(fname, 'rb'))
end
from_stream(f) click to toggle source
# File lib/pliney/apple_code_signature.rb, line 231
def self.from_stream(f)
    obj = MachO::from_stream(f)
    mh = if MachO::is_fat_magic(obj.magic)
             obj.machos.first
         elsif MachO::is_macho_magic(obj.magic)
             obj
         else
             raise "Could not find mach-o object"
         end

    return mh.codesignature
end
parse(data) click to toggle source
# File lib/pliney/apple_code_signature.rb, line 216
def self.parse(data)
    obj = data.is_a?(StringStream)? data : StringStream.new(data)
    magic = obj.read_uint32
    n=FADEMAGIC[magic]
    if n.nil? and ((magic >> 16) == 0xFADE)
        n = :UnknownBlob
    end
    unless n.nil?
        blob=const_get(n).new(magic,obj) {|o| o.parse }
        return blob
    else
        raise "Invalid magic value: 0x#{magic.to_s(16)}"
    end
end