support vbmeta_{system|vendor|product}.img etc

For newly added dynamic partition related features
pull/31/head
cfig 6 years ago
parent c6db6eaf11
commit c3bb4fb356
No known key found for this signature in database
GPG Key ID: B104C307F0FDABB7

@ -18,7 +18,7 @@ fun main(args: Array<String>) {
Avb().parseVbMeta(args[1]) Avb().parseVbMeta(args[1])
} }
"pack" -> { "pack" -> {
Avb().packVbMetaWithPadding() Avb().packVbMetaWithPadding(null)
} }
"sign" -> { "sign" -> {
log.info("vbmeta is already signed") log.info("vbmeta is already signed")

@ -374,8 +374,8 @@ class Avb {
return ai return ai
} }
private fun packVbMeta(info: AVBInfo? = null): ByteArray { private fun packVbMeta(info: AVBInfo? = null, image_file: String? = null): ByteArray {
val ai = info ?: ObjectMapper().readValue(File(getJsonFileName("vbmeta.img")), AVBInfo::class.java) val ai = info ?: ObjectMapper().readValue(File(getJsonFileName(image_file!!)), AVBInfo::class.java)
val alg = Algorithms.get(ai.header!!.algorithm_type.toInt())!! val alg = Algorithms.get(ai.header!!.algorithm_type.toInt())!!
val encodedDesc = ai.auxBlob!!.encodeDescriptors() val encodedDesc = ai.auxBlob!!.encodeDescriptors()
//encoded pubkey //encoded pubkey
@ -428,13 +428,13 @@ class Avb {
return Helper.join(headerBlob, authBlob, auxBlob) return Helper.join(headerBlob, authBlob, auxBlob)
} }
fun packVbMetaWithPadding(info: AVBInfo? = null) { fun packVbMetaWithPadding(image_file: String? = null, info: AVBInfo? = null) {
val rawBlob = packVbMeta(info) val rawBlob = packVbMeta(info, image_file)
val paddingSize = Helper.round_to_multiple(rawBlob.size.toLong(), BLOCK_SIZE) - rawBlob.size val paddingSize = Helper.round_to_multiple(rawBlob.size.toLong(), BLOCK_SIZE) - rawBlob.size
val paddedBlob = Helper.join(rawBlob, Struct3("${paddingSize}x").pack(null)) val paddedBlob = Helper.join(rawBlob, Struct3("${paddingSize}x").pack(null))
log.info("raw vbmeta size ${rawBlob.size}, padding size $paddingSize, total blob size ${paddedBlob.size}") log.info("raw vbmeta size ${rawBlob.size}, padding size $paddingSize, total blob size ${paddedBlob.size}")
log.info("Writing padded vbmeta to file: vbmeta.img.signed") log.info("Writing padded vbmeta to file: $image_file.signed")
Files.write(Paths.get("vbmeta.img.signed"), paddedBlob, StandardOpenOption.CREATE) Files.write(Paths.get("$image_file.signed"), paddedBlob, StandardOpenOption.CREATE)
} }
companion object { companion object {

@ -5,7 +5,7 @@ import cfig.Avb
@ExperimentalUnsignedTypes @ExperimentalUnsignedTypes
class VBMetaParser: IPackable { class VBMetaParser: IPackable {
override fun capabilities(): List<String> { override fun capabilities(): List<String> {
return listOf("^vbmeta\\.img$") return listOf("^vbmeta\\.img$", "^vbmeta\\_[a-z]+.img$")
} }
override fun unpack(fileName: String) { override fun unpack(fileName: String) {
@ -13,6 +13,6 @@ class VBMetaParser: IPackable {
} }
override fun pack(fileName: String) { override fun pack(fileName: String) {
Avb().packVbMetaWithPadding() Avb().packVbMetaWithPadding(fileName)
} }
} }

Loading…
Cancel
Save