Sc14n Namespace

Performs the C14N transformation of a straightforward XML document.

The following C14N transformations are supported:

“inclusive canonicalization” from Canonical XML Version 1.0 (reproduced as RFC 3076) with identifiers http://www.w3.org/TR/2001/REC-xml-c14n-20010315``http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments

“exclusive canonicalization” from Exclusive XML Canonical Version 1.0 (reproduced as RFC 3741) with identifiers http://www.w3.org/2001/10/xml-exc-c14n#``http://www.w3.org/2001/10/xml-exc-c14n#WithComments

Input is expected to be a well-formed XML document. Supported XML encodings are UTF-8, ISO-8859-1 and US-ASCII.

Classes

Class Description
C14n Performs C14N transformation of XML document.
Err Details of errors returned by the core library.
Gen General info about the core library DLL.

Enumerations

Enumeration Description
AdvOptions Advanced option flags
DigAlg Digest Algorithm
Tran Transformation options to specify the document part to be canonicalized.
TranMethod Transformation methods

C14n Class

Performs C14N transformation of XML document.

Inheritance Hierarchy

System.Object
Sc14n.C14n

Namespace: Sc14n
Assembly: diSc14nNet (in diSc14nNet.dll) Version: 3.1.0.28355 (3.1.0.0)

Syntax

public class C14n

The C14n type exposes the following members.

Methods

Name Description
ToBytes(Byte[], String, Tran, TranMethod, String, AdvOptions) Performs C14N transformation of XML document (memory-to-memory with options).
ToBytes(String, String, Tran, TranMethod, String, AdvOptions) Performs C14N transformation of XML document.
ToDigest(Byte[], DigAlg) Computes digest value of inclusive C14N transformation of entire XML document (memory-to-digest).
ToDigest(String, DigAlg) Computes digest value of inclusive C14N transformation of entire XML document (file-to-digest).
ToDigest(Byte[], String, Tran, DigAlg, TranMethod, String, AdvOptions) Computes digest value of C14N transformation of XML document (memory-to-digest).
ToDigest(String, String, Tran, DigAlg, TranMethod, String, AdvOptions) Computes digest value of C14N transformation of XML document (file-to-digest).
ToFile Performs C14N transformation of XML document (file-to-file).

See Also

Sc14n Namespace

C14n.ToBytes(Byte[], String, Tran, TranMethod, String, AdvOptions) Method

Performs C14N transformation of XML document (memory-to-memory with options).

Namespace: Sc14n
Assembly: diSc14nNet (in diSc14nNet.dll) Version: 3.1.0.28355 (3.1.0.0)

Overloads

Name Description
ToBytes(Byte[], String, Tran, TranMethod, String, AdvOptions) Performs C14N transformation of XML document (memory-to-memory with options).
ToBytes(String, String, Tran, TranMethod, String, AdvOptions) Performs C14N transformation of XML document.

Syntax

public static byte[] ToBytes(
    byte[] xmlData,
    string nameOrId = "",
    Tran tranOpt = Tran.Entire,
    TranMethod tranMethod = TranMethod.Inclusive,
    string exclParams = "",
    AdvOptions advOpts = AdvOptions.Default
)

Parameters

xmlData Byte[]

XML data to be processed.

nameOrId String (Optional)

Tag name or Id to include or omit [optional, default=""]. See remarks for C14n.ToFile.

tranOpt Tran (Optional)

Transformation option [optional, default=Tran.Entire].

tranMethod TranMethod (Optional)

Transformation method [optional, default=TranMethod.Inclusive].

exclParams String (Optional)

InclusiveNamespaces PrefixList parameter for exclusive c14n [optional, default=""].

advOpts AdvOptions (Optional)

Option flags [optional, default=0].

Return Value

Byte[]
UTF-8 encoded byte array

See Also

C14n Class
Sc14n Namespace

C14n.ToBytes(String, String, Tran, TranMethod, String, AdvOptions) Method

Performs C14N transformation of XML document.

Namespace: Sc14n
Assembly: diSc14nNet (in diSc14nNet.dll) Version: 3.1.0.28355 (3.1.0.0)

Overloads

