From 1a64e4f4b02f9820602a552c87bf62949c461b55 Mon Sep 17 00:00:00 2001 From: sim Date: Sat, 9 May 2026 17:51:23 +0200 Subject: [PATCH] Fix COSE decoding with x-only keys --- .../kotlin/org/microg/gms/fido/core/protocol/CoseKey.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/play-services-fido/core/src/main/kotlin/org/microg/gms/fido/core/protocol/CoseKey.kt b/play-services-fido/core/src/main/kotlin/org/microg/gms/fido/core/protocol/CoseKey.kt index 61bec1fec4..62ee25fc3f 100644 --- a/play-services-fido/core/src/main/kotlin/org/microg/gms/fido/core/protocol/CoseKey.kt +++ b/play-services-fido/core/src/main/kotlin/org/microg/gms/fido/core/protocol/CoseKey.kt @@ -22,7 +22,7 @@ import java.security.spec.ECPublicKeySpec class CoseKey( val algorithm: Algorithm, val x: ByteArray, - val y: ByteArray, + val y: ByteArray?, val curveId: Int ) { constructor(algorithm: Algorithm, x: BigInteger, y: BigInteger, curveId: Int, curvePointSize: Int) : @@ -35,7 +35,9 @@ class CoseKey( set(ALG, algorithm.algoValue.encodeAsCbor()) set(CRV, curveId.encodeAsCbor()) set(X, x.encodeAsCbor()) - set(Y, y.encodeAsCbor()) + y?.let { + set(Y, y.encodeAsCbor()) + } } fun asCryptoKey(): PublicKey? { @@ -74,7 +76,7 @@ class CoseKey( fun decodeFromCbor(obj: CBORObject): CoseKey = CoseKey( getAlgorithm(obj.get(CoseKey.ALG).AsInt32Value()), obj.get(CoseKey.X).GetByteString(), - obj.get(CoseKey.Y).GetByteString(), + runCatching { obj.get(CoseKey.Y).GetByteString() }.getOrNull(), obj.get(CoseKey.CRV).AsInt32Value() )