Skip to content

Commit

Permalink
Release 3.8.0 (Supreme 0.3.0)
Browse files Browse the repository at this point in the history
  • Loading branch information
JesusMcCloud committed Sep 20, 2024
1 parent 1d03fce commit d40a119
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
8 changes: 4 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Changelog

## 4.0

### 4.0.0 (Supreme 0.3.0) Breaking Changes Ahead!
## 3.0

### 3.8.0 (Supreme 0.3.0) Breaking Changes Ahead!
* Completely revamped ASN.1 Tag Handling
* Properly handle multi-byte tags
* Introduce a new data structure `TLV.Tag` with an accompanying `TagClass` enum and a `constructed` flag to accurately represent arbitrary tags up to `ULong.MAX_VALUE`
Expand Down Expand Up @@ -43,8 +44,7 @@
* `decodeToXXX` to be invoked on an `Asn1Primitive` to decode a DER-encoded primitive into the target type
* `decodeFromAsn1ContentBytes` to be invoked on the companion of the target type to decode the content bytes of a TLV primitive (the _V_ in TLV)
* Update conventions -> Coroutines 1.0.9

## 3.0
* replace `runCatching` with `catching` to be extra-safe

### 3.7.0 (Supreme 0.2.0)
* Remove Swift verifier logic to obtain a general speed-up
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ kotlin.code.style=official
kotlin.js.compiler=ir
org.gradle.jvmargs=-Xmx4g -Dfile.encoding=UTF-8

artifactVersion=4.0.0-SNAPSHOT
supremeVersion=0.3.0-SNAPSHOT
artifactVersion=3.8.0
supremeVersion=0.3.0

# This is not a well-defined property, the ASP convention plugin respects it, though
jdk.version=17
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ private fun ByteIterator.doParseSingle(): Asn1Element = runRethrowing {
fun Asn1Primitive.decodeToBoolean() = runRethrowing { decode(Asn1Element.Tag.BOOL) { Boolean.decodeFromAsn1ContentBytes(it) } }

/** Exception-free version of [decodeToBoolean] */
fun Asn1Primitive.decodeToBooleanOrNull() = runCatching { decodeToBoolean() }.getOrNull()
fun Asn1Primitive.decodeToBooleanOrNull() = catching { decodeToBoolean() }.getOrNull()

/**
* decodes this [Asn1Primitive]'s content into an [Int]
Expand All @@ -115,7 +115,7 @@ fun Asn1Primitive.decodeToBooleanOrNull() = runCatching { decodeToBoolean() }.ge
fun Asn1Primitive.decodeToInt() = runRethrowing { decode(Asn1Element.Tag.INT) { Int.decodeFromAsn1ContentBytes(it) } }

/** Exception-free version of [decodeToInt] */
fun Asn1Primitive.decodeToIntOrNull() = runCatching { decodeToInt() }.getOrNull()
fun Asn1Primitive.decodeToIntOrNull() = catching { decodeToInt() }.getOrNull()

/**
* decodes this [Asn1Primitive]'s content into a [Long]
Expand All @@ -125,7 +125,7 @@ fun Asn1Primitive.decodeToIntOrNull() = runCatching { decodeToInt() }.getOrNull(
fun Asn1Primitive.decodeToLong() = runRethrowing { decode(Asn1Element.Tag.INT) { Long.decodeFromAsn1ContentBytes(it) } }

/** Exception-free version of [decodeToLong] */
inline fun Asn1Primitive.decodeToLongOrNull() = runCatching { decodeToLong() }.getOrNull()
inline fun Asn1Primitive.decodeToLongOrNull() = catching { decodeToLong() }.getOrNull()

/**
* decodes this [Asn1Primitive]'s content into an [UInt]
Expand All @@ -135,7 +135,7 @@ inline fun Asn1Primitive.decodeToLongOrNull() = runCatching { decodeToLong() }.g
fun Asn1Primitive.decodeToUInt() = runRethrowing { decode(Asn1Element.Tag.INT) { UInt.decodeFromAsn1ContentBytes(it) } }

/** Exception-free version of [decodeToUInt] */
inline fun Asn1Primitive.decodeToUIntOrNull() = runCatching { decodeToUInt() }.getOrNull()
inline fun Asn1Primitive.decodeToUIntOrNull() = catching { decodeToUInt() }.getOrNull()

/**
* decodes this [Asn1Primitive]'s content into an [ULong]
Expand All @@ -145,7 +145,7 @@ inline fun Asn1Primitive.decodeToUIntOrNull() = runCatching { decodeToUInt() }.g
fun Asn1Primitive.decodeToULong() = runRethrowing { decode(Asn1Element.Tag.INT) { ULong.decodeFromAsn1ContentBytes(it) } }

/** Exception-free version of [decodeToULong] */
inline fun Asn1Primitive.decodeToULongOrNull() = runCatching { decodeToULong() }.getOrNull()
inline fun Asn1Primitive.decodeToULongOrNull() = catching { decodeToULong() }.getOrNull()

/** Decode the [Asn1Primitive] as a [BigInteger]
* @throws [Asn1Exception] on invalid input */
Expand All @@ -154,7 +154,7 @@ fun Asn1Primitive.decodeToBigInteger() =
runRethrowing { decode(Asn1Element.Tag.INT) { BigInteger.decodeFromAsn1ContentBytes(it) } }

/** Exception-free version of [decodeToBigInteger] */
inline fun Asn1Primitive.decodeToBigIntegerOrNull() = runCatching { decodeToBigInteger() }.getOrNull()
inline fun Asn1Primitive.decodeToBigIntegerOrNull() = catching { decodeToBigInteger() }.getOrNull()

/**
* transforms this [Asn1Primitive] into an [Asn1String] subtype based on its tag
Expand Down Expand Up @@ -183,7 +183,7 @@ fun Asn1Primitive.asAsn1String(): Asn1String = runRethrowing {
fun Asn1Primitive.decodeToString() = runRethrowing {asAsn1String().value}

/** Exception-free version of [decodeToString] */
fun Asn1Primitive.decodeToStringOrNull() = runCatching { decodeToString() }.getOrNull()
fun Asn1Primitive.decodeToStringOrNull() = catching { decodeToString() }.getOrNull()



Expand Down
4 changes: 2 additions & 2 deletions supreme/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ signing {
val signingKeyId: String? by project
val signingKey: String? by project
val signingPassword: String? by project
// useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
// sign(publishing.publications)
useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
sign(publishing.publications)
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ object AndroidKeyStoreProvider:
val publicKey: CryptoPublicKey
val attestation: AndroidKeystoreAttestation?
ks.getCertificateChain(alias).let { chain ->
runCatching { chain.map { X509Certificate.decodeFromDer(it.encoded) } }.let { r ->
catching { chain.map { X509Certificate.decodeFromDer(it.encoded) } }.let { r ->
if (r.isSuccess) r.getOrThrow().let {
publicKey = it.leaf.publicKey
attestation = if (it.size > 1) AndroidKeystoreAttestation(it) else null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@ inline fun <T: CryptoSignature.RawByteEncodable, S: CryptoSignature.RawByteEncod
/** Runs the block, catches exceptions, and maps to [SignatureResult].
* @see SignatureResult.FromException */
internal inline fun signCatching(fn: ()->CryptoSignature.RawByteEncodable): SignatureResult<*> =
runCatching { fn() }.fold(
catching { fn() }.fold(
onSuccess = { SignatureResult.Success(it) },
onFailure = { SignatureResult.FromException(it) })

0 comments on commit d40a119

Please sign in to comment.