SpliceUnsignedAttr
function SpliceUnsignedAttr(const aDer: OctetString; aSignerIndex: Integer; const aAttrDer: OctetString; out aOut: OctetString; out aError: string): Boolean;
SpliceUnsignedAttr appends the complete Attribute TLV aAttrDer to signerInfos[aSignerIndex].unsignedAttrs of the ContentInfo in aDer, creating the [1] IMPLICIT field if it is absent, and returns the rebuilt encoding.
BYTE SURGERY ON PURPOSE. Only the unsignedAttrs SET and the four enclosing length fields are rewritten; every other octet is copied verbatim. A DER round-trip through the object model is NOT an acceptable substitute: it re-serialises signedAttrs, which destroys the signature of any token that was not already strict DER. That is why this exists rather than reusing AddGenericUnsignedAttr.
Note unsignedAttrs is a SET OF and DER would order its members by encoding. We append instead. That is sound here because unsignedAttrs is covered by no signature and no imprint (EN 319 122-1 cl. 5.5.3 excludes it, and the token's own unsignedAttrs sit outside the TSU signature), and the ATSHashIndex covers attribute VALUES individually rather than the SET's encoding.