| 3113 | } |
| 3114 | |
| 3115 | static bool readiness_hex_decode(const char *hex, uint8_t out[CBM_SHA256_DIGEST_LEN]) { |
| 3116 | if (!hex || strlen(hex) != CBM_SHA256_HEX_LEN) { |
| 3117 | return false; |
| 3118 | } |
| 3119 | for (size_t i = 0; i < CBM_SHA256_DIGEST_LEN; i++) { |
| 3120 | int high = readiness_hex_nibble(hex[i * 2U]); |
| 3121 | int low = readiness_hex_nibble(hex[i * 2U + 1U]); |
| 3122 | if (high < 0 || low < 0) { |
| 3123 | return false; |
| 3124 | } |
| 3125 | out[i] = (uint8_t)((high << 4) | low); |
| 3126 | } |
| 3127 | return true; |
| 3128 | } |
| 3129 | |
| 3130 | static void readiness_hex_encode(const uint8_t bytes[CBM_SHA256_DIGEST_LEN], |
| 3131 | char out[CBM_SHA256_HEX_LEN + 1U]) { |
no test coverage detected