.NET Based OPC UA Client/Server SDK  3.1.0.500
UnifiedAutomation.UaBase.SecurityUtils Class Reference

Provides various security related functions. More...

Static Public Member Functions

static bool IsWindowStorePath (string storePath)
 Determines whether the store path points to a windows certificate store. More...
 
static ICertificate LoadCertificate (byte[] bytes, bool extractIssuers=false)
 Initializes a certificate with the DER encoded bytes. More...
 
static ICertificate LoadCertificate (byte[] bytes, string password)
 Initializes a certificate with the DER encoded bytes. More...
 
static ICertificate LoadCertificate (System.Security.Cryptography.X509Certificates.X509Certificate2 x509)
 Initializes a certificate with an x509 certificate. More...
 
static ICertificate[] LoadCertificateChain (byte[] bytes)
 Loads any certificate chain which has been appended the certificate in the byte buffer. More...
 
static byte[] GetNonce (int length)
 Returns a new nonce. More...
 
static byte[] Concat (params byte[][] arrays)
 Concatinates a list of byte arrays. More...
 
static byte[] PSHA1 (byte[] secret, string label, byte[] data, int offset, int length)
 Generates a Pseudo random sequence of bits using the P_SHA1 alhorithm. More...
 
static byte[] PSHA256 (byte[] secret, string label, byte[] data, int offset, int length)
 Generates a Pseudo random sequence of bits using the P_SHA1 alhorithm. More...
 
static List< string > ParseDistinguishedName (string name)
 Parses a distingushed name. More...
 
static bool FindStringIgnoreCase (IList< string > strings, string target)
 Checks if the target is in the list. Comparisons ignore case. More...
 
static bool AreDomainsEqual (string domain1, string domain2)
 Checks if the domains are equal. More...
 
static IList< string > GetDomainsFromCertficate (X509Certificate2 certificate)
 Extracts the the DNS names specified in the certificate. More...
 
static ICertificateStore CreateStore (ISecurityProvider provider, string storePath, bool readOnly=false, bool noPrivateKeys=false)
 Creates a new certificate store instance. More...
 
static SignatureData Sign (ISecurityProvider provider, string securityPolicyUri, ICertificate signingCertificate, byte[] dataToSign)
 Creates a signature with the private key of a certificate. More...
 
static bool Verify (ISecurityProvider provider, string securityPolicyUri, ICertificate signingCertificate, byte[] dataToSign, SignatureData signature)
 Verifies a signature with the public key of a certificate. More...
 
static string GetApplicationUriFromCertficate (X509Certificate2 certificate)
 Extracts the the application URI specified in the certificate. More...
 
static bool DoesUrlMatchCertificate (X509Certificate2 certificate, Uri endpointUrl)
 Checks that the domain in the URL provided matches one of the domains in the certificate. More...
 
static bool CompareDistinguishedName (string name1, string name2)
 Compares two distinguished names. More...
 
static bool CompareDistinguishedName (X509Certificate2 certificate, List< string > parsedName)
 Compares two distinguished names. More...
 
static string ChangeSubjectNameDelimiter (string name, char delimiter)
 Changes the delimiter used to seperate fields in a subject name. More...
 
static bool CheckIfProcessHasAdminRights ()
 Checks if the process has admin rights. More...
 
static HashAlgorithm GetHashAlgorithm (ICertificate certificate)
 Gets the hash algorithm for the certificate. More...
 
static ushort GetHashSize (HashAlgorithm algorithm)
 Gets the hash size for the hash algorithm. More...
 
static ushort GetHashSize (ICertificate certificate)
 Gets the hash size for the certificate. More...
 
static PublicKeyAlgorithm GetPublicKeyAlgorithm (ICertificate certificate)
 Gets the public key algorithm for the certificate. More...
 
static ushort GetPublicKeySize (PublicKeyAlgorithm algorithm)
 Gets the key size for the public key algorithm. More...
 
static ushort GetPublicKeySize (ICertificate certificate)
 Gets the key size for the certificate. More...
 
static bool DoesCertificateSupportSecurityPolicy (ICertificate certificate, string securityPolicyUri)
 Checks if the certificate supports the security policy. More...
 

Detailed Description

Provides various security related functions.

Member Function Documentation

