Skip to content
Permalink
7682a881ff
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
28 lines (25 sloc) 849 Bytes
//
// amfidhook.swift
// Odyssey
//
// Created by CoolStar on 5/8/20.
// Copyright © 2020 coolstar. All rights reserved.
//
import Foundation
import CommonCrypto
func getOverriddenSignature(path: String, standardError: inout FileHandle) -> [UInt8]? {
guard let pathdata = path.data(using: .utf8) else {
return nil
}
var hash = [UInt8](repeating: 0, count: Int(CC_SHA256_DIGEST_LENGTH))
_ = pathdata.withUnsafeBytes { CC_SHA256($0.baseAddress, CC_LONG(pathdata.count), &hash) }
let hashStr = hash.map { String(format: "%02hhx", $0) }.joined()
let pathStr = "/odyssey/cstmp/" + hashStr
guard let cdHashData = try? Data(contentsOf: URL(fileURLWithPath: pathStr)) else {
return nil
}
guard cdHashData.count == CS_CDHASH_LEN else {
return nil
}
return [UInt8](cdHashData)
}