Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/scu-de-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ on:
- fiskaltrust.Middleware.SCU.DE.Swissbit
- fiskaltrust.Middleware.SCU.DE.SwissbitCloud
- fiskaltrust.Middleware.SCU.DE.SwissbitCloudV2
- fiskaltrust.Middleware.SCU.DE.SwissbitV2
Comment thread
forsthug marked this conversation as resolved.
Outdated
deploySandbox:
type: boolean
default: false
Expand Down
15 changes: 15 additions & 0 deletions scu-de/fiskaltrust.Middleware.SCU.DE.sln
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "fiskaltrust.Middleware.SCU.
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "fiskaltrust.Middleware.SCU.DE.FiskalyCertified.UnitTest", "test\fiskaltrust.Middleware.SCU.DE.FiskalyCertified.UnitTest\fiskaltrust.Middleware.SCU.DE.FiskalyCertified.UnitTest.csproj", "{4DAA4C67-C0B0-48C3-B41F-851759D86DFB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "fiskaltrust.Middleware.SCU.DE.SwissbitV2", "src\fiskaltrust.Middleware.SCU.DE.SwissbitV2\fiskaltrust.Middleware.SCU.DE.SwissbitV2.csproj", "{4B1F461A-5F22-A409-18BE-1134AC60DCEC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -351,6 +353,18 @@ Global
{4DAA4C67-C0B0-48C3-B41F-851759D86DFB}.Release|x64.Build.0 = Release|Any CPU
{4DAA4C67-C0B0-48C3-B41F-851759D86DFB}.Release|x86.ActiveCfg = Release|Any CPU
{4DAA4C67-C0B0-48C3-B41F-851759D86DFB}.Release|x86.Build.0 = Release|Any CPU
{4B1F461A-5F22-A409-18BE-1134AC60DCEC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4B1F461A-5F22-A409-18BE-1134AC60DCEC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4B1F461A-5F22-A409-18BE-1134AC60DCEC}.Debug|x64.ActiveCfg = Debug|Any CPU
{4B1F461A-5F22-A409-18BE-1134AC60DCEC}.Debug|x64.Build.0 = Debug|Any CPU
{4B1F461A-5F22-A409-18BE-1134AC60DCEC}.Debug|x86.ActiveCfg = Debug|Any CPU
{4B1F461A-5F22-A409-18BE-1134AC60DCEC}.Debug|x86.Build.0 = Debug|Any CPU
{4B1F461A-5F22-A409-18BE-1134AC60DCEC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4B1F461A-5F22-A409-18BE-1134AC60DCEC}.Release|Any CPU.Build.0 = Release|Any CPU
{4B1F461A-5F22-A409-18BE-1134AC60DCEC}.Release|x64.ActiveCfg = Release|Any CPU
{4B1F461A-5F22-A409-18BE-1134AC60DCEC}.Release|x64.Build.0 = Release|Any CPU
{4B1F461A-5F22-A409-18BE-1134AC60DCEC}.Release|x86.ActiveCfg = Release|Any CPU
{4B1F461A-5F22-A409-18BE-1134AC60DCEC}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -381,6 +395,7 @@ Global
{61F3E070-5E01-4EBE-B6FC-64D05472CB19} = {2F690A2B-96D1-45AC-BD36-E27D68422352}
{0728A325-37E5-4E23-AAC5-DB2860BB75F3} = {7201C6FB-C25C-45DB-9C0B-1355FEF13939}
{4DAA4C67-C0B0-48C3-B41F-851759D86DFB} = {7201C6FB-C25C-45DB-9C0B-1355FEF13939}
{4B1F461A-5F22-A409-18BE-1134AC60DCEC} = {2F690A2B-96D1-45AC-BD36-E27D68422352}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C5E269B8-4A21-4B1B-8805-C8193C08FE3E}
Expand Down
46 changes: 46 additions & 0 deletions scu-de/src/fiskaltrust.Middleware.SCU.DE.SwissbitV2/.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<package>
<metadata>
<id>fiskaltrust.Middleware.SCU.DE.SwissbitV2</id>
<version>1.3.0-local</version>
<authors>fiskaltrust</authors>
<owners>fiskaltrust</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>The fiskaltrust middleware implementation for the Swissbit TSE V2.</description>
<dependencies>
<group targetFramework=".NETFramework4.6.1">
<dependency id="BouncyCastle" version="1.7.0" exclude="Build,Analyzers" />
<dependency Id="fiskaltrust.Middleware.Abstractions" version="1.3.1" />
<dependency id="fiskaltrust.interface" version="1.3.40" exclude="Build,Analyzers" />
<dependency Id="Microsoft.Bcl.AsyncInterfaces" version="1.1.1" />
<dependency Id="System.Linq.Async" version="4.1.1" />
<dependency Id="Microsoft.Extensions.Logging" version="3.1.4" />
<dependency Id="Mono.Posix.NETStandard" version="1.0.0" />
<dependency id="sharpcompress" version="0.24.0" exclude="Build,Analyzers" />
<dependency Id="Newtonsoft.Json" version="12.0.3" />
</group>
<group targetFramework=".NETStandard2.0">
<dependency id="Portable.BouncyCastle" version="1.8.1.2" exclude="Build,Analyzers" />
<dependency id="fiskaltrust.interface" version="1.3.40" exclude="Build,Analyzers" />
<dependency Id="fiskaltrust.Middleware.Abstractions" version="1.3.1" />
<dependency Id="Microsoft.Bcl.AsyncInterfaces" version="1.1.1" />
<dependency Id="System.Linq.Async" version="4.1.1" />
<dependency Id="Microsoft.Extensions.Logging" version="3.1.4" />
<dependency Id="Mono.Posix.NETStandard" version="1.0.0" />
<dependency id="sharpcompress" version="0.24.0" exclude="Build,Analyzers" />
<dependency Id="Newtonsoft.Json" version="12.0.3" />
</group>
</dependencies>
</metadata>
<files>
<file src="bin\Release\net461\fiskaltrust.Middleware.SCU.DE.*.dll" target="lib\net461" />
<file src="bin\Release\netstandard2.0\fiskaltrust.Middleware.SCU.DE.*.dll" target="lib\netstandard2.0" />