Name Description
ToBytes(Byte[], String, Tran, TranMethod, String, AdvOptions) Performs C14N transformation of XML document (memory-to-memory with options).
ToBytes(String, String, Tran, TranMethod, String, AdvOptions) Performs C14N transformation of XML document.

Syntax

public static byte[] ToBytes(
    string xmlFile,
    string nameOrId = "",
    Tran tranOpt = Tran.Entire,
    TranMethod tranMethod = TranMethod.Inclusive,
    string exclParams = "",
    AdvOptions advOpts = AdvOptions.Default
)

Parameters

xmlFile String

Name of input XML file.

nameOrId String (Optional)

Tag name or Id to include or omit [optional, default=""]. See remarks for C14n.ToFile.

tranOpt Tran (Optional)

Transformation option [optional, default=Tran.Entire].

tranMethod TranMethod (Optional)

Transformation method [optional, default=TranMethod.Inclusive].

exclParams String (Optional)

InclusiveNamespaces PrefixList parameter for exclusive c14n [optional, default=""].

advOpts AdvOptions (Optional)

Option flags [optional, default=0].

Return Value

Byte[]
UTF-8 encoded byte array

See Also

C14n Class
Sc14n Namespace

C14n.ToDigest(Byte[], DigAlg) Method

Computes digest value of inclusive C14N transformation of entire XML document (memory-to-digest).

Namespace: Sc14n
Assembly: diSc14nNet (in diSc14nNet.dll) Version: 3.1.0.28355 (3.1.0.0)

Overloads

Name Description
ToDigest(Byte[], DigAlg) Computes digest value of inclusive C14N transformation of entire XML document (memory-to-digest).
ToDigest(String, DigAlg) Computes digest value of inclusive C14N transformation of entire XML document (file-to-digest).
ToDigest(Byte[], String, Tran, DigAlg, TranMethod, String, AdvOptions) Computes digest value of C14N transformation of XML document (memory-to-digest).
ToDigest(String, String, Tran, DigAlg, TranMethod, String, AdvOptions) Computes digest value of C14N transformation of XML document (file-to-digest).

Syntax

public static string ToDigest(
    byte[] xmlData,
    DigAlg digAlg
)

Parameters

xmlData Byte[]

XML data to be processed

digAlg DigAlg

Digest algorithm

Return Value

String
Digest value in base64 encoding or empty string on error (for more details use Err.LastError).

See Also

C14n Class
Sc14n Namespace

Err.LastError Method

Retrieves the last error message (if available).

Namespace: Sc14n
Assembly: diSc14nNet (in diSc14nNet.dll) Version: 3.1.0.28355 (3.1.0.0)

Syntax

public static string LastError()

Return Value

String
Error message from last call (may be empty)

Remarks

Call this immediately when an error is indicated. Calling another method will overwrite the message.

See Also

Err Class
Sc14n Namespace

C14n.ToDigest(String, DigAlg) Method

Computes digest value of inclusive C14N transformation of entire XML document (file-to-digest).

Namespace: Sc14n
Assembly: diSc14nNet (in diSc14nNet.dll) Version: 3.1.0.28355 (3.1.0.0)

Overloads

Name Description
ToDigest(Byte[], DigAlg) Computes digest value of inclusive C14N transformation of entire XML document (memory-to-digest).
ToDigest(String, DigAlg) Computes digest value of inclusive C14N transformation of entire XML document (file-to-digest).
ToDigest(Byte[], String, Tran, DigAlg, TranMethod, String, AdvOptions) Computes digest value of C14N transformation of XML document (memory-to-digest).
ToDigest(String, String, Tran, DigAlg, TranMethod, String, AdvOptions) Computes digest value of C14N transformation of XML document (file-to-digest).

Syntax

public static string ToDigest(
    string xmlFile,
    DigAlg digAlg
)

Parameters

xmlFile String

Name of input XML file.

digAlg DigAlg

Digest algorithm

Return Value

String
Digest value in base64 encoding or empty string on error (for more details use Err.LastError).

See Also

C14n Class
Sc14n Namespace

C14n.ToDigest(Byte[], String, Tran, DigAlg, TranMethod, String, AdvOptions) Method

Computes digest value of C14N transformation of XML document (memory-to-digest).

