Table of Contents

Interface Module to TDTool Library

Module SYSTDT Interface Module to TDTool Library

Description

Module to supply file features to access files for or from external
systems using a different character set or packed numbers or
encoding.
This module internally uses the TDTOOL DLL/Shared Library to
perform the different conversion tasks

SYSTDT is a module to supply features for accessing files for or from external systems using a different character set or packed numbers or encoding.
This module internally uses the TDTOOL DLL/Shared Library to perform the different conversion tasks.

The main features are:

If one of these features is required within a transaction, the module SYSTDT should be made available and the respective routines should be called.


Properties

Property YES/NO
Single page frame No
Show toolbar No
Show menu No
Show statusbar No
Show hint No
Fit panel size No

Rules

Rule Name Additional
function AssertTdToolLibOpen text global
function FormatUUID text global
function TDBase64DecodeText text global
function TDBase64EncodeText text global
function TDBase64EncodeTextToSingleLine text global
function TDBase64EncodeToSingleLine text global
function TDBase64URLDecodeText text global
function TDBase64URLEncodeText text global
function TDCalcHash text global
function TDCalcHashAny text global
function TDCalcHashString text global
function TDCalcHMAC text global
function TDCalcHMACAny text global
function TDCalcHMACEnc text global
function TDCalcHMACN text global
function TDCalcHMACNAny text global
function TDCalcHMACNEnc text global
function TDCalcHMACNString text global
function TDCalcHMACNStringEnc text global
function TDCalcHMACString text global
function TDCalcHMACStringEnc text global
function TDConvertLinefeed text global
function TDEBCDICDecode text global
function TDEBCDICEncode text global
function TDEBCDICISODecode text global
function TDEBCDICISOEncode text global
function TDExportExternalText text global
function TDFingerprint text global
function TDGetLocalEncoding text global
function TDHexDecodeNum numeric global
function TDHexDecodeText text global
function TDHexEncodeNum text global
function TDHexEncodeText text global
function TDHexEncodeTextToSingleLine text global
function TDHexEncodeToSingleLine text global
function TDImportExternalText text global
function TDQPDecodeText text global
function TDQPEncodeText text global
function TDQPEncodeTextToSingleLine text global
function TDQPEncodeToSingleLine text global
function TDRFC1522Decode text global
function TDRFC1522Encode text global
function TDURLEncode text global
function TDUUID text global
function TDUUID4 text global
function TDUUIDByName text global
sub TDBase64Decode global
sub TDBase64Encode global
sub TDCMSDecrypt global
sub TDCMSEncrypt global
sub TDCMSEncryptV2 global
sub TDCMSSign global
sub TDCMSSignV2 global
sub TDCMSVerify global
sub TDDecrypt global
sub TDDecryptByKey global
sub TDDeflateText global
sub TDDERToPEM global
sub TDEncrypt global
sub TDEncryptByKey global
sub TDEncryptV2 global
sub TDGunzip global
sub TDGzip global
sub TDHexDecode global
sub TDHexEncode global
sub TDInflateText global
sub TDLineBreak global
sub TDP12ToPEM global
sub TDP12ToPEMV2 global
sub TDPackComp3 global
sub TDPEMToDER global
sub TDPEMToP12 global
sub TDQPDecode global
sub TDQPEncode global
sub TDRSADecrypt global
sub TDRSAEncrypt global
sub TDRSASign global
sub TDRSAVerify global
sub TDSign global
sub TDSignBuf global
sub TDSignBufV2 global
sub TDSignV2 global
sub TDUnpackComp3 global
sub TDUnpackUnsigned global
sub TDVerify global

Rules Description and Comments

function AssertTdToolLibOpen : text global

assert that library is opened


function TDBase64DecodeText( in ArgB64Str text ) : text global

Decode Base64 encoded text

ArgB64Str base64 encoded text to decode.

Corresponding functions: TDBase64EncodeText


function TDBase64EncodeText( in ArgInStr text ) : text global

Base64 encode text

ArgInStr text to encode.

Corresponding functions: TDBase64DecodeText


function TDBase64EncodeTextToSingleLine( in ArgInStr text ) : text global

Base64 encode text

ArgInStr text to encode.

Corresponding functions: TDBase64DecodeText


function TDBase64EncodeToSingleLine( in ArgFilNam text ) : text global

read file and return base64 encoded text

ArgFilNam Filename of file to read, a relative filename is resolved relative to the data partition.
ArgOutStr outputstream loaded with the base64 encoded contents of the file after processing it.

Corresponding functions: TDBase64Decode


function TDBase64URLDecodeText( in ArgB64Str text ) : text global

Decode Base64URL encoded text

ArgB64Str base64url encoded text to decode.

Corresponding functions: TDBase64URLEncodeText


function TDBase64URLEncodeText( in ArgInStr text ) : text global

Base64URL encode text

ArgInStr text to encode.

Corresponding functions: TDBase64URLDecodeText


function TDCalcHash( in ArgMethod text, in ArgInStr text ) : text global

Calc hash value using specified method

ArgMethod digest algorithm.
ArgInStr text to calc hash from.

Corresponding functions: TDCalcHashString, TDCalcHMACString, TDCalcHMAC, TDCalcHMACNString, TDCalcHMACN


function TDCalcHashString( in ArgMethod text, in ArgInStr text, in ArgOutputFormat text ) : text global

Calc hash value using specified method

ArgMethod digest algorithm.
ArgInStr text to calc hash from.
ArgOutputFormat 'B', 'B64', 'Base64' = Base64 -and- 'H', 'HEX': HEX

Corresponding functions: TDCalcHash, TDCalcHMACString, TDCalcHMAC, TDCalcHMACNString, TDCalcHMACN


function TDCalcHMAC( in ArgMethod text, in ArgInStr text, in ArgKeyStr text ) : text global

Calc hash value using specified method

ArgMethod digest algorithm.
ArgInStr text to calc HMAC from.
ArgKeyStr key for HMAC calculation.

Corresponding functions: TDCalcHashString, TDCalcHash, TDCalcHMACString, TDCalcHMACNString, TDCalcHMACN


function TDCalcHMACEnc( in ArgMethod text, in ArgInStr text, in ArgKeyStr text, in ArgEncoding text ) : text global

