S2OPC OPCUA Toolkit
Loading...
Searching...
No Matches
sopc_sk_manager.h File Reference

Security Keys Manager: manages local storage of the keys retrieved from the Security Keys Provider for the SKS. More...

#include <stdbool.h>
#include <stdint.h>
#include "sopc_builtintypes.h"
#include "sopc_enums.h"

Go to the source code of this file.

Data Structures

struct  SOPC_SKManager
 

Macros

#define SOPC_SK_MANAGER_CURRENT_TOKEN_ID   0
 
#define SOPC_SK_MANAGER_DEFAULT_KEYLIFETIME   (60 * 60 * 1000)
 
#define SOPC_SK_MANAGER_DEFAULT_INITIAL_SIZE   10
 

Typedefs

typedef struct SOPC_SKManager SOPC_SKManager
 
typedef uint32_t(* SOPC_SKManager_GetSize_Func) (SOPC_SKManager *skm)
 Type of functions to get size of the Security Key Manager.
 
typedef SOPC_ReturnStatus(* SOPC_SKManager_SetKeyLifetime_Func) (SOPC_SKManager *skm, uint32_t KeyLifetime)
 
typedef uint32_t(* SOPC_SKManager_GetAllKeysLifeTime_Func) (SOPC_SKManager *skm)
 
typedef SOPC_ReturnStatus(* SOPC_SKManager_SetSecurityPolicyUri_Func) (SOPC_SKManager *skm, SOPC_String *SecurityPolicyUri)
 
typedef SOPC_ReturnStatus(* SOPC_SKManager_SetKeys_Func) (SOPC_SKManager *skm, SOPC_String *SecurityPolicyUri, uint32_t FirstTokenId, SOPC_ByteString *Keys, uint32_t NbKeys, uint32_t TimeToNextKey, uint32_t KeyLifetime)
 
typedef uint32_t(* SOPC_SKManager_AddKeys_Func) (SOPC_SKManager *skm, SOPC_ByteString *Keys, uint32_t NbToken)
 
typedef SOPC_ReturnStatus(* SOPC_SKManager_GetKeys_Func) (SOPC_SKManager *skm, uint32_t StartingTokenId, uint32_t NbRequestedToken, SOPC_String **SecurityPolicyUri, uint32_t *FirstTokenId, SOPC_ByteString **Keys, uint32_t *NbKeys, uint32_t *TimeToNextKey, uint32_t *KeyLifetime)
 
typedef void(* SOPC_SKManager_Clear_Func) (SOPC_SKManager *skm)
 

Functions

SOPC_SKManagerSOPC_SKManager_Create (void)
 Creates an instance of the default SOPC_SKManager.
 
uint32_t SOPC_SKManager_Size (SOPC_SKManager *skm)
 Gets number of managed Token for a given security group.
 
SOPC_ReturnStatus SOPC_SKManager_SetKeyLifetime (SOPC_SKManager *skm, uint32_t KeyLifetime)
 Sets the keys tokens lifetimes.
 
SOPC_ReturnStatus SOPC_SKManager_SetSecurityPolicyUri (SOPC_SKManager *skm, SOPC_String *SecurityPolicyUri)
 Sets the security policy URI for the security keys tokens.
 
SOPC_ReturnStatus SOPC_SKManager_SetKeys (SOPC_SKManager *skm, SOPC_String *SecurityPolicyUri, uint32_t FirstTokenId, SOPC_ByteString *Keys, uint32_t NbKeys, uint32_t TimeToNextKey, uint32_t KeyLifetime)
 Sets Keys of a Security Keys Manager for a given security group. After this function returns ( no matter the status ), old Keys are forgotten and cannot be accessed anymore using this SKManager. All parameters are copied by this function.
 
uint32_t SOPC_SKManager_AddKeys (SOPC_SKManager *skm, SOPC_ByteString *Keys, uint32_t NbToken)
 Adds Keys to a Security Keys Manager for a given security group. New keys are appended to the end of the list of existing keys. If no keys was managed before calling this function, the first token id is set to 1 and is associated to the first new key. All parameters are copied by this function.
 
SOPC_ReturnStatus SOPC_SKManager_GetKeys (SOPC_SKManager *skm, uint32_t StartingTokenId, uint32_t NbRequestedToken, SOPC_String **SecurityPolicyUri, uint32_t *FirstTokenId, SOPC_ByteString **Keys, uint32_t *NbKeys, uint32_t *TimeToNextKey, uint32_t *KeyLifetime)
 Gets Keys of a Security Keys Manager for a given security group. All returned data are copied by this function. The caller is responsible for deleting these data.
 
