Is your feature request related to a problem? Please describe.
For an application whose CBOR-based protocol does not include arbitrary-precision integers (https://www.rfc-editor.org/rfc/rfc8949.html#section-5-3), it should be possible to reject the bignum tags 2 and 3 on decode and math/big.Int on encode.
Describe the solution you'd like
A new decode option specifying the decode behavior for the bignum tags, regardless of the Go type of the unmarshal destination object. Its default value would be backwards-compatible and would permit the bignum tag, but its second mode will cause Wellformed and Unmarshal to return an UnacceptableDataItemError if a bignum tag is encountered.
A new mode for the encode option BigIntConvert, analogous to the InfConvert and NaNConvert options introduced by https://github.com/fxamacker/cbor/pull/513, that will return an UnsupportedTypeError if a math/big.Int is passed to Marshal.
Describe alternatives you've considered
The existing BigIntDec option is scoped to unmarshaling bignums into interface{}, which would not be suitable on its own for the purpose of rejecting all bignums. Bignums can also be decoded into uint, int, float, slice, array, and math/big.Int. I ended up adding the new option because I did not see a use case where the type of the destination Go value would affect whether or not a CBOR-based protocol accepts a particular input.
Is your feature request related to a problem? Please describe.
For an application whose CBOR-based protocol does not include arbitrary-precision integers (https://www.rfc-editor.org/rfc/rfc8949.html#section-5-3), it should be possible to reject the bignum tags 2 and 3 on decode and
math/big.Int
on encode.Describe the solution you'd like
UnacceptableDataItemError
if a bignum tag is encountered.BigIntConvert
, analogous to theInfConvert
andNaNConvert
options introduced by https://github.com/fxamacker/cbor/pull/513, that will return anUnsupportedTypeError
if amath/big.Int
is passed to Marshal.Describe alternatives you've considered
The existing
BigIntDec
option is scoped to unmarshaling bignums intointerface{}
, which would not be suitable on its own for the purpose of rejecting all bignums. Bignums can also be decoded into uint, int, float, slice, array, andmath/big.Int
. I ended up adding the new option because I did not see a use case where the type of the destination Go value would affect whether or not a CBOR-based protocol accepts a particular input.Additional context