Class FinSecurityMediaKeyFile

Namespace
Subsembly.FinTS
Assembly
Subsembly.FinTS.Core.dll

Abstract base class for all key file based IFinSecurityMedia interface implementations.

public abstract class FinSecurityMediaKeyFile : IFinSecurityMedia
Inheritance
FinSecurityMediaKeyFile
Implements
Derived
Inherited Members

Remarks

This class implements all methods of the IFinSecurityMedia interface, delegating key file specific work to some abstract methods that must be overridden by the derived concrete class.

Constructors

FinSecurityMediaKeyFile()

protected FinSecurityMediaKeyFile()

Properties

Capabilities

public FinSecurityMediaCaps Capabilities { get; }

Property Value

FinSecurityMediaCaps

Remarks

A derived class must call SetCapabilities(FinSecurityMediaCaps) in its constructor in order to change the value returned through this property.

ContactCapacity

Number of contacts that are or may be stored in the key file.

public int ContactCapacity { get; }

Property Value

int

Remarks

This property actually returns the number of contacts that have been added through AddContact(FinContact). Thus, if the actual key file can grow in order to store more contacts, then an additional empty contact record should be added at the end.

MaxKeyLength

By default returns 96.

public int MaxKeyLength { get; }

Property Value

int

Remarks

A derived class must override OnGetMaxKeyLength() in order to change the value returned through this property.

PassphraseFlags

By default returns None.

public FinSecurityMediaPassphraseFlags PassphraseFlags { get; }

Property Value

FinSecurityMediaPassphraseFlags

Remarks

A derived class must call SetPassphraseFlags(FinSecurityMediaPassphraseFlags) in its constructor in order to change the value returned through this property.

PassphraseMaxLength

By default returns 256.

public int PassphraseMaxLength { get; }

Property Value

int

Remarks

A derived class must call SetPassphraseMaxLength(int) in its constructor in order to change the value returned through this property.

PassphraseMinLength

By default returns 0.

public int PassphraseMinLength { get; }

Property Value

int

Remarks

A derived class must call SetPassphraseMinLength(int) in its constructor in order to change the value returned through this property.

SecurityMediaID

Provides the security media ID of the currently selected key file.

public string SecurityMediaID { get; }

Property Value

string

SecurityMediaType

Always returns KeyFile.

public FinSecurityMediaType SecurityMediaType { get; }

Property Value

FinSecurityMediaType

SecurityProfiles

public FinSecurityProfile[] SecurityProfiles { get; }

Property Value

FinSecurityProfile[]

Remarks

The default implementation always returns an array with a single RDH-1 element.

State

Indicates the current state of this IFinSecurityMedia implementation.

public FinSecurityMediaState State { get; }

Property Value

FinSecurityMediaState

Methods

AddContact(FinContact)

protected void AddContact(FinContact aContact)

Parameters

aContact FinContact

AddKey(FinSecureKey)

Add another key to this key store.

protected void AddKey(FinSecureKey aKey)

Parameters

aKey FinSecureKey

Authenticate(string, string)

public FinAuthenticateResult Authenticate(string sUserName, string sPassphrase)

Parameters

sUserName string

Optional UserName.

sPassphrase string

Returns

FinAuthenticateResult

AuthenticateAdmin(string, string)

public FinAuthenticateResult AuthenticateAdmin(string sUserName, string sAdminPassphrase)

Parameters

sUserName string
sAdminPassphrase string

Returns

FinAuthenticateResult

AuthenticateSecure()

Always just returns AuthenticateSecureNotSupported

public FinAuthenticateResult AuthenticateSecure()

Returns

FinAuthenticateResult

CanAuthenticateSecure()

public bool CanAuthenticateSecure()

Returns

bool

CanChangePassphraseSecure()

public bool CanChangePassphraseSecure()

Returns

bool

Cancel()

public void Cancel()

ChangePassphrase(string, string, string)

public FinAuthenticateResult ChangePassphrase(string sUserName, string sOldPassphrase, string sNewPassphrase)

