https://github.com/ticesoftware/androidhkdf
https://github.com/ticesoftware/androidhkdf
kotlin tice-app tice-crypto
Last synced: 10 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/ticesoftware/androidhkdf
- Owner: TICESoftware
- License: mit
- Created: 2020-03-26T15:04:15.000Z (about 6 years ago)
- Default Branch: main
- Last Pushed: 2023-08-24T11:55:17.000Z (almost 3 years ago)
- Last Synced: 2025-06-13T08:06:00.208Z (about 1 year ago)
- Topics: kotlin, tice-app, tice-crypto
- Language: Kotlin
- Homepage:
- Size: 196 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# AndroidHKDF
HMAC-based Extract-and-Expand Key Derivation Function (HKDF) as defined in RFC 5869.
The HMAC is provided by libsodium which uses the HMAC-SHA-512/256 algorithm. Libsodium is integrated via Lazysodium.
## Installation
### Jitpack
To integrate the library via jitpack add the jitpack repository to your root `build.gradle` file:
```
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
```
You can then add the dependency to your app's `build.gradle` file where `$VERSION` specifies the specific version of the library:
```
dependencies {
implementation 'com.github.TICESoftware:AndroidHKDF:$VERSION'
}
```
## Usage
For deriving a new key of length 32 bytes from some input keying material `ikm`:
```kotlin
import com.ticeapp.androidhkdf.*
import com.goterl.lazysodium.LazySodiumAndroid
import com.goterl.lazysodium.SodiumAndroid
val ikm = "Input key".encodeToByteArray()
val hkdfKey = deriveHKDFKey(ikm, L = 32)
```
A `salt` and some application specific info string (which is hashed into the HMAC) can additionally be provided:
`deriveHKDFKey(ikm, salt = salt, info = "Info", L = 32)`