uonet-request-signer/hebe-android
2022-05-03 11:38:15 +02:00
..
app [hebe-android] Update dependencies 2022-05-03 11:38:15 +02:00
gradle/wrapper [hebe-android] Update dependencies 2022-05-03 11:38:15 +02:00
lib [hebe-android] Update dependencies 2022-05-03 11:38:15 +02:00
.gitignore [hebe-android] Add hebe Android implementation. 2020-10-17 20:34:05 +02:00
build.gradle [hebe-android] Update dependencies 2022-05-03 11:38:15 +02:00
gradle.properties [hebe-android] Add hebe Android implementation. 2020-10-17 20:34:05 +02:00
gradlew [hebe-android] Add hebe Android implementation. 2020-10-17 20:34:05 +02:00
gradlew.bat [hebe-android] Add hebe Android implementation. 2020-10-17 20:34:05 +02:00
README.md [hebe-android] Update dependencies 2022-05-03 11:38:15 +02:00
settings.gradle [hebe-android] Add hebe Android implementation. 2020-10-17 20:34:05 +02:00

UONET+ (hebe) Request Signer for Android

Installation

allprojects {
    repositories {
        mavenLocal()
    }
}

dependencies {
    implementation "io.github.wulkanowy:uonet-request-signer-hebe-android:0.1.0"
}

Usage

Apart from other platforms, the privateKey returned from the generator is not a PEM-encoded string; it is a PrivateKey object suitable for the Android signer only.

Generate an RSA2048 key pair (private key and certificate):

import io.github.wulkanowy.signer.hebe.android.generateKeyPair
import io.github.wulkanowy.signer.hebe.android.getKeyEntry

val alias = "KeyEntry" // name in the Android KeyStore

// the key entry is saved in the AndroidKeyStore and returned here
val (certificate, fingerprint, privateKey) = generateKeyPair(context, alias)

// to get the key entry for usage later:
val (certificate, fingerprint, privateKey) = getKeyEntry(alias)

Sign request content:

import io.github.wulkanowy.signer.hebe.android.getSignatureValues

// the privateKey here may be either a PEM-encoded string (like in other implementations)
// or a PrivateKey object, returned from the generator above
val (digest, canonicalUrl, signature) = getSignatureValues(fingerprint, privateKey, body, fullUrl, Date())

Tests

$ ./gradlew test