Noise-C
 All Data Structures Files Functions Variables Typedefs Macros Groups Pages
Functions
Key loading and saving API

Functions

int noise_load_certificate_chain_from_buffer (Noise_CertificateChain **chain, NoiseProtobuf *pbuf)
 Loads a certificate chain from a protobuf. More...
 
int noise_load_certificate_chain_from_file (Noise_CertificateChain **chain, const char *filename)
 Loads a certificate chain from a file. More...
 
int noise_load_certificate_from_buffer (Noise_Certificate **cert, NoiseProtobuf *pbuf)
 Loads a certificate from a protobuf. More...
 
int noise_load_certificate_from_file (Noise_Certificate **cert, const char *filename)
 Loads a certificate from a file. More...
 
int noise_load_private_key_from_buffer (Noise_PrivateKey **key, NoiseProtobuf *pbuf, const void *passphrase, size_t passphrase_len)
 Loads a private key from a protobuf. More...
 
int noise_load_private_key_from_file (Noise_PrivateKey **key, const char *filename, const void *passphrase, size_t passphrase_len)
 Loads a private key from a file. More...
 
int noise_save_certificate_chain_to_buffer (const Noise_CertificateChain *chain, NoiseProtobuf *pbuf)
 Saves a certificate chain to a protobuf. More...
 
int noise_save_certificate_chain_to_file (const Noise_CertificateChain *chain, const char *filename)
 Saves a certificate chain to a file. More...
 
int noise_save_certificate_to_buffer (const Noise_Certificate *cert, NoiseProtobuf *pbuf)
 Saves a certificate to a protobuf. More...
 
int noise_save_certificate_to_file (const Noise_Certificate *cert, const char *filename)
 Saves a certificate to a file. More...
 
int noise_save_private_key_to_buffer (const Noise_PrivateKey *key, NoiseProtobuf *pbuf, const void *passphrase, size_t passphrase_len, const char *protect_name)
 Saves a private key in encrypted form to a protobuf. More...
 
int noise_save_private_key_to_file (const Noise_PrivateKey *key, const char *filename, const void *passphrase, size_t passphrase_len, const char *protect_name)
 Saves a private key in encrypted form to a file. More...
 

Detailed Description

Function Documentation

int noise_load_certificate_chain_from_buffer ( Noise_CertificateChain **  chain,
NoiseProtobuf pbuf 
)

Loads a certificate chain from a protobuf.

Parameters
chainVariable that returns the certificate chain if one is loaded.
pbufThe protobuf to load the certificate chain from.
Returns
NOISE_ERROR_NONE on success.
NOISE_ERROR_INVALID_PARAM if chain or pbuf is NULL.
NOISE_ERROR_INVALID_FORMAT if the format of pbuf is not as expected for a certificate or certificate chain.
NOISE_ERROR_NO_MEMORY if there is insufficient memory to load the certificate chain.

The certificate chain is expected to occupy the entire buffer. Trailing unknown data will be rejected as invalid.

If the buffer contains a certificate instead of a full chain, then this function will load the certificate and convert it into a chain containing a single certificate.

See Also
noise_load_certificate_chain_from_file(), noise_save_certificate_chain_to_buffer()

Definition at line 315 of file loader.c.

int noise_load_certificate_chain_from_file ( Noise_CertificateChain **  chain,
const char *  filename 
)

Loads a certificate chain from a file.

Parameters
chainVariable that returns the certificate chain if one is loaded.
filenameThe name of the file to load the certificate chain from.
Returns
NOISE_ERROR_NONE on success.
NOISE_ERROR_INVALID_PARAM if chain or filename is NULL.
NOISE_ERROR_INVALID_FORMAT if the format of filename is not as expected for a certificate or certificate chain.
NOISE_ERROR_NO_MEMORY if there is insufficient memory to load the certificate chain.
NOISE_ERROR_SYSTEM if filename cannot be opened or read, with further information in the system errno variable.

The certificate chain is expected to occupy the entire file. Trailing unknown data will be rejected as invalid.

If the file contains a certificate instead of a full chain, then this function will load the certificate and convert it into a chain containing a single certificate.

See Also
noise_load_certificate_chain_from_file(), noise_save_certificate_chain_to_file()

Definition at line 280 of file loader.c.

int noise_load_certificate_from_buffer ( Noise_Certificate **  cert,
NoiseProtobuf pbuf 
)

Loads a certificate from a protobuf.

