Skip to content

Commit 0e50c73

Browse files
committed
Prepare 0.6.0 release
1 parent e827458 commit 0e50c73

File tree

4 files changed

+68
-16
lines changed

4 files changed

+68
-16
lines changed

CHANGELOG.md

+35
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,40 @@
11
# CHANGELOG
22

3+
## Version 0.6.0 (2025-01-15)
4+
- `@Throws` annotation removed from `Updatable.update` (it is documented).
5+
- Finalizes `Digest` internal API and removes `InternalKotlinCryptoApi` opt-in requirement from constructors.
6+
- Drops usage of `DigestState` in favor of secondary constructor which takes
7+
`Digest` as an argument (for `copy` function implementations).
8+
- `Copyable.copy` override is now passed through to implementations so that the proper
9+
return type can be defined (instead of requiring API consumers to cast from `Digest`).
10+
- `protected` functions renamed:
11+
- `compress` >> `compressProtected`
12+
- `digest` >> `digestProtected`
13+
- `updateDigest` >> `updateProtected`
14+
- `resetDigest` >> `resetProtected`
15+
- `digestProtected` (previously `digest`) now only provides the buffered input and position as
16+
arguments; `bitLength` is no longer tracked by `Digest`.
17+
- `Digest.digest` now zero's out stale buffered input from `bufPos` to `buf.size` before passing it to
18+
`digestProtected` (previously `digest`) as an argument.
19+
- Finalizes `Mac` internal API and removes `InternalKotlinCryptoApi` opt-in requirement from constructors.
20+
- Provides secondary constructor which takes `Mac` as an argument (for `copy` function implementations).
21+
- `Copyable.copy` override is now passed through to `Mac` implementations so that the proper
22+
return type can be defined (instead of requiring API consumers to cast from `Mac`).
23+
- Adds ability to reinitialize `Mac` with a new `key` parameter via `reset(newKey)` (or clear it after use).
24+
- Adds `Mac.clearKey` helper function for zeroing out key material before dereferencing the `Mac` (if desired).
25+
- Removes `Mac.Engine.State` in favor of secondary constructor which takes `Mac.Engine` as an argument
26+
(for `copy` function implementation).
27+
- Adds abstract function `Mac.Engine.reset(newKey)` for reinitialization functionality.
28+
- Finalizes `Xof` and `XofFactory` internal API and removes `InternalKotlinCryptoApi` opt-in
29+
requirement from constructors.
30+
- `Xof.Reader.readProtected` no longer passes `bytesRead` as an argument.
31+
- Adds `ReKeyableXofAlgorithm` interface for `Xof` implementations who's backing delegate is a `Mac`.
32+
- Adds `Xof.Companion.reset(newKey)` extension function which allows API consumers the ability to
33+
reinitialize the `Xof` with a new `key` parameter when that `Xof` is backed by an instance of
34+
`ReKeyableXofAlgorithm` (i.e. a `Mac` implementation).
35+
- `Xof.use` and `Xof.Reader.use` functions are now inlined.
36+
- Removes usage of `KotlinCrypto.endians` library (deprecated) from `Xof.Utils`.
37+
338
## Version 0.5.5 (2024-12-20)
439
- Fixes optimization issues with `Digest.update` internals [[#70]][70]
540

README.md

+31-14
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,14 @@ fun main() {
116116

117117
val hash = mac.doFinal()
118118
val hash2 = copy.doFinal(bytes)
119+
120+
// Reinitialize Mac instance with a new key
121+
// to use for something else.
122+
val newKey = SecureRandom().nextBytesOf(100)
123+
mac.reset(newKey = newKey)
124+
125+
// Zero out key material before dereferencing
126+
copy.clearKey()
119127
}
120128
```
121129

@@ -204,6 +212,27 @@ fun main() {
204212
}
205213
```
206214

215+
```kotlin
216+
// Using KMAC128 from MACs repo as an example
217+
import org.kotlincrypto.macs.kmac.KMAC128
218+
// Using SecureRandom from the secure-random repo as an example
219+
import org.kotlincrypto.SecureRandom
220+
221+
fun main() {
222+
val key = SecureRandom().nextBytesOf(100)
223+
val kmacXof: Xof<KMAC128> = KMAC128.xOf(key)
224+
225+
// If Xof is for a Mac that implements ReKeyableXofAlgorithm,
226+
// reinitialize the instance via the `Xof.Companion.reset`
227+
// extension function for reuse.
228+
val newKey = SecureRandom().nextBytesOf(100)
229+
kmacXof.reset(newKey = newKey)
230+
231+
// Or zero out key material before dereferencing
232+
kmacXof.reset(newKey = ByteArray(1))
233+
}
234+
```
235+
207236
</details>
208237

209238
### Get Started
@@ -216,27 +245,15 @@ The best way to keep `KotlinCrypto` dependencies up to date is by using the
216245
```kotlin
217246
// build.gradle.kts
218247
dependencies {
219-
val core = "0.5.5"
248+
val core = "0.6.0"
220249
implementation("org.kotlincrypto.core:digest:$core")
221250
implementation("org.kotlincrypto.core:mac:$core")
222251
implementation("org.kotlincrypto.core:xof:$core")
223252
}
224253
```
225254

226255
<!-- TAG_VERSION -->
227-
228-
```groovy
229-
// build.gradle
230-
dependencies {
231-
def core = "0.5.5"
232-
implementation "org.kotlincrypto.core:digest:$core"
233-
implementation "org.kotlincrypto.core:mac:$core"
234-
implementation "org.kotlincrypto.core:xof:$core"
235-
}
236-
```
237-
238-
<!-- TAG_VERSION -->
239-
[badge-latest-release]: https://img.shields.io/badge/latest--release-0.5.5-blue.svg?style=flat
256+
[badge-latest-release]: https://img.shields.io/badge/latest--release-0.6.0-blue.svg?style=flat
240257
[badge-license]: https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat
241258

242259
<!-- TAG_DEPENDENCIES -->

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ POM_DEVELOPER_ID=KotlinCrypto
3030
POM_DEVELOPER_NAME=Kotlin Crypto
3131
POM_DEVELOPER_URL=https://github.com/KotlinCrypto/
3232

33-
VERSION_NAME=0.6.0-SNAPSHOT
33+
VERSION_NAME=0.6.0
3434
# 0.1.0-alpha01 = 00 01 00 11
3535
# 0.1.0-beta01 = 00 01 00 21
3636
# 0.1.0-rc01 = 00 01 00 31

library/digest/src/commonMain/kotlin/org/kotlincrypto/core/digest/internal/DigestState.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
**/
1616
package org.kotlincrypto.core.digest.internal
1717

18-
@Deprecated("Replaced by Digest.State since 1.0.0")
18+
@Deprecated("Removed from usage in Digest copy implementation in 0.6.0")
1919
public sealed class DigestState

0 commit comments

Comments
 (0)