Class FinSecurityMediaVoid
Implements a RDH security media that simply stores the secret keys in the associated FinContact instance.
public class FinSecurityMediaVoid : IFinSecurityMedia
- Inheritance
-
FinSecurityMediaVoid
- Implements
- Inherited Members
Remarks
In order to maintain strong security the key data is thoroughly encrypted before it is stored in the FinContact. The encryption is done based on the given passphrase. The SecurityMediaID is used to store a hash value of the passphrase for quick verification.
Constructors
FinSecurityMediaVoid(FinContact)
Special constructor only.
public FinSecurityMediaVoid(FinContact aContact)
Parameters
aContactFinContactThe FinContact where all data of this security media implementation is stored.
Remarks
Constructs an instance that uses the given FinContact to store all its data. The given FinContact instance must be the same as the one which is passed to the other methods of this class which have a FinContact parameter.
This class does not provide a default contructor and therefore cannot be created like other security media implementations. Whevever a FinContact indicates that it uses the FinSecurityMediaType.Void the FinContact will use this special constructor passing itself as the parameter
Exceptions
- ArgumentNullException
The parameter aContact was
null.
Properties
Capabilities
Provides the capabilities of this implementation.
public FinSecurityMediaCaps Capabilities { get; }
Property Value
ContactCapacity
Always 1.
public int ContactCapacity { get; }
Property Value
MaxKeyLength
public int MaxKeyLength { get; }
Property Value
PassphraseFlags
Provides the attributes of the passphrase.
public FinSecurityMediaPassphraseFlags PassphraseFlags { get; }
Property Value
PassphraseMaxLength
Provides the maximum length that is acceptable for a passphrase for this security media implementation.
public int PassphraseMaxLength { get; }
Property Value
PassphraseMinLength
Provides the minimum length that is acceptable for a passphrase for this security media implementation.
public int PassphraseMinLength { get; }
Property Value
SecurityMediaID
The currently selected security media ID.
public string SecurityMediaID { get; }
Property Value
- string
If the instance is in the Null state, then this property will be
null. Otherwise the value is simply the security media ID that was given to Select(string).
SecurityMediaType
Always returns Void.
public FinSecurityMediaType SecurityMediaType { get; }
Property Value
SecurityProfiles
public FinSecurityProfile[] SecurityProfiles { get; }
Property Value
State
The current state of this security media instance.
public FinSecurityMediaState State { get; }
Property Value
Methods
Authenticate(string, string)
Authenticates the passphrase and switches into the Authenticated State.
public FinAuthenticateResult Authenticate(string sUserName, string sPassphrase)
Parameters
Returns
- FinAuthenticateResult
If the parameter sPassphrase was
null, or the passphrase did not match the PassphraseMinLength or PassphraseMaxLength, then BadPassphrase is returned.If the passphrase was wrong, then WrongPassphrase is returned. There is no limit on the number of attempts.
If the passphrase was correct, then Success is returned and the instance switches into the Authenticated State.
Exceptions
- InvalidOperationException
The current State was neither Selected nor Authenticated.
AuthenticateAdmin(string, string)
Not supported.
public FinAuthenticateResult AuthenticateAdmin(string sUserName, string sAdminPassphrase)
Parameters
Returns
Exceptions
- NotSupportedException
This exception is always thrown when this method is called.
AuthenticateSecure()
Not supported.
public FinAuthenticateResult AuthenticateSecure()
Returns
- FinAuthenticateResult
Always returns AuthenticateSecureNotSupported.
CanAuthenticateSecure()
public bool CanAuthenticateSecure()
Returns
CanChangePassphraseSecure()
public bool CanChangePassphraseSecure()
Returns
Cancel()
Cancels the Authenticated state and returns into the Selected state.
public void Cancel()
Exceptions
- InvalidOperationException
The current State was neither Selected nor Authenticated.
ChangePassphrase(string, string, string)
Change the passphrase and switch into the Authenticated State.
public FinAuthenticateResult ChangePassphrase(string sUserName, string sOldPassphrase, string sNewPassphrase)
Parameters
sUserNamestringIs completely ignored.
sOldPassphrasestringThe current passphrase is needed for a successful authentication.
sNewPassphrasestringThis will become the new passphrase that is assigned to this instance.
Returns
Remarks
If one of the passphrase parameters was null, or a passphrase did not
match the PassphraseMinLength or PassphraseMaxLength,
then BadPassphrase is returned.
Exceptions
ChangePassphraseSecure()
Not supported.
public FinAuthenticateResult ChangePassphraseSecure()
Returns
- FinAuthenticateResult
Always returns AuthenticateSecureNotSupported.
Create(string, string, string)
Creates an all new security media and switch directly into the Authenticated State.
public void Create(string sSecurityMediaID, string sUserName, string sPassphrase)
Parameters
sSecurityMediaIDstringAs the implementation of this class does not use an external key file in order to store the secret keys, this parameter is largely ignored. However, whatever string will be passed here is stored in the SecurityMediaID property.
sUserNamestringIs completely ignored.
sPassphrasestringThe new passphrase that shall be used to protect the secret key data which will be stored in the associated contact.
Exceptions
- ArgumentNullException
The parameter sPassphrase was
null.- ArgumentException
The parameter sPassphrase did not match the required PassphraseMinLength or PassphraseMaxLength.
- InvalidOperationException
CreateContact()
Not supported!
public FinContact CreateContact()
Returns
Decrypt(FinContact, FinSecureKey, FinOperationMode, byte[])
public byte[] Decrypt(FinContact aContact, FinSecureKey aKey, FinOperationMode nOpMode, byte[] vbCrypt)
Parameters
aContactFinContactThe contact for which to compute the signature. This must be the same as the FinContact instance that was passed to the constructor.
aKeyFinSecureKeynOpModeFinOperationModevbCryptbyte[]
Returns
- byte[]
Exceptions
- ArgumentNullException
One of the parameters aContact, aKey, or vbCrypt was
null.- InvalidOperationException
The given aContact was not the same instance as the FinContact that was passed to the constructor; or the current State was not Authenticated.
ElevateKey(FinContact, FinSecureKey, FinSecureKeyState)
public void ElevateKey(FinContact aContact, FinSecureKey aKey, FinSecureKeyState nNewKeyState)
Parameters
aContactFinContactThe contact for which to retrieve the key. This must be the same as the FinContact instance that was passed to the constructor.
aKeyFinSecureKeynNewKeyStateFinSecureKeyState
Exceptions
- ArgumentNullException
The parameter aContact or aKey was
null.- ArgumentException
The type of the given keys was none of the supported user key types.
- InvalidOperationException
The given aContact was not the same instance as the FinContact that was passed to the constructor; or the current State was not Authenticated; or the new key state was less than the current key state of the key.
Encrypt(FinContact, FinSecureKey, FinOperationMode, byte[])
Not supported.
public byte[] Encrypt(FinContact aContact, FinSecureKey aKey, FinOperationMode nOpMode, byte[] vbData)
Parameters
aContactFinContactaKeyFinSecureKeynOpModeFinOperationModevbDatabyte[]
Returns
- byte[]
Returns always
null.
EraseContact(int)
Not supported!
public void EraseContact(int nContactIndex)
Parameters
nContactIndexint
EraseKey(FinContact, FinSecureKey)
public void EraseKey(FinContact aContact, FinSecureKey aKey)
Parameters
aContactFinContactThe contact for which to retrieve the key. This must be the same as the FinContact instance that was passed to the constructor.
aKeyFinSecureKeyThe key to be erased.
Exceptions
- ArgumentNullException
The parameter aContact or aKey was
null.- ArgumentException
The key type was none of the supported user key types.
- InvalidOperationException
The given aContact was not the same instance as the FinContact that was passed to the constructor; or the current State was not Authenticated.
GenerateKey(FinContact, FinSecureKeyType, int, int, int)
Generates a new public/private key pair.
public FinSecureKey GenerateKey(FinContact aContact, FinSecureKeyType nKeyType, int nKeyLength, int nKeyNumber, int nKeyVersion)
Parameters
aContactFinContactThe contact for which to retrieve the key. This must be the same as the FinContact instance that was passed to the constructor.
nKeyTypeFinSecureKeyTypenKeyLengthintnKeyNumberintnKeyVersionint
Returns
Exceptions
- ArgumentNullException
The parameter aContact was
null.- ArgumentOutOfRangeException
The key length, or the key number, or the key version was outside the supported range.
- ArgumentException
The key type was none of the supported user key types.
- InvalidOperationException
The given aContact was not the same instance as the FinContact that was passed to the constructor; or the current State was not Authenticated.
InitPassphrase(string, string)
Not supported.
public FinAuthenticateResult InitPassphrase(string sUserName, string sPassphrase)
Parameters
Returns
Exceptions
- NotSupportedException
This exception is always thrown when this method is called.
ObtainContact(int)
Not supported!
public FinContact ObtainContact(int nContactIndex)
Parameters
nContactIndexint
Returns
ObtainKey(FinContact, FinSecureKeyType, int, int)
Find and obtain reference to crypto key from security media.
public FinSecureKey ObtainKey(FinContact aContact, FinSecureKeyType nKeyType, int nKeyNumber, int nKeyVersion)
Parameters
aContactFinContactThe contact for which to retrieve the key. This must be the same as the FinContact instance that was passed to the constructor.
nKeyTypeFinSecureKeyTypeMust be either UserCipheringKey or UserAuthenticationKey.
nKeyNumberintIs ignored.
nKeyVersionintIs ignored.
Returns
- FinSecureKey
Returns the requested key, or
nullif the key is not available, or the key type is not supported.
Exceptions
- ArgumentNullException
The parameter aContact was
null.- InvalidOperationException
The given aContact was not the same instance as the FinContact that was passed to the constructor; or the current State was not Authenticated.
Release()
Release security media and all its resources and return into the Null state.
public void Release()
ResetKey(FinContact, FinSecureKey)
public void ResetKey(FinContact aContact, FinSecureKey aKey)
Parameters
aContactFinContactThe contact for which to retrieve the key. This must be the same as the FinContact instance that was passed to the constructor.
aKeyFinSecureKey
Exceptions
- ArgumentNullException
The parameter aContact or aKey was
null.- ArgumentException
The type of the given keys was none of the supported user key types.
- InvalidOperationException
The given aContact was not the same instance as the FinContact that was passed to the constructor; or the current State was not Authenticated; or the new key state was less than the current key state of the key.
Select(string)
public FinAuthenticateResult Select(string sSecurityMediaID)
Parameters
sSecurityMediaIDstringThe security media ID to select.
Returns
- FinAuthenticateResult
This implementation never fails and therefore always returns Success.
SignHash(FinContact, FinSecureKey, FinOperationMode, FinHash, byte[])
Compute user signature for given hash value.
public byte[] SignHash(FinContact aContact, FinSecureKey aKey, FinOperationMode nOpMode, FinHash nHash, byte[] vbHash)
Parameters
aContactFinContactThe contact for which to compute the signature. This must be the same as the FinContact instance that was passed to the constructor.
aKeyFinSecureKeynOpModeFinOperationModenHashFinHashvbHashbyte[]
Returns
- byte[]
Exceptions
- ArgumentNullException
One of the parameters aContact, aKey, or vbHash was
null.- InvalidOperationException
The given aContact was not the same instance as the FinContact that was passed to the constructor; or the current State was not Authenticated.
StoreContact(int, FinContact)
Not supported!
public void StoreContact(int nContactIndex, FinContact aContact)
Parameters
nContactIndexintaContactFinContact
StoreKey(FinContact, FinSecureKey)
Stores the given key in this security media.
public void StoreKey(FinContact aContact, FinSecureKey aKey)
Parameters
aContactFinContactThe contact for which to store the key. This must be the same as the FinContact instance that was passed to the constructor.
aKeyFinSecureKeyThe key to be stored. This must be one of the supported user key types.
Remarks
The implementation of this method is very special, and is different from the semantics defined for this method by the IFinSecurityMedia interface. Instead of using this method in order to store bank keys, this implementation supports storing user keys.
The very special nature of this method makes it possible to copy user keys from a key file into this security media.
Exceptions
- ArgumentNullException
The parameter aContact was
null.- ArgumentException
The type of the given key was not one of the supported user key types.
- InvalidOperationException
The given aContact was not the same instance as the FinContact that was passed to the constructor; or the current State was not Authenticated.
Verify(FinContact, FinSecureKey, FinOperationMode, FinHash, byte[], byte[])
Not supported.
public bool Verify(FinContact aContact, FinSecureKey aKey, FinOperationMode nOpMode, FinHash nHash, byte[] vbHash, byte[] vbSignature)
Parameters
aContactFinContactaKeyFinSecureKeynOpModeFinOperationModenHashFinHashvbHashbyte[]vbSignaturebyte[]
Returns
- bool
Returns always
false.