uint32_t SOPC_SKManager_GetAllKeysLifeTime (SOPC_SKManager *skm)
 Returns the total remaining lifetime of available keys tokens.
 
void SOPC_SKManager_Clear (SOPC_SKManager *skm)
 Deallocates Security Keys Manager data bytes content.
 

Detailed Description

Security Keys Manager: manages local storage of the keys retrieved from the Security Keys Provider for the SKS.

Note
Keys can be set or appended to previous ones

Macro Definition Documentation

◆ SOPC_SK_MANAGER_CURRENT_TOKEN_ID

#define SOPC_SK_MANAGER_CURRENT_TOKEN_ID   0

◆ SOPC_SK_MANAGER_DEFAULT_KEYLIFETIME

#define SOPC_SK_MANAGER_DEFAULT_KEYLIFETIME   (60 * 60 * 1000)

◆ SOPC_SK_MANAGER_DEFAULT_INITIAL_SIZE

#define SOPC_SK_MANAGER_DEFAULT_INITIAL_SIZE   10

Typedef Documentation

◆ SOPC_SKManager

typedef struct SOPC_SKManager SOPC_SKManager

◆ SOPC_SKManager_GetSize_Func

typedef uint32_t(* SOPC_SKManager_GetSize_Func) (SOPC_SKManager *skm)

Type of functions to get size of the Security Key Manager.

◆ SOPC_SKManager_SetKeyLifetime_Func

typedef SOPC_ReturnStatus(* SOPC_SKManager_SetKeyLifetime_Func) (SOPC_SKManager *skm, uint32_t KeyLifetime)

◆ SOPC_SKManager_GetAllKeysLifeTime_Func

typedef uint32_t(* SOPC_SKManager_GetAllKeysLifeTime_Func) (SOPC_SKManager *skm)

◆ SOPC_SKManager_SetSecurityPolicyUri_Func

typedef SOPC_ReturnStatus(* SOPC_SKManager_SetSecurityPolicyUri_Func) (SOPC_SKManager *skm, SOPC_String *SecurityPolicyUri)

◆ SOPC_SKManager_SetKeys_Func

typedef SOPC_ReturnStatus(* SOPC_SKManager_SetKeys_Func) (SOPC_SKManager *skm, SOPC_String *SecurityPolicyUri, uint32_t FirstTokenId, SOPC_ByteString *Keys, uint32_t NbKeys, uint32_t TimeToNextKey, uint32_t KeyLifetime)

◆ SOPC_SKManager_AddKeys_Func

typedef uint32_t(* SOPC_SKManager_AddKeys_Func) (SOPC_SKManager *skm, SOPC_ByteString *Keys, uint32_t NbToken)

◆ SOPC_SKManager_GetKeys_Func

typedef SOPC_ReturnStatus(* SOPC_SKManager_GetKeys_Func) (SOPC_SKManager *skm, uint32_t StartingTokenId, uint32_t NbRequestedToken, SOPC_String **SecurityPolicyUri, uint32_t *FirstTokenId, SOPC_ByteString **Keys, uint32_t *NbKeys, uint32_t *TimeToNextKey, uint32_t *KeyLifetime)

◆ SOPC_SKManager_Clear_Func

typedef void(* SOPC_SKManager_Clear_Func) (SOPC_SKManager *skm)

Function Documentation

◆ SOPC_SKManager_Create()

SOPC_SKManager * SOPC_SKManager_Create ( void )

Creates an instance of the default SOPC_SKManager.

Returns
a SOPC_SKManager object or NULL if not enough memory

◆ SOPC_SKManager_Size()

uint32_t SOPC_SKManager_Size ( SOPC_SKManager * skm)

Gets number of managed Token for a given security group.

Parameters
skmPointer to Security Keys Manager. Should not be NULL
Returns
The number of Token or 0 if bad parameters

◆ SOPC_SKManager_SetKeyLifetime()

SOPC_ReturnStatus SOPC_SKManager_SetKeyLifetime ( SOPC_SKManager * skm,
uint32_t KeyLifetime )

Sets the keys tokens lifetimes.

