Zoltán Kéri
f1f2ed3194
encoding/base32: Fix decode implementation per RFC 4648
Rework base32.decode() to properly handle all cases per RFC 4648:
- Fix error detection order:
- Check minimum length first (Invalid_Length)
- Check character validity (Invalid_Character)
- Check padding and structure (Malformed_Input)
- Fix padding validation:
- Add required padding length checks (2=6, 4=4, 5=3, 7=1 chars)
- Ensure padding only appears at end
- Fix handling of unpadded inputs
- Fix buffer handling:
- Proper output buffer size calculation
- Add bounds checking for buffer access
- Add proper buffer validation
For example:
- "M" correctly returns Invalid_Length (too short)
- "mzxq====" correctly returns Invalid_Character (lowercase)
- "MZXQ=" correctly returns Malformed_Input (wrong padding)
- Unpadded input lengths must be multiples of 8
These changes make the decode function fully compliant with RFC 4648
requirements while providing proper error handling.
2024-12-24 15:52:33 +01:00
..
2024-09-03 19:59:04 +02:00
2024-12-24 15:52:33 +01:00
2024-04-18 12:17:39 +01:00
2024-10-29 01:50:38 -03:00
2024-09-03 19:59:04 +02:00
2024-09-03 19:59:04 +02:00
2024-09-03 19:59:04 +02:00
2024-08-09 21:56:54 +02:00
2024-11-17 21:35:49 +01:00
2024-09-24 18:57:42 +11:00
2024-12-06 22:12:52 +01:00
2024-09-03 19:59:04 +02:00
2024-09-03 19:59:04 +02:00
2024-09-03 19:59:04 +02:00