Class Anonymizer
Inheritance
Namespace: BO4E.Extensions.Encryption
Assembly: BO4E-dotnet.Extensions.Encryption.dll
Syntax
public class Anonymizer : IDisposable
Constructors
| Improve this Doc View SourceAnonymizer(AnonymizerConfiguration)
Declaration
public Anonymizer(AnonymizerConfiguration configuration)
Parameters
Type | Name | Description |
---|---|---|
AnonymizerConfiguration | configuration |
Fields
| Improve this Doc View SourceHASHED_MARKTLOKATION_PREFIX
instead of '5' or '4' marktlokationIds that are a hashed/pseudonymized value do start with this prefix.
Declaration
protected const string HASHED_MARKTLOKATION_PREFIX = null
Field Value
Type | Description |
---|---|
System.String |
HASHED_MESSLOKATION_PREFIX
instead of 'DE' oder another country code messlokationIds that are a hashed/pseudonymized value do start with this prefix.
Declaration
protected const string HASHED_MESSLOKATION_PREFIX = null
Field Value
Type | Description |
---|---|
System.String |
Properties
| Improve this Doc View SourcepublicKeyX509
Declaration
public X509Certificate2 publicKeyX509 { get; set; }
Property Value
Type | Description |
---|---|
X509Certificate2 |
Methods
| Improve this Doc View SourceApplyOperations<T>(BusinessObject)
Apply the configuration set in the constructor to the JObject set in the constructor.
Declaration
public T ApplyOperations<T>(BusinessObject bo)
Parameters
Type | Name | Description |
---|---|---|
BusinessObject | bo |
Returns
Type | Description |
---|---|
T | A modified JObject with the configuration applied. |
Type Parameters
Name | Description |
---|---|
T |
ApplyOperations<T>(JObject)
Declaration
public T ApplyOperations<T>(JObject jobject)
Parameters
Type | Name | Description |
---|---|---|
JObject | jobject |
Returns
Type | Description |
---|---|
T |
Type Parameters
Name | Description |
---|---|
T |
Dispose()
Declaration
public void Dispose()
Finalize()
Declaration
protected void Finalize()
GenerateHashingSalt()
Generates a 32 byte long salt to be used as input for SetHashingSalt(Byte[]).
Declaration
public static byte[] GenerateHashingSalt()
Returns
Type | Description |
---|---|
System.Byte[] | a 32 byte long securely random salt |
HasHashedKey(Energiemenge)
check if an Energiemenge been pseudonymized using HASH. Calls IsHashedKey(String) for LokationsId.
Declaration
public static bool HasHashedKey(Energiemenge em)
Parameters
Type | Name | Description |
---|---|---|
Energiemenge | em | Energiemenge |
Returns
Type | Description |
---|---|
System.Boolean | true if the LokationsId fulfills the requirements of a hashed key |
HasHashedKey(Marktlokation)
check if a Marktlokation has been pseudonymized using HASH. As of 2019 it's impossible for a "real" Marktlokation to fulfill this condition.
Declaration
public static bool HasHashedKey(Marktlokation ma)
Parameters
Type | Name | Description |
---|---|---|
Marktlokation | ma | Marktlokation |
Returns
Type | Description |
---|---|
System.Boolean | true if the |
HasHashedKey(Messlokation)
check if a Messlokation has been pseudonymized using HASH As of 2019 it's impossible for a "real" Messlokation to fulfill this condition.
Declaration
public static bool HasHashedKey(Messlokation me)
Parameters
Type | Name | Description |
---|---|---|
Messlokation | me | Messlokation |
Returns
Type | Description |
---|---|
System.Boolean | true if the MesslokationsId fulfills the requirements of a hashed key |
HashObject(ref Object, Nullable<DataCategory>)
Applies recursive Hashing on input
for all fields of given DataCategory dataCategory
Declaration
protected void HashObject(ref object input, DataCategory? dataCategory = null)
Parameters
Type | Name | Description |
---|---|---|
System.Object | input | object to be hashed (will be modified by reference) |
System.Nullable<DataCategory> | dataCategory | Category of fields to be modified |
HashString(ref String, Nullable<DataCategory>)
Applies hashing on string value
Declaration
protected void HashString(ref string input, DataCategory? dataCategory)
Parameters
Type | Name | Description |
---|---|---|
System.String | input | string that is going to be hashed |
System.Nullable<DataCategory> | dataCategory |
IsHashedKey(String)
Checks if a stright might originate from HASH
Declaration
public static bool IsHashedKey(string key)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | a string, e.g. '54321012345' |
Returns
Type | Description |
---|---|
System.Boolean | true if the |
SetHashingSalt(Byte[])
Set a salt used when hashing values.
Declaration
public void SetHashingSalt(byte[] salt)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | salt | random salt as byte array |
Remarks
Note that the same salt is used multiple times, at least within the same processed JObject! This is a considerable security weakness that allows for attacks, especially when the origin domain is finite (e.g. when ENUM based values are hashed). This design decision was made because handling a separate salt for each hashed field is impractical. Please opt for the ENCRYPT option in case of doubt. The use of a salt is enforced by throwing a ArgumentNullException when trying to hash ENUM based values without having set a salt before.
See Also
| Improve this Doc View SourceSetNewHashingSalt()
passes the result of GenerateHashingSalt() to SetHashingSalt(Byte[])
Declaration
public void SetNewHashingSalt()
SetPrivateKey(AsymmetricKeyParameter)
Set the private key if DECRYPT is used as anonymizing approach.
Declaration
public void SetPrivateKey(AsymmetricKeyParameter privateKey)
Parameters
Type | Name | Description |
---|---|---|
AsymmetricKeyParameter | privateKey | Bouncy Castle compatible private key |
SetPublicKey(X509Certificate2)
Set the receivers public X509 certificate if ENCRYPT is used as anonymizing approach.
Declaration
public void SetPublicKey(X509Certificate2 x509Certificate)
Parameters
Type | Name | Description |
---|---|---|
X509Certificate2 | x509Certificate | X509 certificate |