Calc hash value using specified method

ArgMethod digest algorithm.
ArgInStr text to calc HMAC from.
ArgKeyStr key for HMAC calculation.
ArgEncoding e.g. UTF-8 Input String Encoding for MAC calculation

Corresponding functions: TDCalcHashString, TDCalcHash, TDCalcHMAC, TDCalcHMACNString, TDCalcHMACN, TDCalcHashStringEnc, TDCalcHashEnc, TDCalcHMACEnc, TDCalcHMACNStringEnc, TDCalcHMACNEnc


function TDCalcHMACN( in ArgMethod text, in ArgInStr text, in ArgKeyStr text, in ArgMaxLen numeric ) : text global

Calc hash value using specified method

ArgMethod digest algorithm.
ArgInStr text to calc HMAC from.
ArgKeyStr key for HMAC calculation.
ArgMaxLen maximum number bytes used from HMAC

Corresponding functions: TDCalcHashString, TDCalcHash, TDCalcHMAC, TDCalcHMACNString, TDCalcHMACN, TDCalcHashStringEnc, TDCalcHashEnc, TDCalcHMACEnc, TDCalcHMACNStringEnc, TDCalcHMACNEnc


function TDCalcHMACNEnc( in ArgMethod text, in ArgInStr text, in ArgKeyStr text, in ArgMaxLen numeric, in ArgEncoding text ) : text global

Calc hash value using specified method

ArgMethod digest algorithm.
ArgInStr text to calc HMAC from.
ArgKeyStr key for HMAC calculation.
ArgMaxLen maximum number bytes used from HMAC
ArgEncoding e.g. UTF-8 Input String Encoding for MAC calculation

Corresponding functions: TDCalcHashString, TDCalcHash, TDCalcHMAC, TDCalcHMACNString, TDCalcHMACN, TDCalcHashStringEnc, TDCalcHashEnc, TDCalcHMACEnc, TDCalcHMACNStringEnc, TDCalcHMACNEnc


function TDCalcHMACNString( in ArgMethod text, in ArgInStr text, in ArgKeyStr text, in ArgMaxLen numeric, in ArgOutputFormat text ) : text global

Calc hash value using specified method

ArgMethod digest algorithm.
ArgInStr text to calc HMAC from.
ArgKeyStr key for HMAC calculation.
ArgMaxLen maximum number bytes used from HMAC
ArgOutputFormat 'B', 'B64', 'Base64' = Base64 -and- 'H', 'HEX': HEX

Corresponding functions: TDCalcHashString, TDCalcHash, TDCalcHMAC, TDCalcHMACNString, TDCalcHMACN, TDCalcHashStringEnc, TDCalcHashEnc, TDCalcHMACEnc, TDCalcHMACNStringEnc, TDCalcHMACNEnc


function TDCalcHMACNStringEnc( in ArgMethod text, in ArgInStr text, in ArgKeyStr text, in ArgMaxLen numeric, in ArgOutputFormat text, in ArgEncoding text ) : text global

Calc hash value using specified method

ArgMethod digest algorithm.
ArgInStr text to calc HMAC from.
ArgKeyStr key for HMAC calculation.
ArgMaxLen maximum number bytes used from HMAC
ArgOutputFormat 'B', 'B64', 'Base64' = Base64 -and- 'H', 'HEX': HEX
ArgEncoding e.g. UTF-8 Input String Encoding for MAC calculation

Corresponding functions: TDCalcHashString, TDCalcHash, TDCalcHMAC, TDCalcHMACNString, TDCalcHMACN, TDCalcHashStringEnc, TDCalcHashEnc, TDCalcHMACEnc, TDCalcHMACNStringEnc, TDCalcHMACNEnc


function TDCalcHMACString( in ArgMethod text, in ArgInStr text, in ArgKeyStr text, in ArgOutputFormat text ) : text global

Calc hash value using specified method

ArgMethod digest algorithm.
ArgInStr text to calc HMAC from.
ArgKeyStr key for HMAC calculation.
ArgOutputFormat 'B', 'B64', 'Base64' = Base64 -and- 'H', 'HEX': HEX

Corresponding functions: TDCalcHashString, TDCalcHash, TDCalcHMAC, TDCalcHMACNString, TDCalcHMACN


function TDCalcHMACStringEnc( in ArgMethod text, in ArgInStr text, in ArgKeyStr text, in ArgOutputFormat text, in ArgEncoding text ) : text global

Calc hash value using specified method

ArgMethod digest algorithm.
ArgInStr text to calc HMAC from.
ArgKeyStr key for HMAC calculation.
ArgOutputFormat 'B', 'B64', 'Base64' = Base64 -and- 'H', 'HEX': HEX
ArgEncoding e.g. UTF-8 Input String Encoding for MAC calculation

Corresponding functions: TDCalcHashString, TDCalcHash, TDCalcHMAC, TDCalcHMACNString, TDCalcHMACN, TDCalcHashStringEnc, TDCalcHashEnc, TDCalcHMACEnc, TDCalcHMACNStringEnc, TDCalcHMACNEnc


function TDConvertLinefeed( in ArgMode numeric, in ArgInStr stream ) : text global

Get stream content as text with defined linefeed characters

ArgMode 0 = remove linefeed chars, 1 = convert to CR, 2 = convert to LF, 3 = convert to CRLF
ArgInStm input stream.

Result text with specified linefeed characters

Corresponding functions: -


function TDEBCDICDecode( in ArgTxt text ) : text global

convert text content from ebcdic to us ascii and return the converted text

ArgTxt input text in ebcdic to be converted.
The function returns the converted text.


function TDEBCDICEncode( in ArgTxt text ) : text global

convert text content from us ascii to ebcdic and return the converted text

ArgTxt input text in us ascii to be converted.
The function returns the converted text.


function TDEBCDICISODecode( in ArgTxt text ) : text global

convert text content from ebcdic to iso-8859-1 and return the converted text

ArgTxt input text in ebcdic to be converted.
The function returns the converted text.


function TDEBCDICISOEncode( in ArgTxt text ) : text global

convert text content from iso-8859-1 to ebcdic and return the converted text

ArgTxt input text in us ascii to be converted.
The function returns the converted text.


function TDExportExternalText( in ArgToEncoding text, in ArgTxt text ) : text global

