CryptoSys Home > Sc14n > Programming interfaces

Programming interfaces to SC14N


This page shows how to use the various programming interfaces to SC14N with documentation and example code.

.NET | C/C++ | VBA/VB6 | Python | Verifying XML‑DSIG docs | Contact us

All reference files are installed in the directory C:\Program Files (x86)\Sc14n unless you chose otherwise during installation. You can find the files by using the Windows menu options
Start > All Programs > Sc14n > Sc14n Reference Files

There is a set of test files in the installation directory C:\Program Files (x86)\Sc14n\TestFiles. You should make a copy of these to a less-protected directory for doing tests. Or you can download the zipped files directly.

Using with .NET: C# and VB.NET

To use the .NET interface with C# and VB.NET (VB2010+):

  1. In your application, add a reference to the Sc14n library:
    1. Project > Add Reference.
    2. In the .NET tab, click on the Browse button to find and select the library file diSc14nNet.dll (installed by default in C:\Program Files (x86)\Sc14n\DotNet).
    3. Click on OK and the wizard will add the reference of the class library to your project.
  2. Add the line to your code (for C#)
    using Sc14n;

    or (for VB.NET)

    Imports Sc14n

C# test programs: TestSc14n.cs and TestSc14nPki.cs
VB.NET test programs: TestSc14n.vb and TestSc14nPki.vb.

Documentation: Sc14n Namespace .NET Help.

Using with C and C++

To use with a C or C++ program, include the diSc14n.h file with your source code and link with the diSc14n.lib library (the install program puts these files by default in C:\Program Files (x86)\Sc14n\C)

Example test programs in C: TestSc14n.c and TestSc14nPKI.c.

Documentation: Reference manual for C/C++ programmers.

Using with VBA and VB6

Add the module basSc14n.bas to your project. (the install program puts this file by default in C:\Program Files (x86)\Sc14n\VBA). Use the module basUtf8FromString.bas to convert between VBA Unicode strings and UTF-8-encoded byte arrays.

Example test programs in VBA: TestSc14n.bas.

Using with Python

See Python Interface to SC14N.

Example test programs in Python: test-sc14n.py and test_sc14n_pki.py.

Documentation: Sc14n Py documentation.

Verifying an XML-DSIG document

The test files folder "TestFiles\signed" contains various files that have been signed using "Alice's" signing key and should pass as valid on the Online XML Digital Signature Verifer.

We find the best way to test is to open the XML file using NotePad++, select all (Ctrl-A), then copy and paste onto the web page. This seems to prevent character encoding errors when using the clipboard.

If you still get an "encoding error" because of a non-ASCII character, then replace the offending character, say é (U+00E9 latin small letter e with acute), with its character reference "é".

These test signed XML documents include the <KeyInfo> as an <RSAKeyValue>. This is required by the Verifier site if you are using a test key like we are. In practice you'd probably be using a <X509Certificate> element instead.

Some examples include inline DTD !ATTLIST instructions which are required if you're using an Id reference like URI="#foo" on the xmldsig-verifier site.

New2022-03-20: See Troubleshooting problems on the 'Online XML Digital Signature Verifier' site

Contact us

To contact us or comment on this page, please send us a message.

This page last updated 15 November 2022

[Go to top]