SIAP: Secure Infrastructure Access Protocol 1.0.0.0a (A1)
A post-quantum secure user verification system and access control mechanism
server.h File Reference

SIAP Server functions. More...

#include "siap.h"

Go to the source code of this file.

Functions

SIAP_EXPORT_API siap_errors siap_server_authenticate_device (uint8_t *dtok, siap_device_key *dkey, siap_device_tag *dtag, const siap_server_key *skey, const uint8_t *phash)
 Authenticate a device. This function hashes a passphrase, decrypts a device keys token-tree, gets the next authentication token, generates a server token, and authenticates the device.
SIAP_EXPORT_API bool siap_server_decrypt_device_key (siap_device_key *dkey, const siap_server_key *skey, const uint8_t *phash)
 Decrypt a device key. This function decrypts a device keys token-tree.
SIAP_EXPORT_API void siap_server_encrypt_device_key (siap_device_key *dkey, const siap_server_key *skey, const uint8_t *phash)
 Encrypt a device key. This function encrypts a device keys token-tree.
SIAP_EXPORT_API bool siap_server_extract_authentication_token (uint8_t *token, siap_device_key *dkey, const siap_server_key *skey)
 Extract an authentication token. This function extracts an authentication token and erases it on the tree.
SIAP_EXPORT_API bool siap_server_generate_authentication_token (uint8_t *token, const siap_device_tag *dtag, const siap_server_key *skey)
 Generate an authentication token that matches the device tags token index. This function generates an authentication token using the server key and the device tag.
SIAP_EXPORT_API void siap_server_generate_device_key (siap_device_key *dkey, const siap_server_key *skey, const uint8_t *did)
 Generate a device key. This function generates a new SIAP device key using the provided server key. It derives the device key from the server key and sets the key identity and expiration time.
SIAP_EXPORT_API void siap_server_generate_device_tag (siap_device_tag *dtag, const siap_device_key *dkey, const uint8_t *phash)
 Generate a device tag. This function generates a new SIAP device tag structure. It populates the provided device tag structure with the device key identity array and a hash of the device key..
SIAP_EXPORT_API bool siap_server_generate_server_key (siap_server_key *skey, const uint8_t *sid)
 Generate a server key-set. This function generates a new SIAP server key-set based on the provided master key. It populates the server key structure with a derived server key and sets the key identity and expiration time.
SIAP_EXPORT_API void siap_server_passphrase_generate (char *passphrase, size_t length)
 Generate a readable pseudo-random passphrase.
SIAP_EXPORT_API void siap_server_passphrase_hash_generate (uint8_t *phash, const char *passphrase, size_t passlen)
 Generate the passphrase hash.
SIAP_EXPORT_API bool siap_server_passphrase_hash_verify (const uint8_t *phash, const char *passphrase, size_t passlen)
 Verify a passphrase against the hash.
SIAP_EXPORT_API bool siap_server_verify_device_tag (siap_device_tag *dtag, const siap_device_key *dkey)
 Hash the key tree and compare it with the value stored in the device tag.

Detailed Description

SIAP Server functions.

Function Documentation

◆ siap_server_authenticate_device()

SIAP_EXPORT_API siap_errors siap_server_authenticate_device ( uint8_t * dtok,
siap_device_key * dkey,
siap_device_tag * dtag,
const siap_server_key * skey,
const uint8_t * phash )

Authenticate a device. This function hashes a passphrase, decrypts a device keys token-tree, gets the next authentication token, generates a server token, and authenticates the device.

Parameters
dtokThe pointer to the output device token.
dkeyThe pointer to the device key.
dtagThe pointer to the device tag.
skey[const] The input server derivation key.
phash[const] The user passphrase hash.

◆ siap_server_decrypt_device_key()

SIAP_EXPORT_API bool siap_server_decrypt_device_key ( siap_device_key * dkey,
const siap_server_key * skey,
const uint8_t * phash )

Decrypt a device key. This function decrypts a device keys token-tree.

Parameters
dkeyThe pointer to the output device key.
skey[const] The input server derivation key.
phash[const] The passphrase hash.

