codesign

Imports

Imports #

"crypto/sha256"
"debug/macho"
"encoding/binary"
"io"
"cmd/internal/hash"

Constants & Variables

CSMAGIC_CODEDIRECTORY const #

const CSMAGIC_CODEDIRECTORY = 0xfade0c02

CSMAGIC_DETACHED_SIGNATURE const #

const CSMAGIC_DETACHED_SIGNATURE = 0xfade0cc1

CSMAGIC_EMBEDDED_SIGNATURE const #

const CSMAGIC_EMBEDDED_SIGNATURE = 0xfade0cc0

CSMAGIC_REQUIREMENT const #

const CSMAGIC_REQUIREMENT = 0xfade0c00

CSMAGIC_REQUIREMENTS const #

const CSMAGIC_REQUIREMENTS = 0xfade0c01

CSSLOT_CODEDIRECTORY const #

const CSSLOT_CODEDIRECTORY = 0

CS_EXECSEG_ALLOW_UNSIGNED const #

const CS_EXECSEG_ALLOW_UNSIGNED = 0x10

CS_EXECSEG_CAN_EXEC_CDHASH const #

const CS_EXECSEG_CAN_EXEC_CDHASH = 0x200

CS_EXECSEG_CAN_LOAD_CDHASH const #

const CS_EXECSEG_CAN_LOAD_CDHASH = 0x100

CS_EXECSEG_DEBUGGER const #

const CS_EXECSEG_DEBUGGER = 0x20

CS_EXECSEG_JIT const #

const CS_EXECSEG_JIT = 0x40

CS_EXECSEG_MAIN_BINARY const #

const CS_EXECSEG_MAIN_BINARY = 0x1

CS_EXECSEG_SKIP_LV const #

const CS_EXECSEG_SKIP_LV = 0x80

CS_HASHTYPE_SHA1 const #

const CS_HASHTYPE_SHA1 = 1

CS_HASHTYPE_SHA256 const #

const CS_HASHTYPE_SHA256 = 2

CS_HASHTYPE_SHA256_TRUNCATED const #

const CS_HASHTYPE_SHA256_TRUNCATED = 3

CS_HASHTYPE_SHA384 const #

const CS_HASHTYPE_SHA384 = 4

LC_CODE_SIGNATURE const #

const LC_CODE_SIGNATURE = 0x1d

blobSize const #

const blobSize = *ast.BinaryExpr

codeDirectorySize const #

const codeDirectorySize = *ast.BinaryExpr

pageSize const #

const pageSize = *ast.BinaryExpr

pageSizeBits const #

const pageSizeBits = 12

superBlobSize const #

const superBlobSize = *ast.BinaryExpr

Structs

Blob struct #

type Blob struct {
typ uint32
offset uint32
}

CodeDirectory struct #

type CodeDirectory struct {
magic uint32
length uint32
version uint32
flags uint32
hashOffset uint32
identOffset uint32
nSpecialSlots uint32
nCodeSlots uint32
codeLimit uint32
hashSize uint8
hashType uint8
_pad1 uint8
pageSize uint8
_pad2 uint32
scatterOffset uint32
teamOffset uint32
_pad3 uint32
codeLimit64 uint64
execSegBase uint64
execSegLimit uint64
execSegFlags uint64
}

CodeSigCmd struct #

CodeSigCmd is Mach-O LC_CODE_SIGNATURE load command.

type CodeSigCmd struct {
Cmd uint32
Cmdsize uint32
Dataoff uint32
Datasize uint32
}

SuperBlob struct #

type SuperBlob struct {
magic uint32
length uint32
count uint32
}

Functions

FindCodeSigCmd function #

func FindCodeSigCmd(f *macho.File) (CodeSigCmd, bool)

Sign function #

Sign generates an ad-hoc code signature and writes it to out. out must have length at least Size(codeSize, id). data is the file content without the signature, of size codeSize. textOff and textSize is the file offset and size of the text segment. isMain is true if this is a main executable. id is the identifier used for signing (a field in CodeDirectory blob, which has no significance in ad-hoc signing).

func Sign(out []byte, data io.Reader, id string, codeSize int64, textOff int64, textSize int64, isMain bool)

Size function #

Size computes the size of the code signature. id is the identifier used for signing (a field in CodeDirectory blob, which has no significance in ad-hoc signing).

func Size(codeSize int64, id string) int64

put method #

func (b *Blob) put(out []byte) []byte

put method #

func (s *SuperBlob) put(out []byte) []byte

put method #

func (c *CodeDirectory) put(out []byte) []byte

put32be function #

func put32be(b []byte, x uint32) []byte

put64be function #

func put64be(b []byte, x uint64) []byte

put8 function #

func put8(b []byte, x uint8) []byte

puts function #

func puts(b []byte, s []byte) []byte

Generated with Arrow