Namespace: Sc14n
Assembly: diSc14nNet (in diSc14nNet.dll) Version: 3.1.0.28355 (3.1.0.0)

Overloads

Name Description
ToDigest(Byte[], DigAlg) Computes digest value of inclusive C14N transformation of entire XML document (memory-to-digest).
ToDigest(String, DigAlg) Computes digest value of inclusive C14N transformation of entire XML document (file-to-digest).
ToDigest(Byte[], String, Tran, DigAlg, TranMethod, String, AdvOptions) Computes digest value of C14N transformation of XML document (memory-to-digest).
ToDigest(String, String, Tran, DigAlg, TranMethod, String, AdvOptions) Computes digest value of C14N transformation of XML document (file-to-digest).

Syntax

public static string ToDigest(
    byte[] xmlData,
    string nameOrId = "",
    Tran tranOpt = Tran.Entire,
    DigAlg digAlg = DigAlg.Default,
    TranMethod tranMethod = TranMethod.Inclusive,
    string exclParams = "",
    AdvOptions advOpts = AdvOptions.Default
)

Parameters

xmlData Byte[]

XML data to be processed

nameOrId String (Optional)

Tag name or Id to include or omit [optional, default=""]. See remarks for C14n.ToFile.

tranOpt Tran (Optional)

Transformation option [optional, default=Tran.Entire].

digAlg DigAlg (Optional)

Digest algorithm [optional, default=DigAlg.Default SHA-1]

tranMethod TranMethod (Optional)

Transformation method [optional, default=TranMethod.Inclusive].

exclParams String (Optional)

InclusiveNamespaces PrefixList parameter for exclusive c14n [optional, default=""].

advOpts AdvOptions (Optional)

Option flags [optional, default=0].

Return Value

String
Digest value in base64 encoding or empty string on error (for more details use Err.LastError).

See Also

C14n Class
Sc14n Namespace

C14n.ToDigest(String, String, Tran, DigAlg, TranMethod, String, AdvOptions) Method

Computes digest value of C14N transformation of XML document (file-to-digest).

Namespace: Sc14n
Assembly: diSc14nNet (in diSc14nNet.dll) Version: 3.1.0.28355 (3.1.0.0)

Overloads

Name Description
ToDigest(Byte[], DigAlg) Computes digest value of inclusive C14N transformation of entire XML document (memory-to-digest).
ToDigest(String, DigAlg) Computes digest value of inclusive C14N transformation of entire XML document (file-to-digest).
ToDigest(Byte[], String, Tran, DigAlg, TranMethod, String, AdvOptions) Computes digest value of C14N transformation of XML document (memory-to-digest).
ToDigest(String, String, Tran, DigAlg, TranMethod, String, AdvOptions) Computes digest value of C14N transformation of XML document (file-to-digest).

Syntax

public static string ToDigest(
    string xmlFile,
    string nameOrId = "",
    Tran tranOpt = Tran.Entire,
    DigAlg digAlg = DigAlg.Default,
    TranMethod tranMethod = TranMethod.Inclusive,
    string exclParams = "",
    AdvOptions advOpts = AdvOptions.Default
)

Parameters

xmlFile String

Name of input XML file.

nameOrId String (Optional)

Tag name or Id to include or omit [optional, default=""]. See remarks for C14n.ToFile.

tranOpt Tran (Optional)

Transformation option [optional, default=Tran.Entire].

digAlg DigAlg (Optional)

Digest algorithm [optional, default=DigAlg.Default SHA-1]

tranMethod TranMethod (Optional)

Transformation method [optional, default=TranMethod.Inclusive].

exclParams String (Optional)

InclusiveNamespaces PrefixList parameter for exclusive c14n [optional, default=""].

advOpts AdvOptions (Optional)

Option flags [optional, default=0].

Return Value

String
Digest value in base64 encoding or empty string on error (for more details use Err.LastError).

See Also

C14n Class
Sc14n Namespace

C14n.ToFile Method

Performs C14N transformation of XML document (file-to-file).

Namespace: Sc14n
Assembly: diSc14nNet (in diSc14nNet.dll) Version: 3.1.0.28355 (3.1.0.0)

