Documentation
¶
Index ¶
- Constants
- func Decrypt(data, iv, key []byte) ([]byte, error)
- func DecryptData(data, iv, key []byte) ([]byte, error)
- func DecryptKBag(kbag *KBagData, gidKey []byte) error
- func DecryptWithGIDKey(data, gidKey []byte) ([]byte, error)
- func DecryptWithKBAGKey(data, kbagKey []byte) ([]byte, error)
- func ExtractData(data []byte) ([]byte, error)
- type Header
- type Img3
- type KBAG128
- type KBAG192
- type KBAG256
- type KBagData
- type KBagHeader
- type Tag
- type TagHeader
Constants ¶
const Magic = "Img3"
Variables ¶
This section is empty.
Functions ¶
func Decrypt ¶
Decrypt decrypts an IMG3 file using the provided IV and key This function assumes the IV and key are already decrypted
func DecryptData ¶
DecryptData decrypts IMG3 data using the provided IV and key
func DecryptKBag ¶
DecryptKBag decrypts the KBAG using the provided GID key The gidKey should be the device's GID key (usually obtained through exploits)
func DecryptWithGIDKey ¶
DecryptWithGIDKey decrypts an IMG3 file using the provided GID key This function handles the complete decryption process including KBAG decryption It tries all available KBAGs until one works
func DecryptWithKBAGKey ¶
DecryptWithKBAGKey decrypts an IMG3 file using the provided KBAG decryption key This function implements the two-stage decryption process: 1. Use the provided key to decrypt the KBAG (which contains the encrypted IV+Key for the data) 2. Use the decrypted KBAG's IV+Key to decrypt the actual data
func ExtractData ¶
ExtractData extracts and decompresses data from an unencrypted IMG3 file This function is for IMG3 files that don't require decryption
Types ¶
type Header ¶
type Header struct {
Magic [4]byte // ASCII_LE("Img3")
FullSize uint32 // full size of fw image
SizeNoPack uint32 // size of fw image without header
SigCheckArea uint32 // although that is just my name for it, this is the
// size of the start of the data section (the code) up to
// the start of the RSA signature (SHSH section)
Ident [4]byte // identifier of image, used when bootrom is parsing images
}
Header img3 header object
type Img3 ¶
Img3 object
func (*Img3) GetAllKBagTags ¶
GetAllKBagTags returns all KBAG tags from the IMG3 file
func (*Img3) GetDataTag ¶
GetDataTag returns the DATA tag from the IMG3 file
func (*Img3) GetKBagTag ¶
GetKBagTag returns the KBAG tag from the IMG3 file
type KBAG128 ¶
type KBAG128 struct {
KBagHeader
EncIV [16]byte // IV for the firmware file, encrypted with the GID Key
EncKey [16]byte // Key for the firmware file, encrypted with the GID Key
}
type KBAG192 ¶
type KBAG192 struct {
KBagHeader
EncIV [16]byte // IV for the firmware file, encrypted with the GID Key
EncKey [24]byte // Key for the firmware file, encrypted with the GID Key
}
type KBAG256 ¶
type KBAG256 struct {
KBagHeader
EncIV [16]byte // IV for the firmware file, encrypted with the GID Key
EncKey [32]byte // Key for the firmware file, encrypted with the GID Key
}
type KBagHeader ¶
type KBagHeader struct {
CryptState uint32 // 1 if encrypted with GID Key, 2 if encrypted with Development GID Key
AESType uint32 // 0x80 = aes128, 0xc0 = aes192, 0x100 = aes256
}
KBAG structures for different AES key sizes Note: The IMG3 tag header (magic, fullSize, tagDataSize) is handled by the Tag structure KBAG data starts directly with cryptState and aesType