Compare commits

...

5 Commits

Author SHA1 Message Date
semantic-release-bot
8e4d5765e1 chore(release): 2.3.0-dev.3 [skip ci]
# [2.3.0-dev.3](https://github.com/ReVanced/revanced-library/compare/v2.3.0-dev.2...v2.3.0-dev.3) (2024-03-14)

### Features

* Improve exception message ([b15efa4](b15efa41f8))
2024-03-14 11:51:48 +00:00
oSumAtrIX
b15efa41f8 feat: Improve exception message 2024-03-14 12:50:20 +01:00
semantic-release-bot
af0aba4a8e chore(release): 2.3.0-dev.2 [skip ci]
# [2.3.0-dev.2](https://github.com/ReVanced/revanced-library/compare/v2.3.0-dev.1...v2.3.0-dev.2) (2024-03-14)

### Features

* Simplify signing utility API ([4c6a636](4c6a6360cf))
2024-03-14 11:40:37 +00:00
oSumAtrIX
4c6a6360cf feat: Simplify signing utility API 2024-03-14 12:39:01 +01:00
oSumAtrIX
80e35270c4 build: Publish sources 2024-03-14 12:21:47 +01:00
6 changed files with 51 additions and 7 deletions

View File

@@ -1,3 +1,17 @@
# [2.3.0-dev.3](https://github.com/ReVanced/revanced-library/compare/v2.3.0-dev.2...v2.3.0-dev.3) (2024-03-14)
### Features
* Improve exception message ([b15efa4](https://github.com/ReVanced/revanced-library/commit/b15efa41f8dc7d73865d0eab15be274b9ee3d7a3))
# [2.3.0-dev.2](https://github.com/ReVanced/revanced-library/compare/v2.3.0-dev.1...v2.3.0-dev.2) (2024-03-14)
### Features
* Simplify signing utility API ([4c6a636](https://github.com/ReVanced/revanced-library/commit/4c6a6360cf83659d1f5c3a7c5710ac54426e9235))
# [2.3.0-dev.1](https://github.com/ReVanced/revanced-library/compare/v2.2.2-dev.1...v2.3.0-dev.1) (2024-03-13) # [2.3.0-dev.1](https://github.com/ReVanced/revanced-library/compare/v2.2.2-dev.1...v2.3.0-dev.1) (2024-03-13)

View File

@@ -39,6 +39,7 @@ public final class app/revanced/library/ApkUtils {
public final fun sign (Ljava/io/File;Lapp/revanced/library/ApkUtils$SigningOptions;)V public final fun sign (Ljava/io/File;Lapp/revanced/library/ApkUtils$SigningOptions;)V
public final fun sign (Ljava/io/File;Ljava/io/File;Lapp/revanced/library/ApkUtils$SigningOptions;)V public final fun sign (Ljava/io/File;Ljava/io/File;Lapp/revanced/library/ApkUtils$SigningOptions;)V
public final fun sign (Ljava/io/File;Ljava/io/File;Ljava/lang/String;Lapp/revanced/library/ApkSigner$PrivateKeyCertificatePair;)V public final fun sign (Ljava/io/File;Ljava/io/File;Ljava/lang/String;Lapp/revanced/library/ApkSigner$PrivateKeyCertificatePair;)V
public final fun signApk (Ljava/io/File;Ljava/io/File;Ljava/lang/String;Lapp/revanced/library/ApkUtils$KeyStoreDetails;)V
} }
public final class app/revanced/library/ApkUtils$KeyStoreDetails { public final class app/revanced/library/ApkUtils$KeyStoreDetails {

View File

@@ -54,6 +54,8 @@ kotlin {
java { java {
targetCompatibility = JavaVersion.VERSION_11 targetCompatibility = JavaVersion.VERSION_11
withSourcesJar()
} }
publishing { publishing {

View File

@@ -1,4 +1,4 @@
org.gradle.parallel = true org.gradle.parallel = true
org.gradle.caching = true org.gradle.caching = true
kotlin.code.style = official kotlin.code.style = official
version = 2.3.0-dev.1 version = 2.3.0-dev.3

View File

@@ -154,7 +154,7 @@ object ApkSigner {
logger.fine("Reading key and certificate pair from keystore entry $keyStoreEntryAlias") logger.fine("Reading key and certificate pair from keystore entry $keyStoreEntryAlias")
if (!keyStore.containsAlias(keyStoreEntryAlias)) { if (!keyStore.containsAlias(keyStoreEntryAlias)) {
throw IllegalArgumentException("Keystore does not contain alias $keyStoreEntryAlias") throw IllegalArgumentException("Keystore does not contain entry with alias $keyStoreEntryAlias")
} }
// Read the private key and certificate from the keystore. // Read the private key and certificate from the keystore.

View File

@@ -103,6 +103,7 @@ object ApkUtils {
* *
* @return The newly created private key and certificate pair. * @return The newly created private key and certificate pair.
*/ */
@Deprecated("This method will be removed in the future.")
fun newPrivateKeyCertificatePair( fun newPrivateKeyCertificatePair(
privateKeyCertificatePairDetails: PrivateKeyCertificatePairDetails, privateKeyCertificatePairDetails: PrivateKeyCertificatePairDetails,
keyStoreDetails: KeyStoreDetails, keyStoreDetails: KeyStoreDetails,
@@ -131,9 +132,10 @@ object ApkUtils {
* *
* @return The private key and certificate pair. * @return The private key and certificate pair.
*/ */
@Deprecated("This method will be removed in the future.")
fun readPrivateKeyCertificatePairFromKeyStore( fun readPrivateKeyCertificatePairFromKeyStore(
keyStoreDetails: KeyStoreDetails, keyStoreDetails: KeyStoreDetails,
) = ApkSigner.readKeyCertificatePair( ) = ApkSigner.readPrivateKeyCertificatePair(
ApkSigner.readKeyStore( ApkSigner.readKeyStore(
keyStoreDetails.keyStore.inputStream(), keyStoreDetails.keyStore.inputStream(),
keyStoreDetails.keyStorePassword, keyStoreDetails.keyStorePassword,
@@ -144,20 +146,26 @@ object ApkUtils {
/** /**
* Signs [inputApkFile] with the given options and saves the signed apk to [outputApkFile]. * Signs [inputApkFile] with the given options and saves the signed apk to [outputApkFile].
* If [KeyStoreDetails.keyStore] does not exist,
* a new private key and certificate pair will be created and saved to the keystore.
* *
* @param inputApkFile The apk file to sign. * @param inputApkFile The apk file to sign.
* @param outputApkFile The file to save the signed apk to. * @param outputApkFile The file to save the signed apk to.
* @param signer The name of the signer. * @param signer The name of the signer.
* @param privateKeyCertificatePair The private key and certificate pair to use for signing. * @param keyStoreDetails The details for the keystore.
*/ */
fun sign( fun signApk(
inputApkFile: File, inputApkFile: File,
outputApkFile: File, outputApkFile: File,
signer: String, signer: String,
privateKeyCertificatePair: ApkSigner.PrivateKeyCertificatePair, keyStoreDetails: KeyStoreDetails,
) = ApkSigner.newApkSigner( ) = ApkSigner.newApkSigner(
signer, signer,
privateKeyCertificatePair, if (keyStoreDetails.keyStore.exists()) {
readPrivateKeyCertificatePairFromKeyStore(keyStoreDetails)
} else {
newPrivateKeyCertificatePair(PrivateKeyCertificatePairDetails(), keyStoreDetails)
},
).signApk(inputApkFile, outputApkFile) ).signApk(inputApkFile, outputApkFile)
@Deprecated("This method will be removed in the future.") @Deprecated("This method will be removed in the future.")
@@ -182,6 +190,25 @@ object ApkUtils {
} }
} }
/**
* Signs [inputApkFile] with the given options and saves the signed apk to [outputApkFile].
*
* @param inputApkFile The apk file to sign.
* @param outputApkFile The file to save the signed apk to.
* @param signer The name of the signer.
* @param privateKeyCertificatePair The private key and certificate pair to use for signing.
*/
@Deprecated("This method will be removed in the future.")
fun sign(
inputApkFile: File,
outputApkFile: File,
signer: String,
privateKeyCertificatePair: ApkSigner.PrivateKeyCertificatePair,
) = ApkSigner.newApkSigner(
signer,
privateKeyCertificatePair,
).signApk(inputApkFile, outputApkFile)
/** /**
* Signs the apk file with the given options. * Signs the apk file with the given options.
* *