<!-- native binaries used by fiskaltrust-launcher out of lib/ folder -->
<!-- the subfolders are not created on output and not used by visual-studio, project.asset.json is not updated -->
<!-- directory-structure runtimes\{runtime-identifier}\native should follow .net5 System.Runtime.InteropServices.NativeLibrary -->
<file src="bin\Release\net461\runtimesv2\**" target="lib\net461\runtimesv2 "/>
<file src="bin\Release\netstandard2.0\runtimesv2\**" target="lib\netstandard2.0\runtimesv2 "/>
<file src="bin\Release\net461\LICENSES\**" target="LICENSES "/>
</files>
</package>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Project>
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Text;

namespace fiskaltrust.Middleware.SCU.DE.SwissbitV2.Exceptions
{
[Serializable]
public class NativeLibraryException : Exception
{
public NativeLibraryException(string message) : base(message) { }

public NativeLibraryException(string message, Exception innerException) : base(message, innerException) { }

public NativeLibraryException() { }

protected NativeLibraryException(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext) { }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System;
using System.Runtime.Serialization;
using fiskaltrust.ifPOS.v1;
using fiskaltrust.Middleware.SCU.DE.SwissbitV2.Interop;

namespace fiskaltrust.Middleware.SCU.DE.SwissbitV2.Exceptions
{
[Serializable]
public class SwissbitException : ScuException
{
public NativeFunctionPointer.WormError Error { get; set; }

public SwissbitException(string message) : base(message) { }

public SwissbitException(string message, NativeFunctionPointer.WormError error) : base(message) => Error = error;

public SwissbitException(string message, Exception innerException) : base(message, innerException) { }

public SwissbitException() { }

protected SwissbitException(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext) { }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
using fiskaltrust.Middleware.SCU.DE.SwissbitV2.Interop;

namespace fiskaltrust.Middleware.SCU.DE.SwissbitV2.Exceptions
{
public static class SwissbitExceptionHelper
{
public static void ThrowIfError(this NativeFunctionPointer.WormError error)
{
switch (error)
{
case NativeFunctionPointer.WormError.WORM_ERROR_NOERROR:
break;
case NativeFunctionPointer.WormError.WORM_ERROR_INVALID_PARAMETER:
throw new SwissbitException("Invalid input parameter.", error);
case NativeFunctionPointer.WormError.WORM_ERROR_NO_WORM_CARD:
throw new SwissbitException("No TSE was found at the provided path.", error);
case NativeFunctionPointer.WormError.WORM_ERROR_IO:
throw new SwissbitException("IO Error. ", error);
case NativeFunctionPointer.WormError.WORM_ERROR_TIMEOUT:
throw new SwissbitException("Operation timed out. ", error);
case NativeFunctionPointer.WormError.WORM_ERROR_OUTOFMEM:
throw new SwissbitException("Out of memory. ", error);
case NativeFunctionPointer.WormError.WORM_ERROR_INVALID_RESPONSE:
throw new SwissbitException("Invalid Response from TSE. ", error);
case NativeFunctionPointer.WormError.WORM_ERROR_STORE_FULL_INTERNAL:
throw new SwissbitException("The TSE Store is full. ", error);
case NativeFunctionPointer.WormError.WORM_ERROR_RESPONSE_MISSING:
throw new SwissbitException("A command was not acknowledged", error);
case NativeFunctionPointer.WormError.WORM_ERROR_EXPORT_NOT_INITIALIZED:
throw new SwissbitException("TSE not initialized. ", error);
case NativeFunctionPointer.WormError.WORM_ERROR_EXPORT_FAILED:
throw new SwissbitException("Export Failed. ", error);
case NativeFunctionPointer.WormError.WORM_ERROR_INCREMENTAL_EXPORT_INVALID_STATE:
throw new SwissbitException("Incremental Export: invalid state.", error);
case NativeFunctionPointer.WormError.WORM_ERROR_INCREMENTAL_EXPORT_NO_DATA:
throw new SwissbitException("Incremental Export: no new data. ", error);
case NativeFunctionPointer.WormError.WORM_ERROR_POWER_CYCLE_DETECTED:
throw new SwissbitException("A power cycle occurred during command execution. ", error);
case NativeFunctionPointer.WormError.WORM_ERROR_FIRMWARE_UPDATE_NOT_APPLIED:
throw new SwissbitException("The firmware update was not properly applied. ", error);
case NativeFunctionPointer.WormError.WORM_ERROR_THREAD_START_FAILED:
throw new SwissbitException("Failed to start the background thread for keeping the TSE awake. ", error);
case NativeFunctionPointer.WormError.WORM_ERROR_FROM_CARD_FIRST:
throw new SwissbitException("Lowest error code that might be raised from the TSE. ", error);
case NativeFunctionPointer.WormError.WORM_ERROR_UNKNOWN:
throw new SwissbitException("Unspecified, internal processing error. ", error);
case NativeFunctionPointer.WormError.WORM_ERROR_NO_TIME_SET:
throw new SwissbitException("Time not set. ", error);
case NativeFunctionPointer.WormError.WORM_ERROR_NO_TRANSACTION_IN_PROGRESS:
throw new SwissbitException("No transaction in progress. ", error);
case NativeFunctionPointer.WormError.WORM_ERROR_INVALID_CMD_SYNTAX:
throw new SwissbitException("Wrong command length. ", error);
case NativeFunctionPointer.WormError.WORM_ERROR_NOT_ENOUGH_DATA_WRITTEN:
throw new SwissbitException("Not enough data written during transaction. ", error);
case NativeFunctionPointer.WormError.WORM_ERROR_TSE_INVALID_PARAMETER:
throw new SwissbitException("Invalid Parameter. ");
case NativeFunctionPointer.WormError.WORM_ERROR_TRANSACTION_NOT_STARTED:
throw new SwissbitException("Given transaction is not started. ", error);
case NativeFunctionPointer.WormError.WORM_ERROR_MAX_PARALLEL_TRANSACTIONS:
throw new SwissbitException("Maximum parallel transactions reached. ", error);
case NativeFunctionPointer.WormError.WORM_ERROR_CERTIFICATE_EXPIRED:
throw new SwissbitException("Certificate expired. ", error);
case NativeFunctionPointer.WormError.WORM_ERROR_NO_LAST_TRANSACTION:
throw new SwissbitException("No last transaction to fetch. ", error);
case NativeFunctionPointer.WormError.WORM_ERROR_CMD_NOT_ALLOWED:
throw new SwissbitException("Command not allowed in current state. ", error);
case NativeFunctionPointer.WormError.WORM_ERROR_TRANSACTION_SIGNATURES_EXCEEDED:
throw new SwissbitException("Signatures exceeded. ", error);
case NativeFunctionPointer.WormError.WORM_ERROR_NOT_AUTHORIZED:
throw new SwissbitException("Not authorized. ", error);
case NativeFunctionPointer.WormError.WORM_ERROR_MAX_REGISTERED_CLIENTS_REACHED:
throw new SwissbitException("Maximum registered clients reached. ", error);
case NativeFunctionPointer.WormError.WORM_ERROR_CLIENT_NOT_REGISTERED:
throw new SwissbitException("Client not registered. ", error);
case NativeFunctionPointer.WormError.WORM_ERROR_EXPORT_UNACKNOWLEDGED_DATA:
throw new SwissbitException("Failed to delete, data not completely exported. ", error);
case NativeFunctionPointer.WormError.WORM_ERROR_CLIENT_HAS_UNFINISHED_TRANSACTIONS:
throw new SwissbitException("Failed to deregister, client has unfinished transactions. ", error);
case NativeFunctionPointer.WormError.WORM_ERROR_TSE_HAS_UNFINISHED_TRANSACTIONS:
throw new SwissbitException("Failed to decommission, TSE has unfinished transactions. ", error);
case NativeFunctionPointer.WormError.WORM_ERROR_TSE_NO_RESPONSE_TO_FETCH:
throw new SwissbitException("Wrong state, there is no response to fetch. ", error);
case NativeFunctionPointer.WormError.WORM_ERROR_NOT_ALLOWED_EXPORT_IN_PROGRESS:
throw new SwissbitException("Wrong state, ongoing Filtered Export must be finished before this command is allowed. ", error);
case NativeFunctionPointer.WormError.WORM_ERROR_STORE_FULL:
throw new SwissbitException("Operation failed, not enough remaining capacity in TSE Store. ", error);
case NativeFunctionPointer.WormError.WORM_ERROR_WRONG_STATE_NEEDS_PUK_CHANGE:
throw new SwissbitException("Wrong state, changed PUK required. ", error);
case NativeFunctionPointer.WormError.WORM_ERROR_WRONG_STATE_NEEDS_PIN_CHANGE:
throw new SwissbitException("Wrong state, changed PIN required. ", error);
case NativeFunctionPointer.WormError.WORM_ERROR_WRONG_STATE_NEEDS_ACTIVE_CTSS:
throw new SwissbitException("Wrong state, active CTSS interface required. ", error);
case NativeFunctionPointer.WormError.WORM_ERROR_WRONG_STATE_NEEDS_SELF_TEST:
throw new SwissbitException("Wrong state, self test must be run first. ", error);
case NativeFunctionPointer.WormError.WORM_ERROR_WRONG_STATE_NEEDS_SELF_TEST_PASSED:
throw new SwissbitException("Wrong state, passed self test required. ", error);
case NativeFunctionPointer.WormError.WORM_ERROR_FWU_INTEGRITY_FAILURE:
throw new SwissbitException("Firmware Update: Integrity check failed. ", error);
case NativeFunctionPointer.WormError.WORM_ERROR_FWU_DECRYPTION_FAILURE:
throw new SwissbitException("Firmware Update: Decryption failed. ", error);
case NativeFunctionPointer.WormError.WORM_ERROR_FWU_WRONG_FORMAT:
throw new SwissbitException("Firmware Update: Wrong format. ", error);
case NativeFunctionPointer.WormError.WORM_ERROR_FWU_INTERNAL_ERROR:
throw new SwissbitException("Firmware Update: Internal error. ", error);
case NativeFunctionPointer.WormError.WORM_ERROR_FWU_DOWNGRADE_PROHIBITED:
throw new SwissbitException("Firmware Update: downgrade prohibited. ", error);
case NativeFunctionPointer.WormError.WORM_ERROR_TSE_ALREADY_INITIALIZED:
throw new SwissbitException("TSE already initialized. ", error);
case NativeFunctionPointer.WormError.WORM_ERROR_TSE_DECOMMISSIONED:
throw new SwissbitException("TSE decommissioned. ", error);
case NativeFunctionPointer.WormError.WORM_ERROR_TSE_NOT_INITIALIZED:
throw new SwissbitException("TSE not initialized. ", error);
case NativeFunctionPointer.WormError.WORM_ERROR_AUTHENTICATION_FAILED:
throw new SwissbitException("Authentication failed. ", error);
case NativeFunctionPointer.WormError.WORM_ERROR_AUTHENTICATION_PIN_BLOCKED:
throw new SwissbitException("PIN is blocked. ", error);
case NativeFunctionPointer.WormError.WORM_ERROR_AUTHENTICATION_USER_NOT_LOGGED_IN:
throw new SwissbitException("Given user is not authenticated. ", error);
case NativeFunctionPointer.WormError.WORM_ERROR_SELF_TEST_FAILED_FW:
throw new SwissbitException("Self test of FW failed. ", error);
case NativeFunctionPointer.WormError.WORM_ERROR_SELF_TEST_FAILED_CSP:
throw new SwissbitException("Self test of CSP failed. ", error);
case NativeFunctionPointer.WormError.WORM_ERROR_SELF_TEST_FAILED_RNG:
throw new SwissbitException("Self test of RNG failed. ", error);
case NativeFunctionPointer.WormError.WORM_ERROR_FWU_BASE_FW_ERROR:
throw new SwissbitException("Firmware Update: Base FW update error. ", error);
case NativeFunctionPointer.WormError.WORM_ERROR_FWU_FWEXT_ERROR:
throw new SwissbitException("Firmware Update: FW Extension update error. ", error);
case NativeFunctionPointer.WormError.WORM_ERROR_FWU_CSP_ERROR:
throw new SwissbitException("Firmware Update: CSP update error. ", error);
case NativeFunctionPointer.WormError.WORM_ERROR_EXPORT_NONE_IN_PROGRESS:
throw new SwissbitException("Filtered Export: no export in progress. ", error);
case NativeFunctionPointer.WormError.WORM_ERROR_EXPORT_RETRY:
throw new SwissbitException("Filtered Export: no new data, keep polling. ", error);
case NativeFunctionPointer.WormError.WORM_ERROR_EXPORT_NO_DATA_AVAILABLE:
throw new SwissbitException("Filtered Export: no matching entries, export would be empty. ", error);
case NativeFunctionPointer.WormError.WORM_ERROR_CMD_NOT_FOUND:
throw new SwissbitException("Command not found. ", error);
case NativeFunctionPointer.WormError.WORM_ERROR_SIG_ERROR:
throw new SwissbitException("Signature creation error. ", error);
case NativeFunctionPointer.WormError.WORM_ERROR_FROM_CARD_LAST:
throw new SwissbitException($"Highest error code that might be raised from the TSE. {error}", error);
default:
throw new SwissbitException($"{error}", error);
}
}
}
}
Loading
Loading