Skip to content

Commit

Permalink
- check unprotected header as a fallback; (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
MykhailoNester authored May 12, 2021
1 parent 542f8bd commit cb0cb9b
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,16 @@ class DefaultCoseService : CoseService {
val content = messageObject[2].GetByteString()
val rgbProtected = messageObject[0].GetByteString()
val key = HeaderKeys.KID.AsCBOR()
val objProtected = CBORObject.DecodeFromBytes(rgbProtected).get(key).GetByteString()
CoseData(content, objProtected)
var kid = CBORObject.DecodeFromBytes(rgbProtected).get(key)
// Kid in unprotected header
if (kid == null) {
kid = messageObject[1].get(key)
}
val kidByteString = kid.GetByteString()
CoseData(content, kidByteString)

} catch (e: Throwable) {
null
}
}
}

}

0 comments on commit cb0cb9b

Please sign in to comment.