-
Notifications
You must be signed in to change notification settings - Fork 11
#306 - Update of Swissbit Hardware TSE V2 #633
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
forsthug
wants to merge
8
commits into
main
Choose a base branch
from
#306---Update-of-Swissbit-Hardware-TSE-V2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f8f5582
Swissbit Hardware V2 project
forsthug 2150e15
Removed direct calls to Swissbit.Interop.NativeWormAPI
forsthug 25e55a4
add firmwareupdate if not v2
forsthug 09f22e8
add to workflow
forsthug 92efcbb
bring back to v1 - merge
forsthug 9254a07
scu-de remove firmware update
forsthug 65b5c3f
..
forsthug 88ca335
..
forsthug File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
scu-de/src/fiskaltrust.Middleware.SCU.DE.SwissbitV2/.nuspec
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> |
3 changes: 3 additions & 0 deletions
3
scu-de/src/fiskaltrust.Middleware.SCU.DE.SwissbitV2/Directory.Build.props
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| <Project> | ||
| <Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" /> | ||
| </Project> |
19 changes: 19 additions & 0 deletions
19
scu-de/src/fiskaltrust.Middleware.SCU.DE.SwissbitV2/Exceptions/NativeLibraryException.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) { } | ||
| } | ||
| } |
23 changes: 23 additions & 0 deletions
23
scu-de/src/fiskaltrust.Middleware.SCU.DE.SwissbitV2/Exceptions/SwissbitException.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) { } | ||
| } | ||
| } |
148 changes: 148 additions & 0 deletions
148
scu-de/src/fiskaltrust.Middleware.SCU.DE.SwissbitV2/Exceptions/SwissbitExceptionHelper.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
| } | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.