项目作者: ks-no

项目描述 :
Library for creating, reading and validating ASIC-E packages
高级语言: C#
项目地址: git://github.com/ks-no/fiks-asice-dotnet.git
创建时间: 2019-02-20T13:22:01Z
项目社区:https://github.com/ks-no/fiks-asice-dotnet

开源协议:MIT License

下载


fiks-asice

MIT license
Nuget
GitHub issues
GitHub Release Date

Library for working with ASiC-E packages in .Net Core based projects.
This project is created by KS and released under a MIT license.

For more information on how to use this library, check the unit test module. The long term goal of this project is
to be functionally compliant with the DIFI ASiC library for Java.

Currently implements:

  • building ASiC-E packages containing binaries containing CAdES descriptor
  • signing packages using private/public keys in PEM files
  • reading ASiC-E packages including exposing CAdES signatures (only CAdES manifest descriptor supported for now)

TODO:

  • support for specifying OASIS manifest
  • support XAdES signatures

Examples

Create ASiC-E package containing single file

  1. using (var outStream = // create outstream)
  2. using (var fileStream = // open FileStream )
  3. {
  4. using (var asiceBuilder =
  5. AsiceBuilder.Create(outStream, MessageDigestAlgorithm.SHA256, signingCertificates))
  6. {
  7. asiceBuilder.AddFile(fileStream)
  8. var asiceArchive = asiceBuilder.Build();
  9. // archive is created, at this point the data will have been flushed to the outStream
  10. }
  11. }

Read data from ASiC-E

  1. IAsicReader reader = new AsiceReader();
  2. using (var inputStream = // ASiC-E package to read)
  3. using (var asice = reader.Read(inputStream))
  4. {
  5. foreach (var asiceReadEntry in asice.Entries)
  6. {
  7. using (var entryStream = asiceReadEntry.OpenStream())
  8. using (var outStream = // stream to output the data to)
  9. {
  10. entryStream.CopyTo(bufferStream);
  11. }
  12. }
  13. // Check that all digests declared in the manifest are valid
  14. if(asice.DigestVerifier.Verification().AllValid)
  15. {
  16. // Do something
  17. }
  18. else
  19. {
  20. // Handle error
  21. }
  22. }