Parameters

sUserName string
sOldPassphrase string
sNewPassphrase string

Returns

FinAuthenticateResult

ChangePassphraseSecure()

Always just returns AuthenticateSecureNotSupported

public FinAuthenticateResult ChangePassphraseSecure()

Returns

FinAuthenticateResult

Create(string, string, string)

public void Create(string sSecurityMediaID, string sUserName, string sPassphrase)

Parameters

sSecurityMediaID string
sUserName string
sPassphrase string

Remarks

The default implementation validates the given parameters and the current object State and then delegates to OnCreateKeyFile(string, string).

CreateContact()

public FinContact CreateContact()

Returns

FinContact

Decrypt(FinContact, FinSecureKey, FinOperationMode, byte[])

public byte[] Decrypt(FinContact aContact, FinSecureKey aKey, FinOperationMode nOpMode, byte[] vbCrypt)

Parameters

aContact FinContact
aKey FinSecureKey
nOpMode FinOperationMode
vbCrypt byte[]

Returns

byte[]

ElevateKey(FinContact, FinSecureKey, FinSecureKeyState)

public void ElevateKey(FinContact aContact, FinSecureKey aKey, FinSecureKeyState nNewKeyState)

Parameters

aContact FinContact
aKey FinSecureKey
nNewKeyState FinSecureKeyState

Encrypt(FinContact, FinSecureKey, FinOperationMode, byte[])

public byte[] Encrypt(FinContact aContact, FinSecureKey aKey, FinOperationMode nOpMode, byte[] vbData)

Parameters

aContact FinContact
aKey FinSecureKey
nOpMode FinOperationMode
vbData byte[]

Returns

byte[]

EraseContact(int)

public void EraseContact(int nContactIndex)

Parameters

nContactIndex int

EraseKey(FinContact, FinSecureKey)

public void EraseKey(FinContact aContact, FinSecureKey aKey)

Parameters

aContact FinContact
aKey FinSecureKey

GenerateKey(FinContact, FinSecureKeyType, int, int, int)

Generates ans stores a new key.

public FinSecureKey GenerateKey(FinContact aContact, FinSecureKeyType nKeyType, int nKeyLength, int nKeyNumber, int nKeyVersion)

Parameters

aContact FinContact
nKeyType FinSecureKeyType
nKeyLength int
nKeyNumber int
nKeyVersion int

Returns

FinSecureKey

Remarks

Any existing key with the same attributes will be replaced.

InitPassphrase(string, string)

Always throws a NotSupportedException.

public FinAuthenticateResult InitPassphrase(string sUserName, string sPassphrase)

Parameters

sUserName string
sPassphrase string

Returns

FinAuthenticateResult

ObtainContact(int)

public FinContact ObtainContact(int nContactIndex)

Parameters

nContactIndex int

Returns

FinContact

ObtainKey(FinContact, FinSecureKeyType, int, int)

public virtual FinSecureKey ObtainKey(FinContact aContact, FinSecureKeyType nKeyType, int nKeyNumber, int nKeyVersion)

Parameters

aContact FinContact
nKeyType FinSecureKeyType
nKeyNumber int
nKeyVersion int

Returns

FinSecureKey

OnCancel()

protected virtual void OnCancel()

OnChangePassphrase(string)

protected virtual FinAuthenticateResult OnChangePassphrase(string sNewPassphrase)

Parameters

sNewPassphrase string

Returns

FinAuthenticateResult

OnCreateKeyFile(string, string)

Override in order to create a new key file instance from scratch.

protected virtual void OnCreateKeyFile(string sUserName, string sPassphrase)

Parameters

sUserName string

Optional UserName parameter.

sPassphrase string

The passphrase to be used in order to protect the key file.

Remarks

The default implementation simply throws NotSupportedException.

OnGetMaxKeyLength()

protected virtual int OnGetMaxKeyLength()

Returns

int

OnGetSecurityProfiles()