convert text content in system character set to the to_encoding and return the converted text

ArgToEncoding target encoding for charset conversion.
ArgTxt input text to be converted.
The function returns the converted text.
The routine determines the currently active internal encoding (usually ISO-8859-1) and passes
both encoding names to the iconv routine, which is used for the conversion of the encoding.
Often used encodings are: CP437, CP850, CP1252, ISO-8859-1, UTF-8
Corresponding functions: TDImportExternalText, TDGetLocalEncoding


function TDFingerprint( in ArgMethod text, in ArgEncoding text, in ArgFilNam text ) : text global

fingerprint for file, either base64 or hex encoded

ArgMethod Message Digest to use (MD5, DSS, DSS1, SHA1, SHA224, SHA256, SHA384, SHA512).
ArgEncoding Output encoding for binary fingerprint, 'b' for base64 and 'h' for hex.
ArgFilNam Filename of file to read, a relative filename is resolved relative to the data partition.

Corresponding functions: -


function TDGetLocalEncoding : text global

The routine determines the currently active internal encoding (usually ISO-8859-1) and returns it.
Often used encodings are: CP437, CP850, ISO-8859-1, CP1252, UTF-8

Corresponding functions: TDExportExternalText, TDImportExternalText


function TDHexDecodeNum( in ArgHEXStr text ) : numeric global

Decode HEX encoded text

ArgHEXStr hex encoded text to decode.

Corresponding functions: TDHexEncodeText


function TDHexDecodeText( in ArgHEXStr text ) : text global

Decode HEX encoded text

ArgHEXStr hex encoded text to decode.

Corresponding functions: TDHexEncodeText


function TDHexEncodeNum( in ArgInNum numeric ) : text global

Base64 encode text

ArgInNum number to encode.

Corresponding functions: TDHexDecodeNum


function TDHexEncodeText( in ArgInStr text ) : text global

Base64 encode text

ArgInStr text to encode.

Corresponding functions: TDHexDecodeText


function TDHexEncodeTextToSingleLine( in ArgInStr text ) : text global

Base64 encode text

ArgInStr text to encode.

Corresponding functions: TDHexDecodeText


function TDHexEncodeToSingleLine( in ArgFilNam text ) : text global

read file and put contents hex encoded into a stream

ArgFilNam Filename of file to read, a relative filename is resolved relative to the data partition.
ArgOutStr outputstream loaded with the hex encoded contents of the file after processing it.

Corresponding functions: TDHexDecode


function TDImportExternalText( in ArgFromEncoding text, in ArgTxt text ) : text global

convert text content in from_encoding to the system character set and return the converted text

ArgFromEncoding Source encoding for charset conversion.
ArgTxt input text to be converted.
The function returns the converted text.
The routine determines the currently active internal encoding (usually ISO-8859-1) and passes
both encoding names to the iconv routine, which is used for the conversion of the encoding.
Often used encodings are: CP437, CP850, CP1252, ISO-8859-1, UTF-8

Corresponding functions: TDExportExternalText, TDGetLocalEncoding


function TDQPDecodeText( in ArgQPStr text ) : text global

Decode QuotedPrintable encoded text

ArgQPStr quoted-printable encoded text to decode.

Corresponding functions: TDQPEncodeText


function TDQPEncodeText( in ArgInStr text ) : text global

QuotedPrintable encode text

ArgInStr text to encode.

Corresponding functions: TDQPDecodeText


function TDQPEncodeTextToSingleLine( in ArgInStr text ) : text global

QuotedPrintable encode text

ArgInStr text to encode.

Corresponding functions: TDQPDecodeText


function TDQPEncodeToSingleLine( in ArgFilNam text ) : text global

read file and put contents quoted-printable encoded into a stream

ArgFilNam Filename of file to read, a relative filename is resolved relative to the data partition.
ArgOutStr outputstream loaded with the quoted-printable encoded contents of the file after processing it.

Corresponding functions: TDQPDecode


function TDRFC1522Decode( in ArgTxt text ) : text global

