yeah, EDI parsing needs a lot of flexibility.
I have read that there are 2 ways to implement digital signatures: AUTACK messages or attaching security headers and trailers inside the message. I have only seen signed messages using the second method. I guess that changing the envelope to support this optional headers should made the trick.
USH+1+768+2+1+6+2+1+1::XXXXXXXXXXXXX::9+2::XXXXXXXXXXXXX::9++1:20110404:192537' -> security header
1 = Non-repudiation of origin
768 = Security reference number
2 = Scope of security application (From security header to security trailer)
1 = Response type, coded (No AUTACK acknowledgement message expected)
6 = Filter function, coded (UN/EDIFACT EDC filter. Filter function for UN/EDIFACT character set repertoire A as described in Part 5 of ISO 9735)
2 = Original character set encoding, coded (ASCII 8 bit)
1 = Role of security provider, coded (Issuer)
1 = Security party qualifier (Message Sender)
USA+1:::16:1' -> security algorithm
1 = Use of algorithm, coded (owner hashed)
16 = Algorithm coded (SHA1)
1 = Algorithm code list identifier (UN/CEFACT)
USC+3CB382EF' -> certificate reference (3CB382EF)
USA+6:16:1:10:1:7+14:1024+12:ZÞÝ~~óbsåÕï}órLüJöJpñIÆÖGÉï\ofSÐÍÙpûCQEpÅÊVgÔìdÂcHÔvÛåØÙÍWÎüY`mbUvïêSpIïÂLÌVÖmuçkÍtbúÈMgeìÁÅEÍêdiÛIaÂÂÆ\\zì^dÛ]÷tS^cùltuÉçcû|ËxÚÊàhQGÛäßs|ÓÍV]UÑ`àÍ+13:ðA@A'
Security algorithm
6 = Owner signing
16 = Cryptographic mode of operation, coded (DSMR)
1 = Mode of operation code list identifier (UN/CEFACT)
10 = Algorith, Coded (RSA)
7 = Padding mechanism, coded (ISO 9796 #2 padding)
However, sending digitally signed INVOIC messages is an additional step that I'm planning to do after I finish implementing the messages I need, if the company I'm working for wants to invest the time on it (not sure it is the case though).