Parameters
skmPointer to Security Keys Manager. Should not be NULL
KeyLifetimeThe keys token lifetime before keys token becomes invalid in milliseconds
Returns
SOPC_STATUS_OK if keys tokens lifetime set

◆ SOPC_SKManager_SetSecurityPolicyUri()

SOPC_ReturnStatus SOPC_SKManager_SetSecurityPolicyUri ( SOPC_SKManager * skm,
SOPC_String * SecurityPolicyUri )

Sets the security policy URI for the security keys tokens.

Parameters
skmPointer to Security Keys Manager. Should not be NULL
SecurityPolicyUriThe URI for the set of algorithms and key lengths used to secure the messages
Returns
SOPC_STATUS_OK if security policy URI set

◆ SOPC_SKManager_SetKeys()

SOPC_ReturnStatus SOPC_SKManager_SetKeys ( SOPC_SKManager * skm,
SOPC_String * SecurityPolicyUri,
uint32_t FirstTokenId,
SOPC_ByteString * Keys,
uint32_t NbKeys,
uint32_t TimeToNextKey,
uint32_t KeyLifetime )

Sets Keys of a Security Keys Manager for a given security group. After this function returns ( no matter the status ), old Keys are forgotten and cannot be accessed anymore using this SKManager. All parameters are copied by this function.

Parameters
skmPointer to Security Keys Manager. Should not be NULL
SecurityPolicyUriThe URI for the set of algorithms and key lengths used to secure the messages
FirstTokenIdThe SecurityTokenId of the first key in the array of returned keys.
KeysAn ordered list of keys that are used when the KeyLifetime elapses
NbKeysThe number of keys tokens in Keys array
TimeToNextKeyThe time, in milliseconds, before the CurrentKey is expected to expire
KeyLifetimeThe lifetime of a key in milliseconds
Returns
SOPC_STATUS_OK if keys are set

◆ SOPC_SKManager_AddKeys()

uint32_t SOPC_SKManager_AddKeys ( SOPC_SKManager * skm,
SOPC_ByteString * Keys,
uint32_t NbToken )

Adds Keys to a Security Keys Manager for a given security group. New keys are appended to the end of the list of existing keys. If no keys was managed before calling this function, the first token id is set to 1 and is associated to the first new key. All parameters are copied by this function.

Parameters
skmPointer to Security Keys Manager. Should not be NULL
KeysThe keys data
NbTokenThe number of keys token (set of keys) to add
Returns
number of added elements

◆ SOPC_SKManager_GetKeys()

SOPC_ReturnStatus SOPC_SKManager_GetKeys ( SOPC_SKManager * skm,
uint32_t StartingTokenId,
uint32_t NbRequestedToken,
SOPC_String ** SecurityPolicyUri,
uint32_t * FirstTokenId,
SOPC_ByteString ** Keys,
uint32_t * NbKeys,
uint32_t * TimeToNextKey,
uint32_t * KeyLifetime )

Gets Keys of a Security Keys Manager for a given security group. All returned data are copied by this function. The caller is responsible for deleting these data.

Parameters
skmPointer to Security Keys Manager. Should not be NULL
StartingTokenIdThe current token is requested by passing 0. It can be a SecurityTokenId from the past to get a key valid for previously sent messages
NbRequestedTokenThe number of requested keys tokens which should be returned in the response
SecurityPolicyUriThe URI for the set of algorithms and key lengths used to secure the messages
FirstTokenIdThe SecurityTokenId of the first key in the array of returned keys.
KeysAn ordered list of keys that are used when the KeyLifetime elapses
NbKeysThe number of keys tokens in Keys array
TimeToNextKeyThe time, in milliseconds, before the CurrentKey is expected to expire
KeyLifetimeThe lifetime of a key in milliseconds
Returns
SOPC_STATUS_OK if keys are get

◆ SOPC_SKManager_GetAllKeysLifeTime()

uint32_t SOPC_SKManager_GetAllKeysLifeTime ( SOPC_SKManager * skm)

Returns the total remaining lifetime of available keys tokens.

Parameters
skmPointer to Security Keys Manager. Should not be NULL
Returns
Total remaining lifetime in milliseconds

◆ SOPC_SKManager_Clear()

void SOPC_SKManager_Clear ( SOPC_SKManager * skm)

Deallocates Security Keys Manager data bytes content.

Parameters
skmPointer to Security Keys Manager. Should not be NULL