convert text content encoded as specified in RFC 1522 (MIME Message Header Extensions for Non-ASCII Text) [http://www.faqs.org/rfcs/rfc1522.html] to the system character set and return the converted text

ArgTxt input text to be converted.

The function returns the converted text.
The routine determines the currently active internal encoding (usually ISO-8859-1) and passes
the to encoding name to the iconv routine, which is used for the conversion of the encoding.

Corresponding functions: TDRFC1522Encode


function TDRFC1522Encode( in ArgToCharset text, in ArgEncoding text, in ArgTxt text ) : text global

convert text content encoded as specified in RFC 1522 (MIME Message Header Extensions for Non-ASCII Text) [http://www.faqs.org/rfcs/rfc1522.html] to the system character set and return the converted text

ArgToCharset target charset for input text to be converted.
ArgEncoding encoding used, “B” for Base64- and “Q” (or any other than “B”) for “QuotedPrintable”-Encoding
ArgTxt input text to be converted.
The function returns the converted text with the following exception: If the encoding is “Q” and the encoded string equals the original string (e.g. ArgTxt has only US-ASCII characters) the original string is returned
The routine determines the currently active internal encoding (usually ISO-8859-1) and passes
the to encoding name to the iconv routine, which is used for the conversion of the encoding.
Corresponding functions: TDRFC1522Decode


function TDURLEncode( in ArgInStr text ) : text global

URL encode text

ArgInStr text to encode.

Corresponding functions: -


function TDUUID : text global

uuid

The function returns the 128-bit uuid version 1 as unformatted hex string.

Corresponding functions: TDUUID4, TDUUIDByName
The returned UUID is NOT separated into Groups. To get a well formatted UUID the result of this function can be formated using function FormatUUID


function TDUUID4 : text global

uuid4

The function returns the 128-bit uuid version 4 as unformatted hex string.

Corresponding functions: TDUUID, TDUUIDByName
The returned UUID is NOT separated into Groups. To get a well formatted UUID the result of this function can be formated using function FormatUUID


function TDUUIDByName( in ArgNS text, in ArgName text ) : text global

uuid

ArgNS namespace of name (DNS, URL, OID, X500).
ArgName name

The function returns the 128-bit uuid version 5 as unformatted hex string.

Corresponding functions: TDUUID, TDUUID4
The returned UUID is NOT separated into Groups. To get a well formatted UUID the result of this function can be formated using function FormatUUID


sub TDBase64Decode( in ArgFilNam text, in ArgInStr stream ) global

decode base64 encoded stream and write result into file

ArgFilNam Filename of file to write, a relative filename is resolved relative to the data partition.
ArgInStr inputstream with base64 encoded contents to process.

Corresponding functions: TDBase64Encode


sub TDBase64Encode( in ArgFilNam text, out ArgOutStr stream ) global

read file and put contents base64 encoded into a stream

ArgFilNam Filename of file to read, a relative filename is resolved relative to the data partition.
ArgOutStr outputstream loaded with the base64 encoded contents of the file after processing it.

Corresponding functions: TDBase64Decode


sub TDCMSDecrypt( in ArgCertFilNam text, in ArgPKeyFilNam text, in ArgPassphrase text, in ArgInStr stream, out ArgOutStr stream ) global

CMS decrypt base64 encoded content to text and put it into a stream

ArgCertFilNam Filename of certificate file in PEM format (not used if pkey is read from P12), a relative filename is resolved relative to the ini partition.
ArgPKeyFilNam Filename of private key file in PEM / P12 format, a relative filename is resolved relative to the ini partition.
ArgPassphrase Passphrase for the private key / certificate file.
ArgInStr Inputstream with base64 encoded content to decrypt.
ArgOutStr Outputstream loaded with decrypted text content.

Corresponding functions: TDSign, TDEncrypt, TDVerify


sub TDCMSEncrypt( in ArgCertFilNam text, in ArgCipherId numeric, in ArgDelimFlag numeric, in ArgInStr stream, out ArgOutStr stream ) global

CMS encrypt content and put it base64 encoded into a stream

ArgCertFilNam Filename of certificate file in PEM / DER format, a relative filename is resolved relative to the ini partition.
ArgCipherId Cipher function id, specify 0 for default DES_EDE3_CBC.
ArgDelimFlag Flag to specify the line delimiter to be used (=0 for 0x0d 0x0a (recommended), =1 for 0x0a ).
ArgInStr Inputstream with text content to encrypt.
ArgOutStr Outputstream loaded with the base64 encoded encryped content.

Corresponding functions: TDCMSSign, TDCMSDecrypt, TDCMSVerify


sub TDCMSSign( in ArgCertFilNam text, in ArgPKeyFilNam text, in ArgPassphrase text, in ArgMDId numeric, in ArgNoCert numeric, in ArgNoDetach numeric, in ArgDelimFlag numeric, in ArgInStr stream, out ArgOutStr stream ) global

create CMS signature from text and put it base64 encoded into a stream

ArgCertFilNam Filename of certificate file in PEM format (not used if pkey is read from P12), a relative filename is resolved relative to the ini partition.
ArgPKeyFilNam Filename of private key file in PEM / P12 format, a relative filename is resolved relative to the ini partition.
ArgPassphrase Passphrase for the private key / certificate file.
ArgMDId MD function id, specify 0 for default SHA1.
ArgNoCert Flag to specify if cert should be omitted from in the signature (=1) or not (=0).
ArgNoDetach Flag to specify if content should be enveloped in the signature (=1) or not (=0).
ArgDelimFlag Flag to specify the line delimiter to be used (=0 for 0x0d 0x0a (recommended), =1 for 0x0a ).
ArgInStr Inputstream with text content to sign.
ArgOutStr Outputstream loaded with the base64 encoded signature / enveloped data.

Corresponding functions: TDCMSEncrypt, TDCMSDecrypt, TDCMSVerify


sub TDCMSVerify( in ArgCertFilNam text, in ArgCAFilNams text, in ArgDelimFlag numeric, in ArgInDataStr stream, in ArgInStr stream, in ArgMaxOutStrLen numeric, out ArgOutStr stream, out ArgMsgDigest text, out ArgSignature text, out ArgInfo text ) global

CMS verify content/signature and put data into a stream if not detached

ArgCertFilNam Filename of certificate file in PEM / DER format, a relative filename is resolved relative to the ini partition (optional).
ArgCAFilNam Filenames of CA certificate files, a relative filenames are resolved relative to the ini partition (optional).
ArgDelimFlag Flag to specify the line delimiter to be used (=0 for 0x0d 0x0a (recommended), =1 for 0x0a ).
ArgInDataStr Inputstream with original text content if detached.
ArgInStr Inputstream with base64 encoded signature / enveloped data.
ArgMaxOutStrLen Maximum size of output (cannot be guessed).
ArgOutStr Outputstream loaded with text content if not detached.
ArgMsgDigest Output is base64 encoded message digest. *NOT SUPPORTED FOR CMS*
ArgSignatur Output is base64 encoded signature.
ArgInfo Output is xml structure containing additional information, currently serial of signer cert.

Corresponding functions: TDSign, TDEncrypt, TDDecrypt


sub TDDecrypt( in ArgCertFilNam text, in ArgPKeyFilNam text, in ArgPassphrase text, in ArgInStr stream, out ArgOutStr stream ) global

PKCS7 decrypt base64 encoded content to text and put it into a stream

ArgCertFilNam Filename of certificate file in PEM format (not used if pkey is read from P12), a relative filename is resolved relative to the ini partition.
ArgPKeyFilNam Filename of private key file in PEM / P12 format, a relative filename is resolved relative to the ini partition.
ArgPassphrase Passphrase for the private key / certificate file.
ArgInStr Inputstream with base64 encoded content to decrypt.
ArgOutStr Outputstream loaded with decrypted text content.

Corresponding functions: TDSign, TDEncrypt, TDVerify


sub TDDeflateText( in ArgGZHeader numeric, in ArgInLevel numeric, in ArgInStr stream, out ArgOutStr stream ) global

Deflate text - result is Base64-encoded

ArgGZHeader use gzip header
ArgInLevel compresson level to use (Z_NO_COMPRESSION = 0, Z_BEST_SPEED = 1, Z_BEST_COMPRESSION = 9, Z_DEFAULT_COMPRESSION = -1).
ArgInStr text to deflate as stream.
ArgOutStr Base64-encoded inflated text as stream.

Corresponding functions: TDInflateText


sub TDDERToPEM( in ArgDERFilNam text, in ArgCertFilNam text ) global

convert binary Cert to PEM

ArgDERFilNam Filename of the DER certificate file, a relative filename is resolved relative to the ini partition.
ArgCertFilNam Filename of certificate file, a relative filename is resolved relative to the ini partition.

Corresponding functions: TDP12toPEM, TDPEMToDER


sub TDEncrypt( in ArgCertFilNam text, in ArgCipherId numeric, in ArgDelimFlag numeric, in ArgInStr stream, out ArgOutStr stream ) global

PKCS7 encrypt content and put it base64 encoded into a stream

ArgCertFilNam Filename of certificate file in PEM / DER format, a relative filename is resolved relative to the ini partition.
ArgCipherId Cipher function id, specify 0 for default DES_EDE3_CBC.
ArgDelimFlag Flag to specify the line delimiter to be used (=0 for 0x0d 0x0a (recommended), =1 for 0x0a ).
ArgInStr Inputstream with text content to encrypt.
ArgOutStr Outputstream loaded with the base64 encoded encryped content.

Corresponding functions: TDSign, TDDecrypt, TDVerify


sub TDGunzip( in ArgFilNamIn text, in ArgFilNamOut text ) global

gunzip file

ArgFilNamIn Filename of file to read, a relative filename is resolved relative to the data partition.
ArgFilNamOut Filename of file to write, a relative filename is resolved relative to the data partition.

Corresponding functions: TDGzip


sub TDGzip( in ArgLevel numeric, in ArgFilNamIn text, in ArgFilNamOut text ) global

gzip file

ArgLevel compresson level to use (Z_NO_COMPRESSION = 0, Z_BEST_SPEED = 1, Z_BEST_COMPRESSION = 9, Z_DEFAULT_COMPRESSION = -1).
ArgFilNamIn Filename of file to read, a relative filename is resolved relative to the data partition.
ArgFilNamOut Filename of file to write, a relative filename is resolved relative to the data partition.

Corresponding functions: TDGunzip


sub TDHexDecode( in ArgFilNam text, in ArgInStr stream ) global

decode hex encoded stream and write result into file

ArgFilNam Filename of file to write, a relative filename is resolved relative to the data partition.
ArgInStr inputstream with hex encoded contents to process.

Corresponding functions: TDHexEncode


sub TDHexEncode( in ArgFilNam text, out ArgOutStr stream ) global

read file and put contents hex encoded into a stream

ArgFilNam Filename of file to read, a relative filename is resolved relative to the data partition.
ArgOutStr outputstream loaded with the hex encoded contents of the file after processing it.

Corresponding functions: TDHexDecode


sub TDInflateText( in ArgGZHeader numeric, in ArgInStr stream, out ArgOutStr stream ) global

Inflate text

ArgGZHeader use gzip header
ArgInStm Base64-encoded text to inflate as stream.
ArgOutStm inflated text as stream.

Corresponding functions: TDDeflateText


sub TDLineBreak( in ArgFilNam text, in ArgLinLen numeric, in ArgRplChr text, out ArgOutStr stream ) global

read file without linebreaks breaking lines to passed linelen and replacing zero-bytes into a stream

ArgFilNam Filename of file to read, a relative filename is resolved relative to the data partition.
ArgLinLen linelength of the lines.
ArgRplChr optional character to be used to replace included hex-00 characters. If an empty string is used the default character `?` will be used (recommended).
ArgOutStr outputstream loaded with the contents of the file after processing it.

The intended use of this routine is to load sequential files with records of fixed length into a TradeDesign stream with every record beeing a line in the resulting stream.
Fields of these records with packed numbers are left in the data compatible to the unpacking routines.

Corresponding functions: TDUnpackComp3, TDUnpackUnsigned


sub TDP12ToPEM( in ArgP12FilNam text, in ArgP12Passphrase text, in ArgCertFilNam text, in ArgPKeyFilNam text, in ArgCipherId numeric, in ArgPassphrase text ) global

convert p12 PKey/Cert to PEM

ArgP12FilNam Filename of the P12 file, a relative filename is resolved relative to the ini partition.
ArgP12Passphrase Passphrase for the P12 file.
ArgCertFilNam Filename of certificate file, a relative filename is resolved relative to the ini partition.
ArgPKeyFilNam Filename of the private key file,, a relative filename is resolved relative to the ini partition.
ArgCipherId Cipher function id, specify 0 for default DES_EDE3_CBC.
ArgPassphrase Passphrase for the private key / certificate file.

Corresponding functions: TDPEMToP12, TDDERToPEM, TDPEMToDER


sub TDPackComp3( in value numeric, in flagunsigned numeric, out packedhexstr text ) global

convert integer to hex-encoded cobol comp3.

Corresponding functions: TDLineBreak, TDUnpackComp3, TDUnpackUnsigned


sub TDPEMToDER( in ArgCertFilNam text, in ArgDERFilNam text ) global

convert PEM to binary Cert

ArgCertFilNam Filename of certificate file, a relative filename is resolved relative to the ini partition.
ArgDERFilNam Filename of the DER certificate file, a relative filename is resolved relative to the ini partition.

Corresponding functions: TDP12toPEM, TDDERToPEM


sub TDPEMToP12( in ArgCertFilNam text, in ArgPKeyFilNam text, in ArgPassphrase text, in ArgCAFilNam text, in ArgP12FilNam text, in ArgP12Passphrase text, in ArgP12Name text ) global

convert PEM PKey/Cert to P12

ArgCertFilNam Filename of certificate file, a relative filename is resolved relative to the ini partition.
ArgPKeyFilNam Filename of the private key file,, a relative filename is resolved relative to the ini partition.
ArgPassphrase Passphrase for the private key / certificate file.
ArgCAFilNam Filename of CA file, a relative filename is resolved relative to the ini partition.
ArgP12FilNam Filename of the P12 file, a relative filename is resolved relative to the ini partition.
ArgP12Passphrase Passphrase for the P12 file.
ArgP!2Name Display name for the P12 file.

Corresponding functions: TDP12ToPEM, TDDERToPEM, TDPEMToDER


sub TDQPDecode( in ArgFilNam text, in ArgInStr stream ) global

decode quoted-printable encoded stream and write result into file

ArgFilNam Filename of file to write, a relative filename is resolved relative to the data partition.
ArgInStr inputstream with quoted-printable encoded contents to process.

Corresponding functions: TDQPEncode


sub TDQPEncode( in ArgFilNam text, out ArgOutStr stream ) global

read file and put contents quoted-printable encoded into a stream

ArgFilNam Filename of file to read, a relative filename is resolved relative to the data partition.
ArgOutStr outputstream loaded with the quoted-printable encoded contents of the file after processing it.

Corresponding functions: TDQPDecode


sub TDSign( in ArgCertFilNam text, in ArgPKeyFilNam text, in ArgPassphrase text, in ArgMDId numeric, in ArgNoCert numeric, in ArgNoDetach numeric, in ArgDelimFlag numeric, in ArgInStr stream, out ArgOutStr stream ) global

create PKCS7 signature from text and put it base64 encoded into a stream

ArgCertFilNam Filename of certificate file in PEM format (not used if pkey is read from P12), a relative filename is resolved relative to the ini partition.
ArgPKeyFilNam Filename of private key file in PEM / P12 format, a relative filename is resolved relative to the ini partition.
ArgPassphrase Passphrase for the private key / certificate file.
ArgMDId MD function id, specify 0 for default SHA1.
ArgNoCert Flag to specify if cert should be omitted from in the signature (=1) or not (=0).
ArgNoDetach Flag to specify if content should be enveloped in the signature (=1) or not (=0).
ArgDelimFlag Flag to specify the line delimiter to be used (=0 for 0x0d 0x0a (recommended), =1 for 0x0a ).
ArgInStr Inputstream with text content to sign.
ArgOutStr Outputstream loaded with the base64 encoded signature / enveloped data.

Corresponding functions: TDEncrypt, TDDecrypt, TDVerify


sub TDSignBuf( in ArgCertFilNam text, in ArgPKeyFilNam text, in ArgPassphrase text, in ArgMDId numeric, in ArgNoCert numeric, in ArgNoDetach numeric, in ArgInStr text, out ArgOutStr text ) global

create signature from text and put it base64 encoded into a block

ArgCertFilNam Filename of certificate file in PEM format (not used if pkey is read from P12), a relative filename is resolved relative to the ini partition.
ArgPKeyFilNam Filename of private key file in PEM / P12 format, a relative filename is resolved relative to the ini partition.
ArgPassphrase Passphrase for the private key / certificate file.
ArgMDId MD function id, specify 0 for default SHA1.
ArgNoCert Flag to specify if cert should be omitted from in the signature (=1) or not (=0).
ArgNoDetach Flag to specify if content should be enveloped in the signature (=1) or not (=0).
ArgInStr Input with text content to sign.
ArgOutStr Output set to the base64 encoded signature / enveloped data.

Corresponding functions: TDEncrypt, TDDecrypt, TDVerify


sub TDUnpackComp3( in packedstr text, out value numeric ) global

convert cobol comp3 to integer. The data to be unpacked is assumed to be
taken from a stream loaded with the TDLineBreak routine.

Corresponding functions: TDLineBreak, TDUnpackUnsigned, TDPackComp3


sub TDUnpackUnsigned( in packedstr text, out value numeric ) global

convert unsigned packed to integer. The data to be unpacked is assumed to be
taken from a stream loaded with the TDLineBreak routine.

Corresponding functions: TDUnpackComp3, TDLineBreak, TDPackComp3


sub TDVerify( in ArgCertFilNam text, in ArgCAFilNams text, in ArgDelimFlag numeric, in ArgInDataStr stream, in ArgInStr stream, in ArgMaxOutStrLen numeric, out ArgOutStr stream, out ArgMsgDigest text, out ArgSignature text, out ArgInfo text ) global

PKCS7 verify content/signature and put data into a stream if not detached

ArgCertFilNam Filename of certificate file in PEM / DER format, a relative filename is resolved relative to the ini partition (optional).
ArgCAFilNam Filenames of CA certificate files, a relative filenames are resolved relative to the ini partition (optional).
ArgDelimFlag Flag to specify the line delimiter to be used (=0 for 0x0d 0x0a (recommended), =1 for 0x0a ).
ArgInDataStr Inputstream with original text content if detached.
ArgInStr Inputstream with base64 encoded signature / enveloped data.
ArgMaxOutStrLen Maximum size of output (cannot be guessed).
ArgOutStr Outputstream loaded with text content if not detached.
ArgMsgDigest Output is base64 encoded message digest.
ArgSignatur Output is base64 encoded signature.
ArgInfo Output is xml structure containing additional information, currently serial of signer cert.

Corresponding functions: TDSign, TDEncrypt, TDDecrypt


sub TDCMSEncryptV2( in ArgCertFilNam text, in ArgCipher text, in ArgDelimFlag numeric, in ArgInStr stream, out ArgOutStr stream ) global

CMS encrypt content and put it base64 encoded into a stream

ArgCertFilNam Filename of certificate file in PEM / DER format, a relative filename is resolved relative to the ini partition.
ArgCipherId Cipher function id, specify 0 for default DES_EDE3_CBC.
ArgDelimFlag Flag to specify the line delimiter to be used (=0 for 0x0d 0x0a (recommended), =1 for 0x0a ).
ArgInStr Inputstream with text content to encrypt.
ArgOutStr Outputstream loaded with the base64 encoded encryped content.

Corresponding functions: TDCMSSign, TDCMSDecrypt, TDCMSVerify


sub TDCMSSignV2( in ArgCertFilNam text, in ArgPKeyFilNam text, in ArgPassphrase text, in ArgMD text, in ArgNoCert numeric, in ArgNoDetach numeric, in ArgDelimFlag numeric, in ArgInStr stream, out ArgOutStr stream ) global

create CMS signature from text and put it base64 encoded into a stream

ArgCertFilNam Filename of certificate file in PEM format (not used if pkey is read from P12), a relative filename is resolved relative to the ini partition.
ArgPKeyFilNam Filename of private key file in PEM / P12 format, a relative filename is resolved relative to the ini partition.
ArgPassphrase Passphrase for the private key / certificate file.
ArgMDId MD function id, specify 0 for default SHA1.
ArgNoCert Flag to specify if cert should be omitted from in the signature (=1) or not (=0).
ArgNoDetach Flag to specify if content should be enveloped in the signature (=1) or not (=0).
ArgDelimFlag Flag to specify the line delimiter to be used (=0 for 0x0d 0x0a (recommended), =1 for 0x0a ).
ArgInStr Inputstream with text content to sign.
ArgOutStr Outputstream loaded with the base64 encoded signature / enveloped data.

Corresponding functions: TDCMSEncrypt, TDCMSDecrypt, TDCMSVerify


sub TDDecryptByKey( in ArgCipherName text, in ArgKey text, in ArgIV text, in ArgInStr stream, out ArgOutStr stream ) global

Decrypt base64 encoded content to text and put it into a stream

ArgCipherName Cipher to be used, e.g. 'aes-256-cbc'
ArgKey Encryption Key
ArgIV Encryption IV
ArgInStr Inputstream with text content to encrypt.
ArgOutStr Outputstream loaded with the base64 encoded encryped content.

Corresponding functions: TDEncryptByKey


sub TDEncryptByKey( in ArgCipherName text, in ArgDelimFlag numeric, in ArgKey text, in ArgIV text, in ArgDoLBreak text, in ArgInStr stream, out ArgOutStr stream ) global

Encrypt content and put it base64 encoded into a stream

ArgCipherName Cipher to be used, e.g. 'aes-256-cbc'
ArgDelimFlag Flag to specify the line delimiter to be used (=0 for 0x0d 0x0a (recommended), =1 for 0x0a ).
ArgKey Encryption Key
ArgIV Encryption IV
ArgDoLBreak Add Lline breaks to base64 encoded output?
ArgInStr Inputstream with text content to encrypt.
ArgOutStr Outputstream loaded with the base64 encoded encryped content.

Corresponding functions: TDDecryptByKey


sub TDEncryptV2( in ArgCertFilNam text, in ArgCipher text, in ArgDelimFlag numeric, in ArgInStr stream, out ArgOutStr stream ) global

PKCS7 encrypt content and put it base64 encoded into a stream

ArgCertFilNam Filename of certificate file in PEM / DER format, a relative filename is resolved relative to the ini partition.
ArgCipher Cipher
ArgDelimFlag Flag to specify the line delimiter to be used (=0 for 0x0d 0x0a (recommended), =1 for 0x0a ).
ArgInStr Inputstream with text content to encrypt.
ArgOutStr Outputstream loaded with the base64 encoded encryped content.

Corresponding functions: TDSign, TDDecrypt, TDVerify


sub TDP12ToPEMV2( in ArgP12FilNam text, in ArgP12Passphrase text, in ArgCertFilNam text, in ArgPKeyFilNam text, in ArgCipher text, in ArgPassphrase text ) global

convert p12 PKey/Cert to PEM

ArgP12FilNam Filename of the P12 file, a relative filename is resolved relative to the ini partition.
ArgP12Passphrase Passphrase for the P12 file.
ArgCertFilNam Filename of certificate file, a relative filename is resolved relative to the ini partition.
ArgPKeyFilNam Filename of the private key file,, a relative filename is resolved relative to the ini partition.
ArgCipher Cipher function
ArgPassphrase Passphrase for the private key / certificate file.

Corresponding functions: TDPEMToP12, TDDERToPEM, TDPEMToDER


sub TDSignBufV2( in ArgCertFilNam text, in ArgPKeyFilNam text, in ArgPassphrase text, in ArgMD text, in ArgNoCert numeric, in ArgNoDetach numeric, in ArgInStr text, out ArgOutStr text ) global

create signature from text and put it base64 encoded into a block

ArgCertFilNam Filename of certificate file in PEM format (not used if pkey is read from P12), a relative filename is resolved relative to the ini partition.
ArgPKeyFilNam Filename of private key file in PEM / P12 format, a relative filename is resolved relative to the ini partition.
ArgPassphrase Passphrase for the private key / certificate file.
ArgMD MD function
ArgNoCert Flag to specify if cert should be omitted from in the signature (=1) or not (=0).
ArgNoDetach Flag to specify if content should be enveloped in the signature (=1) or not (=0).
ArgInStr Input with text content to sign.
ArgOutStr Output set to the base64 encoded signature / enveloped data.

Corresponding functions: TDEncrypt, TDDecrypt, TDVerify


sub TDSignV2( in ArgCertFilNam text, in ArgPKeyFilNam text, in ArgPassphrase text, in ArgMD text, in ArgNoCert numeric, in ArgNoDetach numeric, in ArgDelimFlag numeric, in ArgInStr stream, out ArgOutStr stream ) global

create PKCS7 signature from text and put it base64 encoded into a stream

ArgCertFilNam Filename of certificate file in PEM format (not used if pkey is read from P12), a relative filename is resolved relative to the ini partition.
ArgPKeyFilNam Filename of private key file in PEM / P12 format, a relative filename is resolved relative to the ini partition.
ArgPassphrase Passphrase for the private key / certificate file.
ArgMD MD function
ArgNoCert Flag to specify if cert should be omitted from in the signature (=1) or not (=0).
ArgNoDetach Flag to specify if content should be enveloped in the signature (=1) or not (=0).
ArgDelimFlag Flag to specify the line delimiter to be used (=0 for 0x0d 0x0a (recommended), =1 for 0x0a ).
ArgInStr Inputstream with text content to sign.
ArgOutStr Outputstream loaded with the base64 encoded signature / enveloped data.

Corresponding functions: TDEncrypt, TDDecrypt, TDVerify


function TDCalcHashAny( in ArgMethod text, in ArgInputFormat text, in ArgInStr text, in ArgOutputFormat text ) : text global

Calc hash value using specified method

ArgMethod digest algorithm.
ArgInputFormat 'B', 'B64', 'Base64' = Base64 -and- 'H', 'HEX': HEX -and- 'P', 'T', 'S' = Plain Text
ArgInStr text to calc hash from.
ArgOutputFormat 'B', 'B64', 'Base64' = Base64 -and- 'H', 'HEX': HEX

Corresponding functions: TDCalcHash, TDCalcHMACString, TDCalcHMAC, TDCalcHMACNString, TDCalcHMACN


function TDCalcHMACAny( in ArgMethod text, in ArgInputFormat text, in ArgInStr text, in ArgKeyStr text, in ArgOutputFormat text ) : text global

Calc hash value using specified method

ArgMethod digest algorithm.
ArgInputFormat 'B', 'B64', 'Base64' = Base64 -and- 'H', 'HEX': HEX -and- 'P', 'T', 'S' = Plain Text
ArgInStr text to calc HMAC from.
ArgKeyStr key for HMAC calculation.
ArgOutputFormat 'B', 'B64', 'Base64' = Base64 -and- 'H', 'HEX': HEX

Corresponding functions: TDCalcHashString, TDCalcHash, TDCalcHMAC, TDCalcHMACNString, TDCalcHMACN


function TDCalcHMACNAny( in ArgMethod text, in ArgInputFormat text, in ArgInStr text, in ArgKeyStr text, in ArgMaxLen numeric, in ArgOutputFormat text ) : text global

Calc hash value using specified method

ArgMethod digest algorithm.
ArgInputFormat 'B', 'B64', 'Base64' = Base64 -and- 'H', 'HEX': HEX -and- 'P', 'T', 'S' = Plain Text
ArgInStr text to calc HMAC from.
ArgKeyStr key for HMAC calculation.
ArgMaxLen maximum number bytes used from HMAC
ArgOutputFormat 'B', 'B64', 'Base64' = Base64 -and- 'H', 'HEX': HEX

Corresponding functions: TDCalcHashString, TDCalcHash, TDCalcHMAC, TDCalcHMACNString, TDCalcHMACN, TDCalcHashStringEnc, TDCalcHashEnc, TDCalcHMACEnc, TDCalcHMACNStringEnc, TDCalcHMACNEnc


sub TDRSADecrypt( in ArgPrivKeyFilNam text, in ArgPassphrase text, in ArgDelimFlag numeric, in ArgInputFormat text, in ArgInStr stream, in ArgOutputFormat text, out ArgOutStr stream ) global

RSA decrypt content and put it as specified by outputformat into a stream

ArgPrivKeyFilNam Filename of RSA private key file in PEM format, a relative filename is resolved relative to the ini partition.
ArgPassphrase Passphrase for the private key / certificate file.
ArgDelimFlag Flag to specify the line delimiter to be used (=0 for 0x0d 0x0a (recommended), =1 for 0x0a ).
ArgInputFormat 'B', 'B64', 'Base64' = Base64 -and- 'H', 'HEX': HEX -and- 'P', 'T', 'S' = Plain Text
ArgInStr Inputstream with text content to encrypt.
ArgOutputFormat 'B', 'B64', 'Base64' = Base64 -and- 'H', 'HEX': HEX
ArgOutStr Outputstream loaded with the base64 encoded encryped content.

Corresponding functions: TDRSASign, TDRSAEncrypt, TDRSAVerify


sub TDRSAEncrypt( in ArgPubKeyFilNam text, in ArgPassphrase text, in ArgDelimFlag numeric, in ArgInputFormat text, in ArgInStr stream, in ArgOutputFormat text, out ArgOutStr stream ) global

RSA encrypt content and put it base64 encoded into a stream

ArgPubKeyFilNam Filename of RSA public key file in PEM format, a relative filename is resolved relative to the ini partition.
ArgPassphrase Passphrase for the private key / certificate file.
ArgDelimFlag Flag to specify the line delimiter to be used (=0 for 0x0d 0x0a (recommended), =1 for 0x0a ).
ArgInputFormat 'B', 'B64', 'Base64' = Base64 -and- 'H', 'HEX': HEX -and- 'P', 'T', 'S' = Plain Text
ArgInStr Inputstream with text content to encrypt.
ArgOutputFormat 'B', 'B64', 'Base64' = Base64 -and- 'H', 'HEX': HEX
ArgOutStr Outputstream loaded with the base64 encoded encryped content.

Corresponding functions: TDRSASign, TDRSADecrypt, TDRSAVerify


sub TDRSASign( in ArgPrivKeyFilNam text, in ArgPassphrase text, in ArgMD text, in ArgDelimFlag numeric, in ArgInputFormat text, in ArgInStr stream, in ArgOutputFormat text, out ArgOutStr stream ) global

create RSA signature from text and put it base64 encoded into a stream

ArgPrivKeyFilNam Filename of RSA private key file in PEM , a relative filename is resolved relative to the ini partition.
ArgPassphrase Passphrase for the RSA private key file.
ArgMD MD name
ArgDelimFlag Flag to specify the line delimiter to be used (=0 for 0x0d 0x0a (recommended), =1 for 0x0a ).
ArgInputFormat 'B', 'B64', 'Base64' = Base64 -and- 'H', 'HEX': HEX -and- 'P', 'T', 'S' = Plain Text
ArgInStr Inputstream with text content to sign.
ArgOutputFormat 'B', 'B64', 'Base64' = Base64 -and- 'H', 'HEX': HEX
ArgOutStr Outputstream loaded with the base64 encoded signature / enveloped data.

Corresponding functions: TDRSAEncrypt, TDRSADecrypt, TDRSAVerify


sub TDRSAVerify( in ArgPubKeyFilNam text, in ArgPassphrase text, in ArgMD text, in ArgDelimFlag numeric, in ArgInputFormat text, in ArgInStr stream, in ArgMsgFormat text, in ArgMsgStr stream ) global

create RSA signature from text and put it base64 encoded into a stream

ArgPubKeyFilNam Filename of RSA public key file in PEM , a relative filename is resolved relative to the ini partition.
ArgPassphrase Passphrase for the RSA public key file.
ArgMD MD name
ArgDelimFlag Flag to specify the line delimiter to be used (=0 for 0x0d 0x0a (recommended), =1 for 0x0a ).
ArgInputFormat 'B', 'B64', 'Base64' = Base64 -and- 'H', 'HEX': HEX
ArgInStr Inputstream with signature
ArgMsgFormat 'B', 'B64', 'Base64' = Base64 -and- 'H', 'HEX': HEX -and- 'P', 'T', 'S' = Plain Text
ArgMsgStr Signaturestream loaded with the ArgSigFormat encoded signature

Corresponding functions: TDRSAEncrypt, TDRSADecrypt, TDRSAVerify