Module: Pliney::AppleCodeSignature
- Defined in:
- lib/pliney/apple_code_signature.rb
Defined Under Namespace
Classes: Blob, BlobWrapper, CodeDirectory, DetachedSignature, EmbeddedSignature, Entitlement, LibraryDependencyBlob, OpaqueBlob, Requirement, RequirementSet, SuperBlob, UnknownBlob
Constant Summary
collapse
- FADEMAGIC =
{
0xfade0c00 => :Requirement,
0xfade0c01 => :RequirementSet,
0xfade0c02 => :CodeDirectory,
0xfade0c05 => :LibraryDependencyBlob,
0xfade0cc0 => :EmbeddedSignature,
0xfade0cc1 => :DetachedSignature,
0xfade0b01 => :BlobWrapper,
0xfade7171 => :Entitlement,
}
Class Method Summary
collapse
Class Method Details
.from_path(fname) ⇒ Object
244
245
246
|
# 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) ⇒ Object
231
232
233
234
235
236
237
238
239
240
241
242
|
# 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) ⇒ Object
216
217
218
219
220
221
222
223
224
225
226
227
228
229
|
# 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
|