static bool UnifiedAutomation.UaBase.SecurityUtils.AreDomainsEqual ( string  domain1,
string  domain2 
)
inlinestatic

Checks if the domains are equal.

Parameters
domain1The first domain to compare.
domain2The second domain to compare.
Returns
True if they are equal.
static string UnifiedAutomation.UaBase.SecurityUtils.ChangeSubjectNameDelimiter ( string  name,
char  delimiter 
)
inlinestatic

Changes the delimiter used to seperate fields in a subject name.

static bool UnifiedAutomation.UaBase.SecurityUtils.CheckIfProcessHasAdminRights ( )
inlinestatic

Checks if the process has admin rights.

static bool UnifiedAutomation.UaBase.SecurityUtils.CompareDistinguishedName ( string  name1,
string  name2 
)
inlinestatic

Compares two distinguished names.

static bool UnifiedAutomation.UaBase.SecurityUtils.CompareDistinguishedName ( X509Certificate2  certificate,
List< string >  parsedName 
)
inlinestatic

Compares two distinguished names.

static byte [] UnifiedAutomation.UaBase.SecurityUtils.Concat ( params byte  arrays[][])
inlinestatic

Concatinates a list of byte arrays.

Parameters
arraysThe arrays.
Returns
The new array.
static ICertificateStore UnifiedAutomation.UaBase.SecurityUtils.CreateStore ( ISecurityProvider  provider,
string  storePath,
bool  readOnly = false,
bool  noPrivateKeys = false 
)
inlinestatic

Creates a new certificate store instance.

Parameters
providerThe security provider.
storePathThe path to the certificate store.
readOnlyTRUE if the store is read only; FALSE otherwise.
noPrivateKeysTRUE if private keys should not be loaded into the store; FALSE otherwise.
Returns
The opened certificate store. Must be disposed by caller.
static bool UnifiedAutomation.UaBase.SecurityUtils.DoesCertificateSupportSecurityPolicy ( ICertificate  certificate,
string  securityPolicyUri 
)
inlinestatic

Checks if the certificate supports the security policy.

Parameters
certificateThe certificate.
securityPolicyUriThe security policy URI.
Returns
TRUE if the certificate supports the policy; FALSE otherwise.
static bool UnifiedAutomation.UaBase.SecurityUtils.DoesUrlMatchCertificate ( X509Certificate2  certificate,
Uri  endpointUrl 
)
inlinestatic

Checks that the domain in the URL provided matches one of the domains in the certificate.

Parameters
certificateThe certificate.
endpointUrlThe endpoint url to verify.
Returns
True if the certificate matches the url.
static bool UnifiedAutomation.UaBase.SecurityUtils.FindStringIgnoreCase ( IList< string >  strings,
string  target 
)
inlinestatic

Checks if the target is in the list. Comparisons ignore case.

static string UnifiedAutomation.UaBase.SecurityUtils.GetApplicationUriFromCertficate ( X509Certificate2  certificate)
inlinestatic

Extracts the the application URI specified in the certificate.

Parameters
certificateThe certificate.
Returns
The application URI.
static IList<string> UnifiedAutomation.UaBase.SecurityUtils.GetDomainsFromCertficate ( X509Certificate2  certificate)
inlinestatic

Extracts the the DNS names specified in the certificate.

Parameters
certificateThe certificate.
Returns
The DNS names.
static HashAlgorithm UnifiedAutomation.UaBase.SecurityUtils.GetHashAlgorithm ( ICertificate  certificate)
inlinestatic

Gets the hash algorithm for the certificate.

Parameters
certificateThe certificate.
Returns
The hash algorithm.
static ushort UnifiedAutomation.UaBase.SecurityUtils.GetHashSize ( HashAlgorithm  algorithm)
inlinestatic

Gets the hash size for the hash algorithm.

Parameters
algorithmThe hash algorithm.
Returns
The hash size.
static ushort UnifiedAutomation.UaBase.SecurityUtils.GetHashSize ( ICertificate  certificate)
inlinestatic

Gets the hash size for the certificate.

Parameters
certificateThe certificate.
Returns
The hash size.
static byte [] UnifiedAutomation.UaBase.SecurityUtils.GetNonce ( int  length)
inlinestatic

Returns a new nonce.

