| Previous | Next |
| CRYPT_E_ASN1_MEMORY | CRYPT_E_ASN1_BADPDU |
CRYPT_E_ASN1_OVERFLOW
The destination buffer cannot hold the result
CRYPT_E_ASN1_OVERFLOW is a buffer-capacity failure in the ASN.1 layer. The encoded object may be valid, but the caller-provided destination or an intermediate fixed-size buffer is too small for the encoded or decoded representation.
CryptoAPI encoding and decoding functions support a size-query pattern: call with a null output pointer to obtain the required size, allocate that many bytes, and call again. Reusing a cached size is unsafe when certificate names, extensions, signatures, or optional fields can change between objects.
Correct handling
- Use the documented two-call size-query pattern.
- Treat returned sizes as byte counts, not element counts.
- Guard additions and alignments against integer overflow before allocation.
- Do not truncate DER output; every embedded length would then describe different data.
References
- Microsoft: CryptEncodeObjectEx output sizing
- Microsoft: CryptDecodeObjectEx output sizing
- ITU-T X.690: length octets and complete encodings
Looking for a different code? Search another status or error code.