Syntax

public static int ToFile(
    string outFile,
    string xmlFile,
    string nameOrId = "",
    Tran tranOpt = Tran.Entire,
    TranMethod tranMethod = TranMethod.Inclusive,
    string exclParams = "",
    AdvOptions advOpts = AdvOptions.Default
)

Parameters

outFile String

Name of output file to create.

xmlFile String

Name of input XML file.

nameOrId String (Optional)

Tag name or Id to include or omit [optional, default=""] (see remarks below).

tranOpt Tran (Optional)

Transformation option [optional, default=Tran.Entire].

tranMethod TranMethod (Optional)

Transformation method [optional, default=TranMethod.Inclusive].

exclParams String (Optional)

InclusiveNamespaces PrefixList parameter for exclusive c14n [optional, default=""].

advOpts AdvOptions (Optional)

Option flags [optional, default=0].

Return Value

Int32
0 if successful or non-zero error code.

Remarks

Use the nameOrId parameter to specify the element of the XML document to include or omit.

With options OmitByTag or SubsetByTag, nameOrId specifies the element’s tag name. By default, the first element with a matching tag name will be chosen.To specify the Nth element, write as tagname[N] where N=1,2,3,... With options OmitById or SubsetById, nameOrId specifies the element’s Id. The default Id attribute name is Id, so the argument myvalue will find the element with attribute Id="myvalue".To use a different attribute name - for example ID - write in the form ID=myvalue with no quotes. With option Entire, the parameter is ignored, so just use "" or null.

Exactly one element will be omitted or included. Tag names and Id values are case sensitive. It is an error (NO_DATA_ERROR) if no matching element is found.

Example

// Example 1. Omits the first element with the tag name <Signature>
r = C14n.ToFile("c14nfile1.txt", "input.xml", "Signature", Tran.OmitByTag);

// Example 2. Finds and transforms the first element with the tag name <SignedInfo>
r = C14n.ToFile("c14nfile2.txt", "input.xml", "SignedInfo", Tran.SubsetByTag);

// Example 3. Finds and transforms the third element with the tag name <Data>
r = C14n.ToFile("c14nfile3.txt", "input.xml", "Data[3]", Tran.SubsetByTag);

// Example 4. Finds and transforms the element with attribute Id="foo"
r = C14n.ToFile("c14nfile4.txt", "input.xml", "foo", Tran.SubsetById);

// Example 5. Finds and transforms the element with attribute ID="bar"
r = C14n.ToFile("c14nfile5.txt", "input.xml", "ID=bar", Tran.SubsetById);

// Example 6. Omits element with attribute Id="thesig"
r = C14n.ToFile("c14nfile6.txt", "input.xml", "thesig", Tran.OmitById);

See Also

C14n Class
Sc14n Namespace

Err.ErrorLookup Method

Looks up description for error code.

Namespace: Sc14n
Assembly: diSc14nNet (in diSc14nNet.dll) Version: 3.1.0.28355 (3.1.0.0)

Syntax

public static string ErrorLookup(
    int errCode
)

Parameters

errCode Int32

Value of error code to lookup (may be positive or negative)

Return Value

String
Corresponding error message

See Also

Err Class
Sc14n Namespace

Err Class

Details of errors returned by the core library.

Inheritance Hierarchy

System.Object
Sc14n.Err

Namespace: Sc14n
Assembly: diSc14nNet (in diSc14nNet.dll) Version: 3.1.0.28355 (3.1.0.0)

Syntax

public class Err

The Err type exposes the following members.

Methods

Name Description
ErrorLookup Looks up description for error code.
LastError Retrieves the last error message (if available).

See Also

Sc14n Namespace

Gen Class

General info about the core library DLL.

Inheritance Hierarchy

System.Object
Sc14n.Gen

Namespace: Sc14n
Assembly: diSc14nNet (in diSc14nNet.dll) Version: 3.1.0.28355 (3.1.0.0)

Syntax

public class Gen

The Gen type exposes the following members.

Methods

Name Description
CompileTime Gets date and time the core DLL module was last compiled.
LicenceType Gets licence type.
ModuleName Gets full path name of core DLL module.
Platform Gets platform on which the core DLL is running.
Version Gets version number of core diSc14n DLL.