◆ siap_server_encrypt_device_key()

SIAP_EXPORT_API void siap_server_encrypt_device_key ( siap_device_key * dkey,
const siap_server_key * skey,
const uint8_t * phash )

Encrypt a device key. This function encrypts a device keys token-tree.

Parameters
dkeyThe pointer to the output device key.
skey[const] The input server derivation key.
phash[const] The passphrase hash.

◆ siap_server_extract_authentication_token()

SIAP_EXPORT_API bool siap_server_extract_authentication_token ( uint8_t * token,
siap_device_key * dkey,
const siap_server_key * skey )

Extract an authentication token. This function extracts an authentication token and erases it on the tree.

Parameters
tokenThe output authentication token.
dkeyThe pointer to the output device key.
skey[const] The input server derivation key.

◆ siap_server_generate_authentication_token()

SIAP_EXPORT_API bool siap_server_generate_authentication_token ( uint8_t * token,
const siap_device_tag * dtag,
const siap_server_key * skey )

Generate an authentication token that matches the device tags token index. This function generates an authentication token using the server key and the device tag.

Parameters
tokenThe output authentication token.
dtag[const] The input device tag.
skey[const] A pointer to the server key structure.

◆ siap_server_generate_device_key()

SIAP_EXPORT_API void siap_server_generate_device_key ( siap_device_key * dkey,
const siap_server_key * skey,
const uint8_t * did )

Generate a device key. This function generates a new SIAP device key using the provided server key. It derives the device key from the server key and sets the key identity and expiration time.

Parameters
dkeyA pointer to the SIAP device key structure.
skey[const] A pointer to the SIAP server key structure.
did[const] The key identity array.

◆ siap_server_generate_device_tag()

SIAP_EXPORT_API void siap_server_generate_device_tag ( siap_device_tag * dtag,
const siap_device_key * dkey,
const uint8_t * phash )

Generate a device tag. This function generates a new SIAP device tag structure. It populates the provided device tag structure with the device key identity array and a hash of the device key..

Parameters
dtagA pointer to the SIAP device tag structure.
dkey[const] A pointer to the device key.
phashA pointer to the passphrase hash.

◆ siap_server_generate_server_key()

SIAP_EXPORT_API bool siap_server_generate_server_key ( siap_server_key * skey,
const uint8_t * sid )

Generate a server key-set. This function generates a new SIAP server key-set based on the provided master key. It populates the server key structure with a derived server key and sets the key identity and expiration time.

Parameters
skeyA pointer to the SIAP server key structure.
sid[const] The key identity array.
Returns
Returns false if the random generator fails; otherwise, returns true.

◆ siap_server_passphrase_generate()

SIAP_EXPORT_API void siap_server_passphrase_generate ( char * passphrase,
size_t length )

Generate a readable pseudo-random passphrase.

Parameters
passphraseA pointer to the passphrase array.
lengthThe passphrase length.

◆ siap_server_passphrase_hash_generate()

SIAP_EXPORT_API void siap_server_passphrase_hash_generate ( uint8_t * phash,
const char * passphrase,
size_t passlen )

Generate the passphrase hash.

Parameters
phashA pointer to the passphrase hash.
passphrase[const] A pointer to the passphrase.
passlenThe passphrase length.

◆ siap_server_passphrase_hash_verify()

SIAP_EXPORT_API bool siap_server_passphrase_hash_verify ( const uint8_t * phash,
const char * passphrase,
size_t passlen )

Verify a passphrase against the hash.

Parameters
phash[const] A pointer to the passphrase hash.
passphrase[const] A pointer to the passphrase.
passlenThe passphrase length.
Returns
Returns true if the passphrase hash matches.

◆ siap_server_verify_device_tag()

SIAP_EXPORT_API bool siap_server_verify_device_tag ( siap_device_tag * dtag,
const siap_device_key * dkey )

Hash the key tree and compare it with the value stored in the device tag.

Parameters
dtagA pointer to the SIAP device tag structure.
dkey[const] A pointer to the device key.
Returns
Returns true if the tag hash matches.