Parameters
certVariable that returns the certificate if one is loaded.
pbufThe protobuf to load the certificate from.
Returns
NOISE_ERROR_NONE on success.
NOISE_ERROR_INVALID_PARAM if cert or pbuf is NULL.
NOISE_ERROR_INVALID_FORMAT if the format of pbuf is not as expected for a certificate or certificate chain.
NOISE_ERROR_NO_MEMORY if there is insufficient memory to load the certificate.

The certificate is expected to occupy the entire buffer. Trailing unknown data will be rejected as invalid.

If the buffer contains a certificate chain, then this function will load the first certificate in the chain and discard the rest. No verification will be performed on the certificate even if the remaining certificates in the chain would allow verification.

See Also
noise_load_certificate_from_file(), noise_save_certificate_to_buffer()

Definition at line 214 of file loader.c.

int noise_load_certificate_from_file ( Noise_Certificate **  cert,
const char *  filename 
)

Loads a certificate from a file.

Parameters
certVariable that returns the certificate if one is loaded.
filenameThe name of the file to load the certificate from.
Returns
NOISE_ERROR_NONE on success.
NOISE_ERROR_INVALID_PARAM if cert or filename is NULL.
NOISE_ERROR_INVALID_FORMAT if the format of filename is not as expected for a certificate or certificate chain.
NOISE_ERROR_NO_MEMORY if there is insufficient memory to load the certificate.
NOISE_ERROR_SYSTEM if filename cannot be opened or read, with further information in the system errno variable.

The certificate is expected to occupy the entire file. Trailing unknown data will be rejected as invalid.

If the file contains a certificate chain, then this function will load the first certificate in the chain and discard the rest. No verification will be performed on the certificate even if the remaining certificates in the chain would allow verification.

See Also
noise_load_certificate_from_buffer(), noise_save_certificate_to_file()

Definition at line 179 of file loader.c.

int noise_load_private_key_from_buffer ( Noise_PrivateKey **  key,
NoiseProtobuf pbuf,
const void *  passphrase,
size_t  passphrase_len 
)

Loads a private key from a protobuf.

Parameters
keyVariable that returns the private key if one is loaded.
pbufThe protobuf to load the private key from.
passphrasePoints to the passphrase to use to unlock the private key.
passphrase_lenLength of the passphrase in bytes.
Returns
NOISE_ERROR_NONE on success.
NOISE_ERROR_INVALID_PARAM if key, pbuf, or passphrase is NULL.
NOISE_ERROR_INVALID_FORMAT if the format of pbuf is not as expected for a private key.
NOISE_ERROR_UNKNOWN_NAME if the algorithm that was used to encrypt the private key is unknown.
NOISE_ERROR_MAC_FAILURE if the passphrase is incorrect.
NOISE_ERROR_NO_MEMORY if there is insufficient memory to load the private key.

The private key is expected to occupy the entire buffer. Trailing unknown data will be rejected as invalid.

See Also
noise_load_private_key_from_file(), noise_save_private_key_to_buffer()

Definition at line 451 of file loader.c.

int noise_load_private_key_from_file ( Noise_PrivateKey **  key,
const char *  filename,
const void *  passphrase,
size_t  passphrase_len 
)

Loads a private key from a file.

Parameters
keyVariable that returns the private key if one is loaded.
filenameThe name of the file to load the private key from.
passphrasePoints to the passphrase to use to unlock the private key.
passphrase_lenLength of the passphrase in bytes.
Returns
NOISE_ERROR_NONE on success.
NOISE_ERROR_INVALID_PARAM if key, filename, or passphrase is NULL.
NOISE_ERROR_INVALID_FORMAT if the format of the file is not as expected for a private key.
NOISE_ERROR_UNKNOWN_NAME if the algorithm that was used to encrypt the private key is unknown.
NOISE_ERROR_MAC_FAILURE if the passphrase is incorrect.
NOISE_ERROR_NO_MEMORY if there is insufficient memory to load the private key.
NOISE_ERROR_SYSTEM if filename cannot be opened or read, with further information in the system errno variable.

The private key is expected to occupy the entire buffer. Trailing unknown data will be rejected as invalid.

See Also
noise_load_private_key_from_buffer(), noise_save_private_key_to_file()

Definition at line 376 of file loader.c.

int noise_save_certificate_chain_to_buffer ( const Noise_CertificateChain chain,
NoiseProtobuf pbuf 
)

Saves a certificate chain to a protobuf.

Parameters
chainThe certificate chain to be saved.
pbufThe protobuf to save the certificate chain to.
Returns
NOISE_ERROR_NONE on success.
NOISE_ERROR_INVALID_PARAM if chain or pbuf is NULL.
See Also
noise_save_certificate_chain_to_file(), noise_load_certificate_chain_from_buffer()

Definition at line 697 of file loader.c.