See Also

Sc14n Namespace

Gen.CompileTime Method

Gets date and time the core DLL module was last compiled.

Namespace: Sc14n
Assembly: diSc14nNet (in diSc14nNet.dll) Version: 3.1.0.28355 (3.1.0.0)

Syntax

public static string CompileTime()

Return Value

String
Date and time string

See Also

Gen Class
Sc14n Namespace

Gen.LicenceType Method

Gets licence type.

Namespace: Sc14n
Assembly: diSc14nNet (in diSc14nNet.dll) Version: 3.1.0.28355 (3.1.0.0)

Syntax

public static char LicenceType()

Return Value

Char
D=Developer T=Trial

Remarks

Note the Australian/English spelling of “Licence”.

See Also

Gen Class
Sc14n Namespace

Gen.ModuleName Method

Gets full path name of core DLL module.

Namespace: Sc14n
Assembly: diSc14nNet (in diSc14nNet.dll) Version: 3.1.0.28355 (3.1.0.0)

Syntax

public static string ModuleName()

Return Value

String
File name

See Also

Gen Class
Sc14n Namespace

Gen.Platform Method

Gets platform on which the core DLL is running.

Namespace: Sc14n
Assembly: diSc14nNet (in diSc14nNet.dll) Version: 3.1.0.28355 (3.1.0.0)

Syntax

public static string Platform()

Return Value

String
"Win32" or "Win64"

See Also

Gen Class
Sc14n Namespace

Gen.Version Method

Gets version number of core diSc14n DLL.

Namespace: Sc14n
Assembly: diSc14nNet (in diSc14nNet.dll) Version: 3.1.0.28355 (3.1.0.0)

Syntax

public static int Version()

Return Value

Int32
Version number in form Major * 10000 + Minor * 100 + Release

Remarks

E.g. version 1.2.3 returns 10203

See Also

Gen Class
Sc14n Namespace

AdvOptions Enumeration

Advanced option flags

Namespace: Sc14n
Assembly: diSc14nNet (in diSc14nNet.dll) Version: 3.1.0.28355 (3.1.0.0)

Syntax

[FlagsAttribute]
public enum AdvOptions

Members

Member name Description
Default Default options.
Flatten Flatten the XML - remove all ignorable whitespace between tags.

See Also

Sc14n Namespace

DigAlg Enumeration

Digest Algorithm

Namespace: Sc14n
Assembly: diSc14nNet (in diSc14nNet.dll) Version: 3.1.0.28355 (3.1.0.0)

Syntax

public enum DigAlg

Members

Member name Description
Default Use default digest algorithm (SHA-1)
Sha1 Use SHA-1 digest algorithm (default)
Sha256 Use SHA-256 digest algorithm
Sha384 Use SHA-384 digest algorithm
Sha512 Use SHA-512 digest algorithm

See Also

Sc14n Namespace

Tran Enumeration

Transformation options to specify the document part to be canonicalized.

Namespace: Sc14n
Assembly: diSc14nNet (in diSc14nNet.dll) Version: 3.1.0.28355 (3.1.0.0)

Syntax

public enum Tran

Members

Member name Description
Entire Transform the entire document.
OmitByTag Omit the element with the given tag name.
SubsetByTag Transform the subset with the given tag name.
OmitById Omit the element with the given Id.
SubsetById Transform the subset with the given Id.

See Also

Sc14n Namespace
Remarks in C14n.ToFile

TranMethod Enumeration

Transformation methods

Namespace: Sc14n
Assembly: diSc14nNet (in diSc14nNet.dll) Version: 3.1.0.28355 (3.1.0.0)

Syntax

public enum TranMethod

Members

Member name Description
Inclusive Inclusive C14N without comments from RFC 3076.
Exclusive Exclusive C14N without comments from RFC 3741.
InclusiveWithComments Inclusive C14N with comments from RFC 3076.
ExclusiveWithComments Exclusive C14N with comments from RFC 3741.

See Also

Sc14n Namespace


Created: 2025-10-20 20:24:20
Copyright (C) 2025 D.I. Management Services Pty Ltd t/a CryptoSys https://cryptosys.net