Class FinSecurityMediaKeyFile
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
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
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
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
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
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
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
SecurityMediaType
Always returns KeyFile.
public FinSecurityMediaType SecurityMediaType { get; }
Property Value
SecurityProfiles
public FinSecurityProfile[] SecurityProfiles { get; }
Property Value
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
Methods
AddContact(FinContact)
protected void AddContact(FinContact aContact)
Parameters
aContactFinContact
AddKey(FinSecureKey)
Add another key to this key store.
protected void AddKey(FinSecureKey aKey)
Parameters
aKeyFinSecureKey
Authenticate(string, string)
public FinAuthenticateResult Authenticate(string sUserName, string sPassphrase)
Parameters
Returns
AuthenticateAdmin(string, string)
public FinAuthenticateResult AuthenticateAdmin(string sUserName, string sAdminPassphrase)
Parameters
Returns
AuthenticateSecure()
Always just returns AuthenticateSecureNotSupported
public FinAuthenticateResult AuthenticateSecure()
Returns
CanAuthenticateSecure()
public bool CanAuthenticateSecure()
Returns
CanChangePassphraseSecure()
public bool CanChangePassphraseSecure()
Returns
Cancel()
public void Cancel()
ChangePassphrase(string, string, string)
public FinAuthenticateResult ChangePassphrase(string sUserName, string sOldPassphrase, string sNewPassphrase)
Parameters
Returns
ChangePassphraseSecure()
Always just returns AuthenticateSecureNotSupported
public FinAuthenticateResult ChangePassphraseSecure()
Returns
Create(string, string, string)
public void Create(string sSecurityMediaID, string sUserName, string sPassphrase)
Parameters
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
Decrypt(FinContact, FinSecureKey, FinOperationMode, byte[])
public byte[] Decrypt(FinContact aContact, FinSecureKey aKey, FinOperationMode nOpMode, byte[] vbCrypt)
Parameters
aContactFinContactaKeyFinSecureKeynOpModeFinOperationModevbCryptbyte[]
Returns
- byte[]
ElevateKey(FinContact, FinSecureKey, FinSecureKeyState)
public void ElevateKey(FinContact aContact, FinSecureKey aKey, FinSecureKeyState nNewKeyState)
Parameters
aContactFinContactaKeyFinSecureKeynNewKeyStateFinSecureKeyState
Encrypt(FinContact, FinSecureKey, FinOperationMode, byte[])
public byte[] Encrypt(FinContact aContact, FinSecureKey aKey, FinOperationMode nOpMode, byte[] vbData)
Parameters
aContactFinContactaKeyFinSecureKeynOpModeFinOperationModevbDatabyte[]
Returns
- byte[]
EraseContact(int)
public void EraseContact(int nContactIndex)
Parameters
nContactIndexint
EraseKey(FinContact, FinSecureKey)
public void EraseKey(FinContact aContact, FinSecureKey aKey)
Parameters
aContactFinContactaKeyFinSecureKey
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
aContactFinContactnKeyTypeFinSecureKeyTypenKeyLengthintnKeyNumberintnKeyVersionint
Returns
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
Returns
ObtainContact(int)
public FinContact ObtainContact(int nContactIndex)
Parameters
nContactIndexint
Returns
ObtainKey(FinContact, FinSecureKeyType, int, int)
public virtual FinSecureKey ObtainKey(FinContact aContact, FinSecureKeyType nKeyType, int nKeyNumber, int nKeyVersion)
Parameters
aContactFinContactnKeyTypeFinSecureKeyTypenKeyNumberintnKeyVersionint
Returns
OnCancel()
protected virtual void OnCancel()
OnChangePassphrase(string)
protected virtual FinAuthenticateResult OnChangePassphrase(string sNewPassphrase)
Parameters
sNewPassphrasestring
Returns
OnCreateKeyFile(string, string)
Override in order to create a new key file instance from scratch.
protected virtual void OnCreateKeyFile(string sUserName, string sPassphrase)
Parameters
sUserNamestringOptional UserName parameter.
sPassphrasestringThe passphrase to be used in order to protect the key file.
Remarks
The default implementation simply throws NotSupportedException.
OnGetMaxKeyLength()
protected virtual int OnGetMaxKeyLength()
Returns
OnGetSecurityProfiles()
protected virtual FinSecurityProfile[] OnGetSecurityProfiles()
Returns
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
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
sFileNamestring
OnSelectKeyFile(string)
Must be overriden in order to select an existing key file.
protected abstract FinAuthenticateResult OnSelectKeyFile(string sFileName)
Parameters
sFileNamestringThe complete file name including path and file name extension of the key file to be selected by this method.
Returns
Release()
public void Release()
ResetKey(FinContact, FinSecureKey)
public void ResetKey(FinContact aContact, FinSecureKey aKey)
Parameters
aContactFinContactaKeyFinSecureKey
Select(string)
public FinAuthenticateResult Select(string sSecurityMediaID)
Parameters
sSecurityMediaIDstring
Returns
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
sFilenamestringThe 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
nullis returned.
Exceptions
- ArgumentNullException
The parameter sFilename was
null.- ArgumentException
The parameter aFilename was an empty string.
SetCapabilities(FinSecurityMediaCaps)
protected void SetCapabilities(FinSecurityMediaCaps nCapabilities)
Parameters
nCapabilitiesFinSecurityMediaCaps
SetPassphraseFlags(FinSecurityMediaPassphraseFlags)
protected void SetPassphraseFlags(FinSecurityMediaPassphraseFlags nPassphraseFlags)
Parameters
nPassphraseFlagsFinSecurityMediaPassphraseFlags
SetPassphraseMaxLength(int)
protected void SetPassphraseMaxLength(int nPassphraseMaxLength)
Parameters
nPassphraseMaxLengthint
SetPassphraseMinLength(int)
protected void SetPassphraseMinLength(int nPassphraseMinLength)
Parameters
nPassphraseMinLengthint
SignHash(FinContact, FinSecureKey, FinOperationMode, FinHash, byte[])
public byte[] SignHash(FinContact aContact, FinSecureKey aKey, FinOperationMode nOpMode, FinHash nHash, byte[] vbHash)
Parameters
aContactFinContactaKeyFinSecureKeynOpModeFinOperationModenHashFinHashvbHashbyte[]
Returns
- byte[]
StoreContact(int, FinContact)
public void StoreContact(int nContactIndex, FinContact aContact)
Parameters
nContactIndexintaContactFinContact
StoreKey(FinContact, FinSecureKey)
public void StoreKey(FinContact aContact, FinSecureKey aKey)
Parameters
aContactFinContactaKeyFinSecureKey
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
aContactFinContactaKeyFinSecureKeynOpModeFinOperationModenHashFinHashvbHashbyte[]vbSignaturebyte[]