You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Android_boot_image_editor/bbootimg/src/test/kotlin/KeyUtilTest.kt

23 lines
661 B
Kotlin

import avb.alg.Algorithms
import cfig.KeyUtil
import org.apache.commons.codec.binary.Hex
import org.junit.Assert.*
import org.junit.Test
import java.io.FileInputStream
import java.nio.file.Files
import java.nio.file.Paths
@ExperimentalUnsignedTypes
class KeyUtilTest {
@Test
fun parseKeys() {
val keyFile = "../" + Algorithms.get("SHA256_RSA2048")!!.defaultKey
val k = KeyUtil.parsePk8PrivateKey(Files.readAllBytes(Paths.get(keyFile.replace("pem", "pk8"))))
val k2 = KeyUtil.parsePemPrivateKey2(FileInputStream(keyFile))
println(Hex.encodeHexString(k.encoded))
println(Hex.encodeHexString(k2.encoded))
}
}