Giter Club home page Giter Club logo

xmlsignverify-core-csharp's Introduction

Table of Contents

Overview

This library provides reference implementation of ISO 20022 Digital Signature specification to sign and verify XML messages.

Refer to ISO20022 Signed Unsigned Message Examples for understanding the difference between a signed and unsigned message.

In a signed XML payload, you will see three reference nodes:

  • Resource as URI="" - will get resolved to AppHdr
  • Resource with no URI - will get resolved to Document
  • Resource as URI="#id" - will get resolved to element as per that id value

Compatibility

  • Visual Studio 2019+ or JetBrain Rider 2020+
  • Framework NET 5.0

Usage

Signing the Request

XmlSignUtil.Sign(XmlDocument xmlDocument, SignatureInfo signatureInfo, SignatureKeyInfo signatureKeyinfo) signs the XML Document where:

  • xmlDocument - the unsigned payload
  • signatureInfo - signature info which is used in signing the payload
  • signatureKeyInfo - signature key info which holds private key and ski bytes to be set in X509 Data element

Refer to detailed message signing flow.

Verifying the Request

XmlSignUtil.Verify(XmlDocument signedXml, AsymmetricAlgorithm publicKey) verifies the signed payload where:

  • signedXml - the signed payload
  • publicKey - the public key

Refer to detailed message verification flow.

Adding the Classes to Your Project

There are two classes:

  • XmlSignUtil.cs
  • XmlSignUtilTest.cs

XmlSignUtil.cs calls below methods:

  • Sign
  • Verify

XmlSignUtilTest.cs includes 4 test cases:

  • Sign the document and verify it: SignAndVerifyTest()
  • Sign the document and then try to verify with wrong public key and assert failure in verification: SignAndVerifyWithWrongPublicKeyTest()
  • Sign the document and tamper the payload and assert failure in verification: SignAndVerifyWithWhenSignedPayloadTamperedTest()
  • Verify a Java-signed document: JavaSignedVerifyTest()

xmlsignverify-core-csharp's People

Contributors

cemaleray avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.