textOrByteStringDeterministic returns length of the text or byte string element in bytes for which its deterministicy has been ensured
(input []byte)
| 111 | |
| 112 | // textOrByteStringDeterministic returns length of the text or byte string element in bytes for which its deterministicy has been ensured |
| 113 | func textOrByteStringDeterministic(input []byte) (int, error) { |
| 114 | // uintLen is the length of the number representing the length of the text/byte string. |
| 115 | uintLen, stringLen, err := unsignedIntegerDeterministic(input) |
| 116 | if err != nil { |
| 117 | return 0, err |
| 118 | } |
| 119 | |
| 120 | if (uintLen + int(stringLen)) >= len(input) { |
| 121 | panic("Text or byte string's length cannot exceed the length of the input byte array.") |
| 122 | } |
| 123 | |
| 124 | return uintLen + int(stringLen), nil |
| 125 | } |
| 126 | |
| 127 | // arrayDeterministic returns length of the CBOR array in bytes and checks that each item on it follows the deterministic principles. |
| 128 | func arrayDeterministic(input []byte) (int, error) { |