Package com.yubico.yubikit.fido
Class Cbor
java.lang.Object
com.yubico.yubikit.fido.Cbor
Provides canonical CBOR encoding and decoding.
Only a small subset of CBOR is implemented, sufficient for CTAP2 functionality.
Note that while any integer type can be encoded into canonical CBOR, but all CBOR integers will decode to an int. Thus, numeric map keys can use any integer type (byte, short, int, long) when encoding to send to a device, but any response will have ints for keys.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Object
decode
(byte[] data) Decodes an Object from CBOR data.static Object
decode
(byte[] data, int offset, int length) Decodes an Object from CBOR data.static Object
decodeFrom
(ByteBuffer buf) Decodes a single Object from a ByteBuffer containing CBOR encoded data at the buffers current position.static byte[]
Encodes an object into canonical CBOR.static void
encodeTo
(OutputStream stream, Object value) Encodes an object into canonical CBOR, to an OutputStream.
-
Constructor Details
-
Cbor
public Cbor()
-
-
Method Details
-
encode
Encodes an object into canonical CBOR.- Parameters:
value
- the Object to encode.- Returns:
- CBOR encoded bytes.
-
encodeTo
Encodes an object into canonical CBOR, to an OutputStream.- Parameters:
stream
- the output stream to write tovalue
- the Object to encode.- Throws:
IOException
- A communication error in the transport layer.
-
decode
Decodes an Object from CBOR data.- Parameters:
data
- The CBOR encoded byte array.offset
- The offset of where the CBOR encoded data is in the given byte array.length
- The length of CBOR encoded data.- Returns:
- The decoded Object.
-
decode
Decodes an Object from CBOR data.- Parameters:
data
- The CBOR encoded byte array.- Returns:
- The decoded Object.
-
decodeFrom
Decodes a single Object from a ByteBuffer containing CBOR encoded data at the buffers current position. The position will be updated to point to the end of the CBOR data.- Parameters:
buf
- the ByteBuffer from where the Object should be decoded.- Returns:
- The decoded object.
-