S2OPC OPCUA Toolkit
|
Defines a cryptographic API to performing hash mechanisms. This module is not required by the OPC UA protocol. It hashes a secret and may be used to authenticate users. More...
#include "sopc_builtintypes.h"
#include "sopc_enums.h"
#include "sopc_mem_alloc.h"
#include "sopc_secret_buffer.h"
Go to the source code of this file.
Typedefs | |
typedef enum SOPC_HashBasedCrypto_Algo | SOPC_HashBasedCrypto_Algo |
Defines the supported algorithms for user authentication. | |
typedef struct SOPC_HashBasedCrypto_Config | SOPC_HashBasedCrypto_Config |
cryptographic structure to configure the algorithm used. | |
Enumerations | |
enum | SOPC_HashBasedCrypto_Algo { SOPC_HashBasedCrypto_PBKDF2_HMAC_SHA256 } |
Defines the supported algorithms for user authentication. More... | |
Functions | |
SOPC_ReturnStatus | SOPC_HashBasedCrypto_Config_Create (SOPC_HashBasedCrypto_Config **cfg) |
Create the internal configuration structure. | |
void | SOPC_HashBasedCrypto_Config_Free (SOPC_HashBasedCrypto_Config *cfg) |
Free the internal configuration. | |
SOPC_ReturnStatus | SOPC_HashBasedCrypto_Config_PBKDF2 (SOPC_HashBasedCrypto_Config *config, const SOPC_ByteString *pSalt, size_t iteration_count, size_t lenOutput) |
Fills the configuration structure for SOPC_HashBasedCrypto_PBKDF2_HMAC_SHA256 algorithm. | |
SOPC_ReturnStatus | SOPC_HashBasedCrypto_Run (const SOPC_HashBasedCrypto_Config *config, const SOPC_ByteString *pSecret, SOPC_ByteString **ppOutput) |
Function that allows to execute a hashing mechanism. | |
Defines a cryptographic API to performing hash mechanisms. This module is not required by the OPC UA protocol. It hashes a secret and may be used to authenticate users.
Supported algorithms:
typedef enum SOPC_HashBasedCrypto_Algo SOPC_HashBasedCrypto_Algo |
Defines the supported algorithms for user authentication.
typedef struct SOPC_HashBasedCrypto_Config SOPC_HashBasedCrypto_Config |
cryptographic structure to configure the algorithm used.
SOPC_ReturnStatus SOPC_HashBasedCrypto_Config_Create | ( | SOPC_HashBasedCrypto_Config ** | cfg | ) |
Create the internal configuration structure.
[out] | cfg | A valid pointer to the newly created structure. You should free it with SOPC_HashBasedCrypto_Config_Free() |
cfg
is NULL ond SOPC_STATUS_OUT_OF_MEMORY when memory allocation failed. void SOPC_HashBasedCrypto_Config_Free | ( | SOPC_HashBasedCrypto_Config * | cfg | ) |
Free the internal configuration.
cfg | A valid pointer to the configuration to freed. |
SOPC_ReturnStatus SOPC_HashBasedCrypto_Config_PBKDF2 | ( | SOPC_HashBasedCrypto_Config * | config, |
const SOPC_ByteString * | pSalt, | ||
size_t | iteration_count, | ||
size_t | lenOutput ) |
Fills the configuration structure for SOPC_HashBasedCrypto_PBKDF2_HMAC_SHA256 algorithm.
config | A valid pointer to the configuration structure. |
pSalt | A valid pointer to a ByteString which contains the salt. |
iteration_count | Desired iteration count (as large as possible). |
lenOutput | Length of output desired. |
SOPC_ReturnStatus SOPC_HashBasedCrypto_Run | ( | const SOPC_HashBasedCrypto_Config * | config, |
const SOPC_ByteString * | pSecret, | ||
SOPC_ByteString ** | ppOutput ) |
Function that allows to execute a hashing mechanism.
config | A valid pointer to the configuration structure. | |
pSecret | A valid pointer to a ByteString which contains the data to hash. | |
[out] | ppOutput | A valid pointer to the newly created ByteString which will contain the generated hash. You should free it. |
config
is configured with SOPC_HashBasedCrypto_PBKDF2_HMAC_SHA256 then length of pSecret
should not exceed 32 bytes because a secret longer than digest size does not protect more, because, HMAC-SHA256 is considered to have 256 bits maximum input entropy.ppOutput
is unspecified when return value is not SOPC_STATUS_OK.config
is checked beforehand by this function.