int noise_save_certificate_chain_to_file ( const Noise_CertificateChain chain,
const char *  filename 
)

Saves a certificate chain to a file.

Parameters
chainThe certificate chain to be saved.
filenameThe name of the file to save the certificate chain to.
Returns
NOISE_ERROR_NONE on success.
NOISE_ERROR_INVALID_PARAM if chain or filename is NULL.
NOISE_ERROR_INVALID_LENGTH if the serialized version of the certificate chain is more than NOISE_MAX_PAYLOAD_LEN bytes in length.
NOISE_ERROR_SYSTEM if filename cannot be opened or written, with further information in the system errno variable.
NOISE_ERROR_NO_MEMORY if there is insufficient memory.
See Also
noise_save_certificate_chain_to_buffer(), noise_load_certificate_chain_from_file()

Definition at line 678 of file loader.c.

int noise_save_certificate_to_buffer ( const Noise_Certificate cert,
NoiseProtobuf pbuf 
)

Saves a certificate to a protobuf.

Parameters
certThe certificate to be saved.
pbufThe protobuf to save the certificate to.
Returns
NOISE_ERROR_NONE on success.
NOISE_ERROR_INVALID_PARAM if cert or pbuf is NULL.
See Also
noise_save_certificate_to_file(), noise_load_certificate_from_buffer()

Definition at line 655 of file loader.c.

int noise_save_certificate_to_file ( const Noise_Certificate cert,
const char *  filename 
)

Saves a certificate to a file.

Parameters
certThe certificate to be saved.
filenameThe name of the file to save the certificate to.
Returns
NOISE_ERROR_NONE on success.
NOISE_ERROR_INVALID_PARAM if cert or filename is NULL.
NOISE_ERROR_INVALID_LENGTH if the serialized version of the certificate is more than NOISE_MAX_PAYLOAD_LEN bytes in length.
NOISE_ERROR_SYSTEM if filename cannot be opened or written, with further information in the system errno variable.
NOISE_ERROR_NO_MEMORY if there is insufficient memory.
See Also
noise_save_certificate_to_buffer(), noise_load_certificate_from_file()

Definition at line 637 of file loader.c.

int noise_save_private_key_to_buffer ( const Noise_PrivateKey key,
NoiseProtobuf pbuf,
const void *  passphrase,
size_t  passphrase_len,
const char *  protect_name 
)

Saves a private key in encrypted form to a protobuf.

Parameters
keyThe private key to be saved.
pbufThe protobuf to write the encrypted data to.
passphrasePoints to the passphrase to use to encrypt the private key.
passphrase_lenLength of the passphrase in bytes.
protect_nameThe name of the algorithm to use to protect the private key; e.g. "ChaChaPoly_BLAKE2b_PBKDF2".
Returns
NOISE_ERROR_NONE on success.
NOISE_ERROR_INVALID_PARAM if one of key, pbuf, passphrase, or protect_name is NULL.
NOISE_ERROR_UNKNOWN_NAME if protect_name is unknown.
NOISE_ERROR_INVALID_LENGTH if pbuf is not large enough to contain the encrypted private key data.
NOISE_ERROR_NO_MEMORY if there is insufficient memory to save the encrypted private key data.
See Also
noise_save_private_key_to_file(), noise_load_private_key_from_buffer()

Definition at line 808 of file loader.c.

int noise_save_private_key_to_file ( const Noise_PrivateKey key,
const char *  filename,
const void *  passphrase,
size_t  passphrase_len,
const char *  protect_name 
)

Saves a private key in encrypted form to a file.

Parameters
keyThe private key to be saved.
filenameThe name of the file to save to.
passphrasePoints to the passphrase to use to encrypt the private key.
passphrase_lenLength of the passphrase in bytes.
protect_nameThe name of the algorithm to use to protect the private key; e.g. "ChaChaPoly_BLAKE2b_PBKDF2".
Returns
NOISE_ERROR_NONE on success.
NOISE_ERROR_INVALID_PARAM if one of key, filename, passphrase, or protect_name is NULL.
NOISE_ERROR_INVALID_LENGTH if the total size of the encrypted private key will be larger than NOISE_MAX_PAYLOAD_LEN.
NOISE_ERROR_UNKNOWN_NAME if protect_name is unknown.
NOISE_ERROR_NO_MEMORY if there is insufficient memory to save the encrypted private key data.
NOISE_ERROR_SYSTEM if there was a problem opening or writing to filename, with the specific reason reported in the system errno variable.
See Also
noise_save_private_key_to_buffer(), noise_load_private_key_from_file()

Definition at line 727 of file loader.c.