protected virtual FinSecurityProfile[] OnGetSecurityProfiles()

Returns

FinSecurityProfile[]

OnLoadKeyFile(string, string)

Must be overriden in order to fully load a previously selected key file.

protected abstract FinAuthenticateResult OnLoadKeyFile(string sUserName, string sPassphrase)

Parameters

sUserName string

Optional UserName parameter.

sPassphrase string

Returns

FinAuthenticateResult

This method is also responsible for checking the passphrase and to return an appropriate FinAuthenticateResult for it.

OnRelease()

protected virtual void OnRelease()

OnSaveKeyFile(string)

protected virtual void OnSaveKeyFile(string sFileName)

Parameters

sFileName string

OnSelectKeyFile(string)

Must be overriden in order to select an existing key file.

protected abstract FinAuthenticateResult OnSelectKeyFile(string sFileName)

Parameters

sFileName string

The complete file name including path and file name extension of the key file to be selected by this method.

Returns

FinAuthenticateResult

Release()

public void Release()

ResetKey(FinContact, FinSecureKey)

public void ResetKey(FinContact aContact, FinSecureKey aKey)

Parameters

aContact FinContact
aKey FinSecureKey

Select(string)

public FinAuthenticateResult Select(string sSecurityMediaID)

Parameters

sSecurityMediaID string

Returns

FinAuthenticateResult

SelectKeyFile(string)

Convenience helper that attempts to detect the type of the given key file and returns a suitable IFinSecurityMedia instance for it.

public static IFinSecurityMedia SelectKeyFile(string sFilename)

Parameters

sFilename string

The name of the key file to select with a suitable IFinSecurityMedia implementation. Must not be null.

Returns

IFinSecurityMedia

If the key file was successfully detected and also successfully selected by the IFinSecurityMedia implementation, then a reference to the selected instance is returned. If the key file was not recognized, or selection failed, then null is returned.

Exceptions

ArgumentNullException

The parameter sFilename was null.

ArgumentException

The parameter aFilename was an empty string.

SetCapabilities(FinSecurityMediaCaps)

protected void SetCapabilities(FinSecurityMediaCaps nCapabilities)

Parameters

nCapabilities FinSecurityMediaCaps

SetPassphraseFlags(FinSecurityMediaPassphraseFlags)

protected void SetPassphraseFlags(FinSecurityMediaPassphraseFlags nPassphraseFlags)

Parameters

nPassphraseFlags FinSecurityMediaPassphraseFlags

SetPassphraseMaxLength(int)

protected void SetPassphraseMaxLength(int nPassphraseMaxLength)

Parameters

nPassphraseMaxLength int

SetPassphraseMinLength(int)

protected void SetPassphraseMinLength(int nPassphraseMinLength)

Parameters

nPassphraseMinLength int

SignHash(FinContact, FinSecureKey, FinOperationMode, FinHash, byte[])

public byte[] SignHash(FinContact aContact, FinSecureKey aKey, FinOperationMode nOpMode, FinHash nHash, byte[] vbHash)

Parameters

aContact FinContact
aKey FinSecureKey
nOpMode FinOperationMode
nHash FinHash
vbHash byte[]

Returns

byte[]

StoreContact(int, FinContact)

public void StoreContact(int nContactIndex, FinContact aContact)

Parameters

nContactIndex int
aContact FinContact

StoreKey(FinContact, FinSecureKey)

public void StoreKey(FinContact aContact, FinSecureKey aKey)

Parameters

aContact FinContact
aKey FinSecureKey

Remarks

Any existing key with the same attributes will be replaced.

Verify(FinContact, FinSecureKey, FinOperationMode, FinHash, byte[], byte[])

public bool Verify(FinContact aContact, FinSecureKey aKey, FinOperationMode nOpMode, FinHash nHash, byte[] vbHash, byte[] vbSignature)

Parameters

aContact FinContact
aKey FinSecureKey
nOpMode FinOperationMode
nHash FinHash
vbHash byte[]
vbSignature byte[]

Returns

bool