Skip to content

Stream Message Too Large For Algorithm

URI: https://docs.ankatech.co/errors/stream-message-too-large-for-algorithm
HTTP Status: 413 Content Too Large (RFC 9110 §15.5.14)

When you see this

A streaming operation of the Core API (the /api/v3/crypto/stream/* operations, /api/v3/migration/stream/convert-pkcs7-to-jose and /api/v3/interoperability/verify) was refused because the streamed message is larger than the key's algorithm can process in one streamed operation.

Most algorithms process a stream as it arrives. Some cannot: they keep the whole message until they sign, verify or finish, so the Core API bounds how much of a message such an algorithm may be fed, and refuses before the octet that would pass the bound reaches it. The bound is derived from the service's memory (16 MiB on a 1 GiB heap, or lower where the operator lowered it) and is shared equally by the keys of one request that keep the message; for an attached JWS it counts the payload's base64url encoding. The algorithms that keep the whole message are:

Algorithm Signing Verifying
Ed25519, Ed448 keeps the message keeps the message
SLH-DSA, every parameter set keeps the message keeps the message
Falcon keeps the message keeps the message
XMSS, XMSS^MT keeps the message keeps the message
LMS / HSS streams keeps the message
ML-DSA, ECDSA, RSA-PSS, SM2, GOST R 34.10-2012 streams streams

A composite signature key streams: it signs a fixed-size digest of the message. Among the content ciphers, every CCM mode (AES, ARIA and SM4) keeps the whole message on encryption and on decryption, because CCM authenticates the message length before its first block (NIST SP 800-38C §6.1); a CCM message is also bounded by the mode itself, 16,777,215 octets for the 12-octet nonce the platform uses (RFC 3610 §2.1). Every GCM mode and ChaCha20-Poly1305 stream.

The same problem type is answered in three cases, each with its own fixed detail:

  • The message is too large for the key's algorithm. The message outgrew what the algorithm may be fed in one streamed operation, or what its mode can process:

    The streamed message is larger than the key's algorithm can process in one streamed operation on this service. To stream a larger message, sign or verify with an ML-DSA, ECDSA, RSA-PSS or composite key, and encrypt or decrypt with AES-GCM instead of a CCM mode.

  • No room is left in the operation for another such key. One streamed operation can feed the same message to several keys (the signers of a multi-signature verification, a re-signature's source signers beside its new signer). The room one request may hold for keys whose algorithm keeps the whole message was already held by its other keys, or was returned when the operation ended:

    This streamed operation has no room left for another key whose algorithm holds the whole message: the room one request may hold for such keys is already held by its other keys, or was returned when the operation ended. To stream it, sign or verify with an ML-DSA, ECDSA, RSA-PSS or composite key, and encrypt or decrypt with AES-GCM instead of a CCM mode.

  • The key needs more than its share, whatever the message. The least the key's algorithm holds for any message, an empty one included, is more than the share of the operation's room one key is given:

    The key's algorithm needs more room than this streamed operation can give one key, whatever the length of the message. To stream it, sign or verify with an ML-DSA, ECDSA, RSA-PSS or composite key, and encrypt or decrypt with AES-GCM instead of a CCM mode.

The refusal is about the message and the key, not about load: retrying the same message with the same key is refused the same way. When the instance's room for such keys, or the tenant's share of it, cannot take the request at that moment, the answer is Streaming Concurrency Limit (429 with Retry-After) instead.

Response

Before the response is committed, the operation answers this problem document:

{
  "type": "https://docs.ankatech.co/errors/stream-message-too-large-for-algorithm",
  "title": "Stream Message Too Large For Algorithm",
  "status": 413,
  "detail": "The streamed message is larger than the key's algorithm can process in one streamed operation on this service. To stream a larger message, sign or verify with an ML-DSA, ECDSA, RSA-PSS or composite key, and encrypt or decrypt with AES-GCM instead of a CCM mode.",
  "instance": "/api/v3/crypto/stream/sign",
  "timestamp": 1794738067,
  "correlationId": "5f0c2a9e-7b41-4c8d-9e2f-1a6b3c4d5e6f"
}

The detail is one of the three fixed texts above. It never names a size, a limit, a tenant or a key.

After the response is committed, a problem document can no longer be sent: the stream is ended instead (an HTTP/2 stream reset, or an HTTP/1.1 body without its terminating chunk; where the reset cannot be recorded, the connection is closed). Part of the body may already have been sent: it is incomplete, and the caller discards it. Either way the operation's audit record is one FAILURE with the code stream-message-too-large-for-algorithm.

Common Causes

  • A large file signed or verified with an Ed25519, Ed448, SLH-DSA, Falcon, XMSS or XMSS^MT key, or verified with an LMS / HSS key.
  • A large file encrypted or decrypted with a key whose content cipher is a CCM mode.
  • A multi-signature verification or a re-signature whose several keys all keep the whole message.

How to Resolve

  1. To stream large messages, sign and verify with an ML-DSA, ECDSA, RSA-PSS or composite key, and encrypt and decrypt with AES-GCM instead of a CCM mode. These process the stream as it arrives and are not bounded this way.
  2. Where the algorithm is fixed by policy or by the other party, keep the message small enough for it, or split it.
  3. For a verification or re-signature with several keys that keep the whole message, reduce how many of them one operation feeds.