Skip to content

Commit

Permalink
minor polishing
Browse files Browse the repository at this point in the history
Co-authored-by: Jakob Heher <jakob.heher@iaik.tugraz.at>
  • Loading branch information
JesusMcCloud and iaik-jheher committed Oct 4, 2024
1 parent 9aeb4d7 commit 3c3a31c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,10 @@ internal fun App() {
var currentSigner by remember { mutableStateOf<KmmResult<Signer>?>(null) }
val currentKey by getter { currentSigner?.mapCatching(Signer::publicKey) }
val currentKeyStr by getter {
currentKey?.fold(onSuccess = {
it.toString()
},
currentKey?.fold(
onSuccess = {
it.toString()
},
onFailure = {
Napier.e("Key failed", it)
"${it::class.simpleName ?: "<unnamed>"}: ${it.message}"
Expand Down Expand Up @@ -310,8 +311,8 @@ internal fun App() {
when (val alg = keyAlgorithm.algorithm) {
is SignatureAlgorithm.ECDSA -> {
this@createSigningKey.ec {
curve = alg.requiredCurve
?: ECCurve.entries.find { it.nativeDigest == alg.digest }!!
curve = alg.requiredCurve ?:
ECCurve.entries.find { it.nativeDigest == alg.digest }!!
digests = setOf(alg.digest)
}
}
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/indispensable.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ All of these functions throw an `Asn1Exception` when decoding fails.
Moreover, a generic tag assertion function is present on `Asn1Element`, which throws an `Asn1TagMisMatchException` on error
and returns the tag-asserted element on success:

* `Asn1Element.assertTag()` takes either an `Asn1Element.Tag` or an `Ulong` tag number
* `Asn1Element.assertTag()` takes either an `Asn1Element.Tag` or an `ULong` tag number


### Encoding
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ sealed class Asn1Element(
/**
* Creates a copy of this tag, overriding [tagValue], but keeping [isConstructed] and [tagClass]
*/
fun withNumber(number: ULong) = Tag(number, constructed = isConstructed, tagClass = tagClass)
infix fun withNumber(number: ULong) = Tag(number, constructed = isConstructed, tagClass = tagClass)

constructor(tagValue: ULong, constructed: Boolean, tagClass: TagClass = TagClass.UNIVERSAL) : this(
encode(
Expand Down Expand Up @@ -409,7 +409,7 @@ inline fun <reified T : Asn1Element> T.assertTag(tag: Asn1Element.Tag): T {
* @throws Asn1TagMismatchException on failure
*/
@Throws(Asn1TagMismatchException::class)
inline fun <reified T : Asn1Element> T.assertTag(tagNumber: ULong): T = assertTag(tag.withNumber(tagNumber))
inline fun <reified T : Asn1Element> T.assertTag(tagNumber: ULong): T = assertTag(tag withNumber tagNumber)

object Asn1EncodableSerializer : KSerializer<Asn1Element> {
override val descriptor = PrimitiveSerialDescriptor("Asn1Encodable", PrimitiveKind.STRING)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ suspend fun Signer.sign(tbsCertificate: TbsCertificate): KmmResult<X509Certifica
}

/**
* Shorthand helper to creat a [Pkcs10CertificationRequest] by signing [tbsCsr]
* Shorthand helper to create a [Pkcs10CertificationRequest] by signing [tbsCsr]
*/
suspend fun Signer.sign(tbsCsr: TbsCertificationRequest): KmmResult<Pkcs10CertificationRequest> {
val toX509SignatureAlgorithm =
Expand Down

0 comments on commit 3c3a31c

Please sign in to comment.