Parameters
lengthThe length of the nonce.
Returns
The new nonce.
static PublicKeyAlgorithm UnifiedAutomation.UaBase.SecurityUtils.GetPublicKeyAlgorithm ( ICertificate  certificate)
inlinestatic

Gets the public key algorithm for the certificate.

Parameters
certificateThe certificate.
Returns
The public key algorithm.
static ushort UnifiedAutomation.UaBase.SecurityUtils.GetPublicKeySize ( PublicKeyAlgorithm  algorithm)
inlinestatic

Gets the key size for the public key algorithm.

Parameters
algorithmThe public key algorithm.
Returns
The key size.
static ushort UnifiedAutomation.UaBase.SecurityUtils.GetPublicKeySize ( ICertificate  certificate)
inlinestatic

Gets the key size for the certificate.

Parameters
certificateThe certificate.
Returns
The key size.
static bool UnifiedAutomation.UaBase.SecurityUtils.IsWindowStorePath ( string  storePath)
inlinestatic

Determines whether the store path points to a windows certificate store.

Parameters
storePathThe store path.

If a storePath starts with

  • LocalMachine\
  • CurrentUser\
  • Service\
  • User\

it is assumed that it is a path to a Windows certificate store.

Returns
true if the store path points to a windows certificate store; otherwise, false.
static ICertificate UnifiedAutomation.UaBase.SecurityUtils.LoadCertificate ( byte[]  bytes,
bool  extractIssuers = false 
)
inlinestatic

Initializes a certificate with the DER encoded bytes.

Parameters
bytesThe DER encoded blob.
extractIssuersTRUE if the issuers should be extracted from the blob.
Returns
The certificate object.
static ICertificate UnifiedAutomation.UaBase.SecurityUtils.LoadCertificate ( byte[]  bytes,
string  password 
)
inlinestatic

Initializes a certificate with the DER encoded bytes.

Parameters
bytesThe bytes.
passwordThe password.
Returns
The certificate object.
static ICertificate UnifiedAutomation.UaBase.SecurityUtils.LoadCertificate ( System.Security.Cryptography.X509Certificates.X509Certificate2  x509)
inlinestatic

Initializes a certificate with an x509 certificate.

Parameters
x509The x509 used to initialize the certificate object.
Returns
The certificate object.
static ICertificate [] UnifiedAutomation.UaBase.SecurityUtils.LoadCertificateChain ( byte[]  bytes)
inlinestatic

Loads any certificate chain which has been appended the certificate in the byte buffer.

Parameters
bytesThe bytes.
Returns
The chain.
static List<string> UnifiedAutomation.UaBase.SecurityUtils.ParseDistinguishedName ( string  name)
inlinestatic

Parses a distingushed name.

static byte [] UnifiedAutomation.UaBase.SecurityUtils.PSHA1 ( byte[]  secret,
string  label,
byte[]  data,
int  offset,
int  length 
)
inlinestatic

Generates a Pseudo random sequence of bits using the P_SHA1 alhorithm.

static byte [] UnifiedAutomation.UaBase.SecurityUtils.PSHA256 ( byte[]  secret,
string  label,
byte[]  data,
int  offset,
int  length 
)
inlinestatic

Generates a Pseudo random sequence of bits using the P_SHA1 alhorithm.

static SignatureData UnifiedAutomation.UaBase.SecurityUtils.Sign ( ISecurityProvider  provider,
string  securityPolicyUri,
ICertificate  signingCertificate,
byte[]  dataToSign 
)
inlinestatic

Creates a signature with the private key of a certificate.

Parameters
providerThe security provider.
securityPolicyUriThe security policy that specifies the cryptography algorithms.
signingCertificateThe certificate used to create the signature (must have a private key).
dataToSignThe data to sign.
Returns
The signature.
static bool UnifiedAutomation.UaBase.SecurityUtils.Verify ( ISecurityProvider  provider,
string  securityPolicyUri,
ICertificate  signingCertificate,
byte[]  dataToSign,
SignatureData  signature 
)
inlinestatic

Verifies a signature with the public key of a certificate.

Parameters
providerThe security provider.
securityPolicyUriThe security policy that specifies the cryptography algorithms.
signingCertificateThe certificate used to create the signature.
dataToSignThe data to sign.
signatureThe signature to verify.
Returns
TRUE if the signature is value; FALSE otherwise.

The documentation for this class was generated from the following file: