Tizen Native API
4.0
|
Provides APIs for encryption and decryption operations.
#include <yaca/yaca_crypto.h>
#include <yaca/yaca_encrypt.h>
#include <yaca/yaca_seal.h>
#include <yaca/yaca_types.h>
#include <yaca/yaca_error.h>
It provides advanced APIs for encryption/decryption operations with symmetric keys and sealing/opening operations with asymmetric keys.
Encrypt API example
#include <stdio.h> #include <yaca_crypto.h> #include <yaca_encrypt.h> #include <yaca_key.h> #include <yaca_error.h> /* include helpers functions and definitions */ #include "misc.h" int main() { int ret; yaca_context_h ctx = YACA_CONTEXT_NULL; yaca_key_h key = YACA_KEY_NULL; yaca_key_h iv = YACA_KEY_NULL; char *encrypted = NULL; char *decrypted = NULL; size_t encrypted_len; size_t decrypted_len; size_t block_len; size_t output_len; size_t written_len; ret = yaca_initialize(); if (ret != YACA_ERROR_NONE) goto exit; printf("Plain data (16 of %zu bytes): %.16s\n", INPUT_DATA_SIZE, INPUT_DATA); /* Key generation */ ret = yaca_key_generate(YACA_KEY_TYPE_SYMMETRIC, YACA_KEY_LENGTH_256BIT, &key); if (ret != YACA_ERROR_NONE) goto exit; /* IV generation */ ret = yaca_key_generate(YACA_KEY_TYPE_IV, YACA_KEY_LENGTH_IV_128BIT, &iv); if (ret != YACA_ERROR_NONE) goto exit; /* Encryption */ { /* Initialize encryption context */ ret = yaca_encrypt_initialize(&ctx, YACA_ENCRYPT_AES, YACA_BCM_CBC, key, iv); if (ret != YACA_ERROR_NONE) goto exit; /* Get output length for the update */ ret = yaca_context_get_output_length(ctx, INPUT_DATA_SIZE, &output_len); if (ret != YACA_ERROR_NONE) goto exit; /* Get output length for the finalize */ ret = yaca_context_get_output_length(ctx, 0, &block_len); if (ret != YACA_ERROR_NONE) goto exit; /* Calculate max output length and allocate memory */ encrypted_len = output_len + block_len; ret = yaca_zalloc(encrypted_len, (void**)&encrypted); if (ret != YACA_ERROR_NONE) goto exit; /* Encrypt data */ ret = yaca_encrypt_update(ctx, INPUT_DATA, INPUT_DATA_SIZE, encrypted, &written_len); if (ret != YACA_ERROR_NONE) goto exit; encrypted_len = written_len; ret = yaca_encrypt_finalize(ctx, encrypted + encrypted_len, &written_len); if (ret != YACA_ERROR_NONE) goto exit; encrypted_len += written_len; /* Resize output buffer */ ret = yaca_realloc(encrypted_len, (void**)&encrypted); if (ret != YACA_ERROR_NONE) goto exit; /* display encrypted data in hexadecimal format */ dump_hex(encrypted, 16, "Encrypted data (16 of %zu bytes): ", encrypted_len); yaca_context_destroy(ctx); ctx = YACA_CONTEXT_NULL; } /* Decryption */ { /* Initialize decryption context */ ret = yaca_decrypt_initialize(&ctx, YACA_ENCRYPT_AES, YACA_BCM_CBC, key, iv); if (ret != YACA_ERROR_NONE) goto exit; /* Get output length for the update */ ret = yaca_context_get_output_length(ctx, encrypted_len, &output_len); if (ret != YACA_ERROR_NONE) goto exit; /* Get output length for the finalize */ ret = yaca_context_get_output_length(ctx, 0, &block_len); if (ret != YACA_ERROR_NONE) goto exit; /* Calculate max output length and allocate memory */ decrypted_len = output_len + block_len; ret = yaca_zalloc(decrypted_len, (void**)&decrypted); if (ret != YACA_ERROR_NONE) goto exit; /* Decrypt data */ ret = yaca_decrypt_update(ctx, encrypted, encrypted_len, decrypted, &written_len); if (ret != YACA_ERROR_NONE) goto exit; decrypted_len = written_len; ret = yaca_decrypt_finalize(ctx, decrypted + decrypted_len, &written_len); if (ret != YACA_ERROR_NONE) goto exit; decrypted_len += written_len; /* Resize output buffer */ ret = yaca_realloc(decrypted_len, (void**)&decrypted); if (ret != YACA_ERROR_NONE) goto exit; printf("Decrypted data (16 of %zu bytes): %.16s\n\n", decrypted_len, decrypted); } exit: yaca_free(decrypted); yaca_free(encrypted); yaca_context_destroy(ctx); yaca_key_destroy(iv); yaca_key_destroy(key); yaca_cleanup(); return ret; }
AES GCM encrypt API example
#include <stdio.h> #include <yaca_crypto.h> #include <yaca_encrypt.h> #include <yaca_key.h> #include <yaca_error.h> /* include helpers functions and definitions */ #include "misc.h" int main() { int ret; yaca_context_h ctx = YACA_CONTEXT_NULL; yaca_key_h key = YACA_KEY_NULL; yaca_key_h iv = YACA_KEY_NULL; char *encrypted = NULL; char *decrypted = NULL; size_t encrypted_len; size_t decrypted_len; char *aad = NULL; char *tag = NULL; size_t aad_len = 16; size_t tag_len = 16; size_t block_len; size_t output_len; size_t written_len; ret = yaca_initialize(); if (ret != YACA_ERROR_NONE) goto exit; printf("Plain data (16 of %zu bytes): %.16s\n", INPUT_DATA_SIZE, INPUT_DATA); /* Key generation */ ret = yaca_key_generate(YACA_KEY_TYPE_SYMMETRIC, YACA_KEY_LENGTH_256BIT, &key); if (ret != YACA_ERROR_NONE) goto exit; /* IV generation */ ret = yaca_key_generate(YACA_KEY_TYPE_IV, YACA_KEY_LENGTH_IV_128BIT, &iv); if (ret != YACA_ERROR_NONE) goto exit; /* Additional Authentication Data generation */ ret = yaca_zalloc(aad_len, (void**)&aad); if (ret != YACA_ERROR_NONE) goto exit; ret = yaca_randomize_bytes(aad, aad_len); if (ret != YACA_ERROR_NONE) goto exit; /* Allocate memory for tag */ ret = yaca_zalloc(tag_len, (void**)&tag); if (ret != YACA_ERROR_NONE) goto exit; /* Encryption */ { /* Initialize encryption context */ ret = yaca_encrypt_initialize(&ctx, YACA_ENCRYPT_AES, YACA_BCM_GCM, key, iv); if (ret != YACA_ERROR_NONE) goto exit; /* Get output length for the update */ ret = yaca_context_get_output_length(ctx, INPUT_DATA_SIZE, &output_len); if (ret != YACA_ERROR_NONE) goto exit; /* Get output length for the finalize */ ret = yaca_context_get_output_length(ctx, 0, &block_len); if (ret != YACA_ERROR_NONE) goto exit; /* Calculate max output length and allocate memory */ encrypted_len = output_len + block_len; ret = yaca_zalloc(encrypted_len, (void**)&encrypted); if (ret != YACA_ERROR_NONE) goto exit; /* Provide Additional Authentication Data */ ret = yaca_context_set_property(ctx, YACA_PROPERTY_GCM_AAD, aad, aad_len); if (ret != YACA_ERROR_NONE) goto exit; /* Encrypt data */ ret = yaca_encrypt_update(ctx, INPUT_DATA, INPUT_DATA_SIZE, encrypted, &written_len); if (ret != YACA_ERROR_NONE) goto exit; encrypted_len = written_len; ret = yaca_encrypt_finalize(ctx, encrypted + encrypted_len, &written_len); if (ret != YACA_ERROR_NONE) goto exit; encrypted_len += written_len; /* Resize output buffer */ ret = yaca_realloc(encrypted_len, (void**)&encrypted); if (ret != YACA_ERROR_NONE) goto exit; /* Set the tag length and get the tag */ ret = yaca_context_set_property(ctx, YACA_PROPERTY_GCM_TAG_LEN, &tag_len, sizeof(tag_len)); if (ret != YACA_ERROR_NONE) goto exit; ret = yaca_context_get_property(ctx, YACA_PROPERTY_GCM_TAG, (void**)tag, &tag_len); if (ret != YACA_ERROR_NONE) goto exit; /* display encrypted data in hexadecimal format */ dump_hex(encrypted, 16, "Encrypted data (16 of %zu bytes): ", encrypted_len); yaca_context_destroy(ctx); ctx = YACA_CONTEXT_NULL; } /* Decryption */ { /* Initialize decryption context */ ret = yaca_decrypt_initialize(&ctx, YACA_ENCRYPT_AES, YACA_BCM_GCM, key, iv); if (ret != YACA_ERROR_NONE) goto exit; /* Get output length for the update */ ret = yaca_context_get_output_length(ctx, encrypted_len, &output_len); if (ret != YACA_ERROR_NONE) goto exit; /* Get output length for the finalize */ ret = yaca_context_get_output_length(ctx, 0, &block_len); if (ret != YACA_ERROR_NONE) goto exit; /* Calculate max output length and allocate memory */ decrypted_len = output_len + block_len; ret = yaca_zalloc(decrypted_len, (void**)&decrypted); if (ret != YACA_ERROR_NONE) goto exit; /* Provide Additional Authentication Data */ ret = yaca_context_set_property(ctx, YACA_PROPERTY_GCM_AAD, aad, aad_len); if (ret != YACA_ERROR_NONE) goto exit; /* Decrypt data */ ret = yaca_decrypt_update(ctx, encrypted, encrypted_len, decrypted, &written_len); if (ret != YACA_ERROR_NONE) goto exit; decrypted_len = written_len; /* Set expected tag value before final decryption */ ret = yaca_context_set_property(ctx, YACA_PROPERTY_GCM_TAG, tag, tag_len); if (ret != YACA_ERROR_NONE) goto exit; ret = yaca_decrypt_finalize(ctx, decrypted + decrypted_len, &written_len); if (ret != YACA_ERROR_NONE) goto exit; decrypted_len += written_len; /* Resize output buffer */ ret = yaca_realloc(decrypted_len, (void**)&decrypted); if (ret != YACA_ERROR_NONE) goto exit; printf("Decrypted data (16 of %zu bytes): %.16s\n\n", decrypted_len, decrypted); } exit: yaca_free(decrypted); yaca_free(encrypted); yaca_free(tag); yaca_free(aad); yaca_context_destroy(ctx); yaca_key_destroy(iv); yaca_key_destroy(key); yaca_cleanup(); return ret; }
AES CCM encrypt API example
#include <stdio.h> #include <yaca_crypto.h> #include <yaca_encrypt.h> #include <yaca_key.h> #include <yaca_error.h> /* include helpers functions and definitions */ #include "misc.h" int main() { int ret; yaca_context_h ctx = YACA_CONTEXT_NULL; yaca_key_h key = YACA_KEY_NULL; yaca_key_h iv = YACA_KEY_NULL; char *encrypted = NULL; char *decrypted = NULL; size_t encrypted_len; size_t decrypted_len; char *aad = NULL; char *tag = NULL; size_t aad_len = 16; size_t tag_len = 12; size_t block_len; size_t output_len; size_t written_len; ret = yaca_initialize(); if (ret != YACA_ERROR_NONE) goto exit; printf("Plain data (16 of %zu bytes): %.16s\n", INPUT_DATA_SIZE, INPUT_DATA); /* Key generation */ ret = yaca_key_generate(YACA_KEY_TYPE_SYMMETRIC, YACA_KEY_LENGTH_256BIT, &key); if (ret != YACA_ERROR_NONE) goto exit; /* IV generation */ ret = yaca_key_generate(YACA_KEY_TYPE_IV, YACA_KEY_LENGTH_IV_64BIT, &iv); if (ret != YACA_ERROR_NONE) goto exit; /* Additional Authentication Data generation */ ret = yaca_zalloc(aad_len, (void**)&aad); if (ret != YACA_ERROR_NONE) goto exit; ret = yaca_randomize_bytes(aad, aad_len); if (ret != YACA_ERROR_NONE) goto exit; /* Allocate memory for tag */ ret = yaca_zalloc(tag_len, (void**)&tag); if (ret != YACA_ERROR_NONE) goto exit; /* Encryption */ { /* Initialize encryption context */ ret = yaca_encrypt_initialize(&ctx, YACA_ENCRYPT_AES, YACA_BCM_CCM, key, iv); if (ret != YACA_ERROR_NONE) goto exit; /* Get output length for the update */ ret = yaca_context_get_output_length(ctx, INPUT_DATA_SIZE, &output_len); if (ret != YACA_ERROR_NONE) goto exit; /* Get output length for the finalize */ ret = yaca_context_get_output_length(ctx, 0, &block_len); if (ret != YACA_ERROR_NONE) goto exit; /* Calculate max output length and allocate memory */ encrypted_len = output_len + block_len; ret = yaca_zalloc(encrypted_len, (void**)&encrypted); if (ret != YACA_ERROR_NONE) goto exit; /* Set tag length */ ret = yaca_context_set_property(ctx, YACA_PROPERTY_CCM_TAG_LEN, &tag_len, sizeof(tag_len)); if (ret != YACA_ERROR_NONE) goto exit; /* The total plain text length must be passed (only needed if AAD is passed) */ ret = yaca_encrypt_update(ctx, NULL, INPUT_DATA_SIZE , NULL, &written_len); if (ret != YACA_ERROR_NONE) goto exit; /* Provide Additional Authentication Data */ ret = yaca_context_set_property(ctx, YACA_PROPERTY_CCM_AAD, aad, aad_len); if (ret != YACA_ERROR_NONE) goto exit; /* Encrypt data */ ret = yaca_encrypt_update(ctx, INPUT_DATA, INPUT_DATA_SIZE, encrypted, &written_len); if (ret != YACA_ERROR_NONE) goto exit; encrypted_len = written_len; ret = yaca_encrypt_finalize(ctx, encrypted + encrypted_len, &written_len); if (ret != YACA_ERROR_NONE) goto exit; encrypted_len += written_len; /* Resize output buffer */ ret = yaca_realloc(encrypted_len, (void**)&encrypted); if (ret != YACA_ERROR_NONE) goto exit; /* Get the tag after final encryption */ ret = yaca_context_get_property(ctx, YACA_PROPERTY_CCM_TAG, (void**)tag, &tag_len); if (ret != YACA_ERROR_NONE) goto exit; /* display encrypted data in hexadecimal format */ dump_hex(encrypted, 16, "Encrypted data (16 of %zu bytes): ", encrypted_len); yaca_context_destroy(ctx); ctx = YACA_CONTEXT_NULL; } /* Decryption */ { /* Initialize decryption context */ ret = yaca_decrypt_initialize(&ctx, YACA_ENCRYPT_AES, YACA_BCM_CCM, key, iv); if (ret != YACA_ERROR_NONE) goto exit; /* Get output length for the update */ ret = yaca_context_get_output_length(ctx, encrypted_len, &output_len); if (ret != YACA_ERROR_NONE) goto exit; /* Get output length for the finalize */ ret = yaca_context_get_output_length(ctx, 0, &block_len); if (ret != YACA_ERROR_NONE) goto exit; /* Calculate max output length and allocate memory */ decrypted_len = output_len + block_len; ret = yaca_zalloc(decrypted_len, (void**)&decrypted); if (ret != YACA_ERROR_NONE) goto exit; /* Set expected tag value */ ret = yaca_context_set_property(ctx, YACA_PROPERTY_CCM_TAG, tag, tag_len); if (ret != YACA_ERROR_NONE) goto exit; /* The total encrypted text length must be passed (only needed if AAD is passed) */ ret = yaca_decrypt_update(ctx, NULL, encrypted_len , NULL, &written_len); if (ret != YACA_ERROR_NONE) goto exit; /* Provide Additional Authentication Data */ ret = yaca_context_set_property(ctx, YACA_PROPERTY_CCM_AAD, aad, aad_len); if (ret != YACA_ERROR_NONE) goto exit; /* Decrypt data */ ret = yaca_decrypt_update(ctx, encrypted, encrypted_len, decrypted, &written_len); if (ret != YACA_ERROR_NONE) goto exit; decrypted_len = written_len; ret = yaca_decrypt_finalize(ctx, decrypted + decrypted_len, &written_len); if (ret != YACA_ERROR_NONE) goto exit; decrypted_len += written_len; /* Resize output buffer */ ret = yaca_realloc(decrypted_len, (void**)&decrypted); if (ret != YACA_ERROR_NONE) goto exit; printf("Decrypted data (16 of %zu bytes): %.16s\n\n", decrypted_len, decrypted); } exit: yaca_free(decrypted); yaca_free(encrypted); yaca_free(tag); yaca_free(aad); yaca_context_destroy(ctx); yaca_key_destroy(iv); yaca_key_destroy(key); yaca_cleanup(); return ret; }
Asymmetric Encryption API example
#include <stdio.h> #include <yaca_crypto.h> #include <yaca_seal.h> #include <yaca_key.h> #include <yaca_error.h> /* include helpers functions and definitions */ #include "misc.h" int main() { int ret; yaca_context_h ctx = YACA_CONTEXT_NULL; yaca_key_h rsa_pub = YACA_KEY_NULL; yaca_key_h rsa_priv = YACA_KEY_NULL; yaca_key_h sym_key = YACA_KEY_NULL; yaca_key_h iv = YACA_KEY_NULL; char *encrypted = NULL; char *decrypted = NULL; size_t encrypted_len; size_t decrypted_len; size_t block_len; size_t output_len; size_t written_len; ret = yaca_initialize(); if (ret != YACA_ERROR_NONE) goto exit; printf("Plain data (16 of %zu bytes): %.16s\n", INPUT_DATA_SIZE, INPUT_DATA); /* Generate key pair */ ret = yaca_key_generate(YACA_KEY_TYPE_RSA_PRIV, YACA_KEY_LENGTH_4096BIT, &rsa_priv); if (ret != YACA_ERROR_NONE) goto exit; ret = yaca_key_extract_public(rsa_priv, &rsa_pub); if (ret != YACA_ERROR_NONE) goto exit; /* Encryption */ { /* Initialize encryption context */ ret = yaca_seal_initialize(&ctx, rsa_pub, YACA_ENCRYPT_AES, YACA_BCM_CBC, YACA_KEY_LENGTH_256BIT, &sym_key, &iv); if (ret != YACA_ERROR_NONE) goto exit; /* Get output length for the update */ ret = yaca_context_get_output_length(ctx, INPUT_DATA_SIZE, &output_len); if (ret != YACA_ERROR_NONE) goto exit; /* Get output length for the finalize */ ret = yaca_context_get_output_length(ctx, 0, &block_len); if (ret != YACA_ERROR_NONE) goto exit; /* Calculate max output length and allocate memory */ encrypted_len = output_len + block_len; ret = yaca_zalloc(encrypted_len, (void**)&encrypted); if (ret != YACA_ERROR_NONE) goto exit; /* Encrypt data */ ret = yaca_seal_update(ctx, INPUT_DATA, INPUT_DATA_SIZE, encrypted, &written_len); if (ret != YACA_ERROR_NONE) goto exit; encrypted_len = written_len; ret = yaca_seal_finalize(ctx, encrypted + encrypted_len, &written_len); if (ret != YACA_ERROR_NONE) goto exit; encrypted_len += written_len; /* Resize output buffer */ ret = yaca_realloc(encrypted_len, (void**)&encrypted); if (ret != YACA_ERROR_NONE) goto exit; /* display encrypted data in hexadecimal format */ dump_hex(encrypted, 16, "Encrypted data (16 of %zu bytes): ", encrypted_len); yaca_context_destroy(ctx); ctx = YACA_CONTEXT_NULL; } /* Decryption */ { /* Initialize decryption context */ ret = yaca_open_initialize(&ctx, rsa_priv, YACA_ENCRYPT_AES, YACA_BCM_CBC, YACA_KEY_LENGTH_256BIT, sym_key, iv); if (ret != YACA_ERROR_NONE) goto exit; /* Get output length for the update */ ret = yaca_context_get_output_length(ctx, encrypted_len, &output_len); if (ret != YACA_ERROR_NONE) goto exit; /* Get output length for the finalize */ ret = yaca_context_get_output_length(ctx, 0, &block_len); if (ret != YACA_ERROR_NONE) goto exit; /* Calculate max output length and allocate memory */ decrypted_len = output_len + block_len; ret = yaca_zalloc(decrypted_len, (void**)&decrypted); if (ret != YACA_ERROR_NONE) goto exit; /* Decrypt data */ ret = yaca_open_update(ctx, encrypted, encrypted_len, decrypted, &written_len); if (ret != YACA_ERROR_NONE) goto exit; decrypted_len = written_len; ret = yaca_open_finalize(ctx, decrypted + decrypted_len, &written_len); if (ret != YACA_ERROR_NONE) goto exit; decrypted_len += written_len; /* Resize output buffer */ ret = yaca_realloc(decrypted_len, (void**)&decrypted); if (ret != YACA_ERROR_NONE) goto exit; printf("Decrypted data (16 of %zu bytes): %.16s\n\n", decrypted_len, decrypted); } exit: yaca_free(decrypted); yaca_free(encrypted); yaca_context_destroy(ctx); yaca_key_destroy(sym_key); yaca_key_destroy(iv); yaca_key_destroy(rsa_pub); yaca_key_destroy(rsa_priv); yaca_cleanup(); return ret; }
Functions | |
int | yaca_initialize (void) |
Initializes the library. Must be called before any other crypto function. Should be called once in each thread that uses yaca. | |
void | yaca_cleanup (void) |
Cleans up the library. Must be called before exiting the thread that called yaca_initialize(). | |
int | yaca_malloc (size_t size, void **memory) |
Allocates the memory. | |
int | yaca_zalloc (size_t size, void **memory) |
Allocates the zeroed memory. | |
int | yaca_realloc (size_t size, void **memory) |
Re-allocates the memory. | |
void | yaca_free (void *memory) |
Frees the memory allocated by yaca_malloc(), yaca_zalloc(), yaca_realloc() or one of the cryptographic operations. | |
int | yaca_memcmp (const void *first, const void *second, size_t len) |
Safely compares first len bytes of two buffers. | |
int | yaca_randomize_bytes (char *data, size_t data_len) |
Generates random data. | |
int | yaca_context_set_property (yaca_context_h ctx, yaca_property_e property, const void *value, size_t value_len) |
Sets the non-standard context properties. Can only be called on an initialized context. | |
int | yaca_context_get_property (const yaca_context_h ctx, yaca_property_e property, void **value, size_t *value_len) |
Returns the non-standard context properties. Can only be called on an initialized context. | |
int | yaca_context_get_output_length (const yaca_context_h ctx, size_t input_len, size_t *output_len) |
Returns the minimum required size of the output buffer for a single crypto function call. | |
void | yaca_context_destroy (yaca_context_h ctx) |
Destroys the crypto context. Must be called on all contexts that are no longer used. Passing YACA_CONTEXT_NULL is allowed. | |
int | yaca_encrypt_get_iv_bit_length (yaca_encrypt_algorithm_e algo, yaca_block_cipher_mode_e bcm, size_t key_bit_len, size_t *iv_bit_len) |
Returns the recommended/default length of the Initialization Vector for a given encryption configuration. | |
int | yaca_encrypt_initialize (yaca_context_h *ctx, yaca_encrypt_algorithm_e algo, yaca_block_cipher_mode_e bcm, const yaca_key_h sym_key, const yaca_key_h iv) |
Initializes an encryption context. | |
int | yaca_encrypt_update (yaca_context_h ctx, const char *plaintext, size_t plaintext_len, char *ciphertext, size_t *ciphertext_len) |
Encrypts chunk of the data. | |
int | yaca_encrypt_finalize (yaca_context_h ctx, char *ciphertext, size_t *ciphertext_len) |
Encrypts the final chunk of the data. | |
int | yaca_decrypt_initialize (yaca_context_h *ctx, yaca_encrypt_algorithm_e algo, yaca_block_cipher_mode_e bcm, const yaca_key_h sym_key, const yaca_key_h iv) |
Initializes an decryption context. | |
int | yaca_decrypt_update (yaca_context_h ctx, const char *ciphertext, size_t ciphertext_len, char *plaintext, size_t *plaintext_len) |
Decrypts chunk of the data. | |
int | yaca_decrypt_finalize (yaca_context_h ctx, char *plaintext, size_t *plaintext_len) |
Decrypts the final chunk of the data. | |
int | yaca_seal_initialize (yaca_context_h *ctx, const yaca_key_h pub_key, yaca_encrypt_algorithm_e algo, yaca_block_cipher_mode_e bcm, size_t sym_key_bit_len, yaca_key_h *sym_key, yaca_key_h *iv) |
Initializes an asymmetric encryption context and generates symmetric key and Initialization Vector. | |
int | yaca_seal_update (yaca_context_h ctx, const char *plaintext, size_t plaintext_len, char *ciphertext, size_t *ciphertext_len) |
Encrypts piece of the data. | |
int | yaca_seal_finalize (yaca_context_h ctx, char *ciphertext, size_t *ciphertext_len) |
Encrypts the final piece of the data. | |
int | yaca_open_initialize (yaca_context_h *ctx, const yaca_key_h prv_key, yaca_encrypt_algorithm_e algo, yaca_block_cipher_mode_e bcm, size_t sym_key_bit_len, const yaca_key_h sym_key, const yaca_key_h iv) |
Initializes an asymmetric decryption context. | |
int | yaca_open_update (yaca_context_h ctx, const char *ciphertext, size_t ciphertext_len, char *plaintext, size_t *plaintext_len) |
Decrypts piece of the data. | |
int | yaca_open_finalize (yaca_context_h ctx, char *plaintext, size_t *plaintext_len) |
Decrypts last chunk of sealed message. | |
Typedefs | |
typedef struct yaca_context_s * | yaca_context_h |
The context handle. | |
typedef struct yaca_key_s * | yaca_key_h |
The handle of a key, an Initialization Vector or a key generation parameters. | |
Defines | |
#define | YACA_CONTEXT_NULL ((yaca_context_h) NULL) |
NULL value for the crypto context. | |
#define | YACA_KEY_LENGTH_DH_GENERATOR_2 (YACA_KEYLEN_COMPONENT_TYPE_DH | YACA_KEYLEN_COMPONENT_DH_GEN_2) |
A value indicating generator equal 2 for DH parameters. To be or'ed with safe prime length in bits. Prime length is recommended to be 2048 bits or higher. | |
#define | YACA_KEY_LENGTH_DH_GENERATOR_5 (YACA_KEYLEN_COMPONENT_TYPE_DH | YACA_KEYLEN_COMPONENT_DH_GEN_5) |
A value indicating generator equal 5 for DH parameters. To be or'ed with safe prime length in bits. Prime length is recommended to be 2048 bits or higher. |
#define YACA_CONTEXT_NULL ((yaca_context_h) NULL) |
NULL value for the crypto context.
typedef struct yaca_context_s* yaca_context_h |
The context handle.
typedef struct yaca_key_s* yaca_key_h |
The handle of a key, an Initialization Vector or a key generation parameters.
Enumeration of YACA chaining modes for block ciphers.
YACA_BCM_NONE |
Used when algorithm doesn't support block ciphers modes. Initialization Vector is not used. |
YACA_BCM_ECB |
ECB block cipher mode. Initialization Vector is not used. By default the input data is padded using standard block padding (YACA_PADDING_PKCS7). Padding can be disabled using yaca_context_set_property() and YACA_PROPERTY_PADDING,YACA_PADDING_NONE, then the total length of data passed until *_finalize() MUST be a multiple of block size. YACA_PROPERTY_PADDING can be set at the latest before the *_finalize() call. |
YACA_BCM_CTR |
CTR block cipher mode. 128-bit Initialization Vector for AES, 64-bit for other algorithms is mandatory. |
YACA_BCM_CBC |
CBC block cipher mode. 128-bit Initialization Vector for AES, 64-bit for other algorithms is mandatory. By default the input data is padded using standard block padding (YACA_PADDING_PKCS7). Padding can be disabled using yaca_context_set_property() and YACA_PROPERTY_PADDING, YACA_PADDING_NONE, then the total length of data passed until *_finalize() MUST be a multiple of block size. YACA_PROPERTY_PADDING can be set at the latest before the *_finalize() call. |
YACA_BCM_GCM |
GCM block cipher mode. This is a variable Initialization Vector length mode (recommended 96-bits). Supported properties:
|
YACA_BCM_CFB |
Default CFB block cipher mode. 128-bit Initialization Vector for AES, 64-bit for other algorithms is mandatory. |
YACA_BCM_CFB1 |
1 bit CFB block cipher mode. 128-bit Initialization Vector for AES, 64-bit for other algorithms is mandatory. |
YACA_BCM_CFB8 |
8 bits CFB block cipher mode. 128-bit Initialization Vector for AES, 64-bit for other algorithms is mandatory. |
YACA_BCM_OFB |
OFB block cipher mode. 128-bit Initialization Vector for AES, 64-bit for other algorithms is mandatory. |
YACA_BCM_CCM |
CBC-MAC Mode (AES). This is a variable Initialization Vector length mode. Supported properties:
The total encrypted text length must be passed to yaca_decrypt_update() / yaca_open_update() if AAD is used. |
YACA_BCM_WRAP |
Used with YACA_ENCRYPT_AES or YACA_ENCRYPT_3DES_3TDEA to perform a key wrapping (key material symmetric encryption). Only a single yaca_encrypt_update() / yaca_decrypt_update() is allowed. Usage in yaca_seal_initialize() / yaca_open_finalize() is forbidden. Key used to do the wrapping with YACA_ENCRYPT_AES can be a 128-bit key, a 192-bit key, or a 256-bit key. Key used to do the wrapping with YACA_ENCRYPT_3DES_3TDEA can be a 192-bit DES key only. |
Enumeration of YACA message digest algorithms.
Enumeration of YACA symmetric encryption algorithms.
YACA_ENCRYPT_AES |
AES encryption.
|
YACA_ENCRYPT_UNSAFE_DES |
DES encryption.
|
YACA_ENCRYPT_UNSAFE_3DES_2TDEA |
3DES 2-key encryption.
|
YACA_ENCRYPT_3DES_3TDEA |
3DES 3-key encryption.
|
YACA_ENCRYPT_UNSAFE_RC2 |
RC2 encryption. This is a variable key length cipher.
|
YACA_ENCRYPT_UNSAFE_RC4 |
RC4 encryption. This is a variable key length cipher.
|
YACA_ENCRYPT_CAST5 |
CAST5 encryption. This is a variable key length cipher.
|
enum yaca_error_e |
enum yaca_kdf_e |
Enumeration of YACA key derivation functions.
Enumeration of YACA DH parameters taken from RFC 5114. It's meant to be passed or returned as a key_bit_len param in appropriate functions when dealing with DH and wanting to use RFC 5114 values.
Enumeration of YACA key lengths. It is possible to use arbitrary integer instead, this enum values are placed here to avoid magic numbers.
Enumeration of YACA elliptic curve types with their bit lengths. It's meant to be passed or returned as a key_bit_len param in appropriate functions when dealing with elliptic curves.
Enumeration of YACA key file formats.
enum yaca_key_format_e |
enum yaca_key_type_e |
Enumeration of YACA key types, Initialization Vector is considered as key.
enum yaca_padding_e |
Enumeration of YACA paddings.
YACA_PADDING_NONE |
No padding at all. This method assumes that the input data already has a proper length for a given cryptographic operation (e.g. it has been padded by the client). Suitable for symmetric encrypt/decrypt operations as well as low-level RSA operations. |
YACA_PADDING_X931 |
X9.31 padding. Suitable for RSA sign/verify operation. Not supported in low-level RSA operations. |
YACA_PADDING_PKCS1 |
PKCS #1 v1.5 padding. Suitable for RSA sign/verify and low-level RSA operations. For low-level operations the input must be at least 11 bytes shorter than the key length. |
YACA_PADDING_PKCS1_PSS |
PKCS #1 PSS padding. Suitable for RSA sign/verify operations. Not supported in low-level RSA operations. |
YACA_PADDING_PKCS1_OAEP |
EME-OAEP as defined in PKCS #1 v2.0 with SHA-1, MGF1 and an empty encoding parameter. Suitable for low-level RSA public_encrypt/private_decrypt operations. For low-level operations the input must be at least 42 bytes shorter than the key length. |
YACA_PADDING_PKCS1_SSLV23 |
PKCS #1 v1.5 padding with an SSL-specific modification that denotes that the party is SSL3 capable. It is used for rollback attack detection in SSLv3. If during decryption it turns out that both parties are using YACA_PADDING_PKCS1_SSLV23 (both are communicating using SSL2 and both are SSL3 capable) it is treated as a rollback attack and an error is returned. Suitable for low-level RSA public_encrypt/private_decrypt operations. For low-level operations the input must be at least 11 bytes shorter than the key length. |
YACA_PADDING_PKCS7 |
PKCS #7 padding. Suitable for symmetric encrypt/decrypt operation. |
enum yaca_property_e |
Enumeration of YACA non-standard properties for algorithms.
YACA_PROPERTY_PADDING |
Padding for the encrypt/decrypt or sign/verify operation. Property type is yaca_padding_e. This property can be set at the latest before the *_finalize() call. |
YACA_PROPERTY_GCM_AAD |
GCM Additional Authentication Data. Property type is a buffer (e.g. char*) |
YACA_PROPERTY_GCM_TAG |
GCM Tag. Property type is a buffer (e.g. char*) |
YACA_PROPERTY_GCM_TAG_LEN |
GCM Tag length in bytes. Property type is size_t. |
YACA_PROPERTY_CCM_AAD |
CCM Additional Authentication Data. Property type is a buffer (e.g. char*) |
YACA_PROPERTY_CCM_TAG |
CCM Tag. Property type is a buffer (e.g. char*) |
YACA_PROPERTY_CCM_TAG_LEN |
CCM Tag length in bytes. Property type is size_t. |
YACA_PROPERTY_RC2_EFFECTIVE_KEY_BITS |
RC2 effective key bits, 1-1024, 1 bit resolution. Property type is size_t. |
void yaca_cleanup | ( | void | ) |
Cleans up the library. Must be called before exiting the thread that called yaca_initialize().
void yaca_context_destroy | ( | yaca_context_h | ctx | ) |
Destroys the crypto context. Must be called on all contexts that are no longer used. Passing YACA_CONTEXT_NULL is allowed.
[in,out] | ctx | Crypto context |
int yaca_context_get_output_length | ( | const yaca_context_h | ctx, |
size_t | input_len, | ||
size_t * | output_len | ||
) |
Returns the minimum required size of the output buffer for a single crypto function call.
[in] | ctx | Previously initialized crypto context |
[in] | input_len | Length of the input data to be processed |
[out] | output_len | Required length of the output |
YACA_ERROR_NONE | Successful |
YACA_ERROR_INVALID_PARAMETER | Required parameters have incorrect values (NULL, invalid ctx or too big input_len) |
YACA_ERROR_INTERNAL | Internal error |
int yaca_context_get_property | ( | const yaca_context_h | ctx, |
yaca_property_e | property, | ||
void ** | value, | ||
size_t * | value_len | ||
) |
Returns the non-standard context properties. Can only be called on an initialized context.
[in] | ctx | Previously initialized crypto context |
[in] | property | Property to be read |
[out] | value | Copy of the property value |
[out] | value_len | Length of the property value will be returned here |
YACA_ERROR_NONE | Successful |
YACA_ERROR_INVALID_PARAMETER | Required parameters have incorrect values (NULL, invalid ctx or property) |
YACA_ERROR_OUT_OF_MEMORY | Out of memory error |
YACA_ERROR_INTERNAL | Internal error |
int yaca_context_set_property | ( | yaca_context_h | ctx, |
yaca_property_e | property, | ||
const void * | value, | ||
size_t | value_len | ||
) |
Sets the non-standard context properties. Can only be called on an initialized context.
[in,out] | ctx | Previously initialized crypto context |
[in] | property | Property to be set |
[in] | value | Property value |
[in] | value_len | Length of the property value |
YACA_ERROR_NONE | Successful |
YACA_ERROR_INVALID_PARAMETER | Required parameters have incorrect values (NULL, 0, invalid ctx or property) |
YACA_ERROR_INTERNAL | Internal error |
int yaca_decrypt_finalize | ( | yaca_context_h | ctx, |
char * | plaintext, | ||
size_t * | plaintext_len | ||
) |
Decrypts the final chunk of the data.
[in,out] | ctx | A valid decrypt context |
[out] | plaintext | Final piece of the decrypted data (must be allocated by client, see yaca_context_get_output_length()) |
[out] | plaintext_len | Length of the final piece, actual number of bytes written will be returned here |
YACA_ERROR_NONE | Successful |
YACA_ERROR_INVALID_PARAMETER | Required parameters have incorrect values (NULL, invalid ctx), wrong YACA_PROPERTY_GCM_AAD or wrong YACA_PROPERTY_GCM_TAG was used |
YACA_ERROR_INTERNAL | Internal error |
int yaca_decrypt_initialize | ( | yaca_context_h * | ctx, |
yaca_encrypt_algorithm_e | algo, | ||
yaca_block_cipher_mode_e | bcm, | ||
const yaca_key_h | sym_key, | ||
const yaca_key_h | iv | ||
) |
Initializes an decryption context.
[out] | ctx | Newly created context |
[in] | algo | Encryption algorithm that was used to encrypt the data |
[in] | bcm | Chaining mode that was used to encrypt the data |
[in] | sym_key | Symmetric key that was used to encrypt the data |
[in] | iv | Initialization Vector that was used to encrypt the data |
YACA_ERROR_NONE | Successful |
YACA_ERROR_INVALID_PARAMETER | Required parameters have incorrect values (NULL, invalid algo, bcm, sym_key or iv) |
YACA_ERROR_OUT_OF_MEMORY | Out of memory error |
YACA_ERROR_INTERNAL | Internal error |
int yaca_decrypt_update | ( | yaca_context_h | ctx, |
const char * | ciphertext, | ||
size_t | ciphertext_len, | ||
char * | plaintext, | ||
size_t * | plaintext_len | ||
) |
Decrypts chunk of the data.
[in,out] | ctx | Context created by yaca_decrypt_initialize() |
[in] | ciphertext | Ciphertext to be decrypted |
[in] | ciphertext_len | Length of the ciphertext |
[out] | plaintext | Buffer for the decrypted data (must be allocated by client, see yaca_context_get_output_length()) |
[out] | plaintext_len | Length of the decrypted data, actual number of bytes written will be returned here |
YACA_ERROR_NONE | Successful |
YACA_ERROR_INVALID_PARAMETER | Required parameters have incorrect values (NULL, 0, invalid ctx), wrong YACA_PROPERTY_CCM_AAD or wrong YACA_PROPERTY_CCM_TAG was used |
YACA_ERROR_INTERNAL | Internal error |
int yaca_encrypt_finalize | ( | yaca_context_h | ctx, |
char * | ciphertext, | ||
size_t * | ciphertext_len | ||
) |
Encrypts the final chunk of the data.
[in,out] | ctx | A valid encrypt context |
[out] | ciphertext | Final piece of the encrypted data (must be allocated by client, see yaca_context_get_output_length()) |
[out] | ciphertext_len | Length of the final piece, actual number of bytes written will be returned here |
YACA_ERROR_NONE | Successful |
YACA_ERROR_INVALID_PARAMETER | Required parameters have incorrect values (NULL, invalid ctx) |
YACA_ERROR_INTERNAL | Internal error |
int yaca_encrypt_get_iv_bit_length | ( | yaca_encrypt_algorithm_e | algo, |
yaca_block_cipher_mode_e | bcm, | ||
size_t | key_bit_len, | ||
size_t * | iv_bit_len | ||
) |
Returns the recommended/default length of the Initialization Vector for a given encryption configuration.
[in] | algo | Encryption algorithm |
[in] | bcm | Chain mode |
[in] | key_bit_len | Key length in bits |
[out] | iv_bit_len | Recommended Initialization Vector length in bits |
YACA_ERROR_NONE | Successful |
YACA_ERROR_INVALID_PARAMETER | Required parameters have incorrect values (NULL, invalid algo, bcm or key_bit_len) |
YACA_ERROR_INTERNAL | Internal error |
int yaca_encrypt_initialize | ( | yaca_context_h * | ctx, |
yaca_encrypt_algorithm_e | algo, | ||
yaca_block_cipher_mode_e | bcm, | ||
const yaca_key_h | sym_key, | ||
const yaca_key_h | iv | ||
) |
Initializes an encryption context.
[out] | ctx | Newly created context |
[in] | algo | Encryption algorithm that will be used |
[in] | bcm | Chaining mode that will be used |
[in] | sym_key | Symmetric key that will be used |
[in] | iv | Initialization Vector that will be used |
YACA_ERROR_NONE | Successful |
YACA_ERROR_INVALID_PARAMETER | Required parameters have incorrect values (NULL, invalid algo, bcm, sym_key or iv) |
YACA_ERROR_OUT_OF_MEMORY | Out of memory error |
YACA_ERROR_INTERNAL | Internal error |
int yaca_encrypt_update | ( | yaca_context_h | ctx, |
const char * | plaintext, | ||
size_t | plaintext_len, | ||
char * | ciphertext, | ||
size_t * | ciphertext_len | ||
) |
Encrypts chunk of the data.
[in,out] | ctx | Context created by yaca_encrypt_initialize() |
[in] | plaintext | Plaintext to be encrypted |
[in] | plaintext_len | Length of the plaintext |
[out] | ciphertext | Buffer for the encrypted data (must be allocated by client, see yaca_context_get_output_length()) |
[out] | ciphertext_len | Length of the encrypted data, actual number of bytes written will be returned here |
YACA_ERROR_NONE | Successful |
YACA_ERROR_INVALID_PARAMETER | Required parameters have incorrect values (NULL, 0, invalid ctx) |
YACA_ERROR_INTERNAL | Internal error |
void yaca_free | ( | void * | memory | ) |
Frees the memory allocated by yaca_malloc(), yaca_zalloc(), yaca_realloc() or one of the cryptographic operations.
[in] | memory | Pointer to the memory to be freed |
int yaca_initialize | ( | void | ) |
Initializes the library. Must be called before any other crypto function. Should be called once in each thread that uses yaca.
YACA_ERROR_NONE | Successful |
YACA_ERROR_OUT_OF_MEMORY | Out of memory error |
YACA_ERROR_INTERNAL | Internal error |
int yaca_malloc | ( | size_t | size, |
void ** | memory | ||
) |
Allocates the memory.
[in] | size | Size of the allocation (bytes) |
[out] | memory | Allocated memory |
YACA_ERROR_NONE | Successful |
YACA_ERROR_INVALID_PARAMETER | Required parameters have incorrect values (NULL, 0) |
YACA_ERROR_OUT_OF_MEMORY | Out of memory error |
int yaca_memcmp | ( | const void * | first, |
const void * | second, | ||
size_t | len | ||
) |
Safely compares first len bytes of two buffers.
[in] | first | Pointer to the first buffer |
[in] | second | Pointer to the second buffer |
[in] | len | Length to compare |
YACA_ERROR_NONE | Successful |
YACA_ERROR_INVALID_PARAMETER | Required parameters have incorrect values (NULL, 0) |
YACA_ERROR_DATA_MISMATCH | Buffers are different |
int yaca_open_finalize | ( | yaca_context_h | ctx, |
char * | plaintext, | ||
size_t * | plaintext_len | ||
) |
Decrypts last chunk of sealed message.
[in,out] | ctx | A valid open context |
[out] | plaintext | Final piece of the decrypted data (must be allocated by client, see yaca_context_get_output_length()) |
[out] | plaintext_len | Length of the final piece, actual number of bytes written will be returned here |
YACA_ERROR_NONE | Successful |
YACA_ERROR_INVALID_PARAMETER | Required parameters have incorrect values (NULL, invalid ctx), wrong YACA_PROPERTY_GCM_AAD or wrong YACA_PROPERTY_GCM_TAG was used |
YACA_ERROR_INTERNAL | Internal error |
int yaca_open_initialize | ( | yaca_context_h * | ctx, |
const yaca_key_h | prv_key, | ||
yaca_encrypt_algorithm_e | algo, | ||
yaca_block_cipher_mode_e | bcm, | ||
size_t | sym_key_bit_len, | ||
const yaca_key_h | sym_key, | ||
const yaca_key_h | iv | ||
) |
Initializes an asymmetric decryption context.
[out] | ctx | Newly created context |
[in] | prv_key | Private key, part of the pair that was used for the encryption |
[in] | algo | Symmetric algorithm that was used for the encryption |
[in] | bcm | Block chaining mode for the symmetric algorithm |
[in] | sym_key_bit_len | Symmetric key length (in bits) that was used for the encryption |
[in] | sym_key | Symmetric key, encrypted with the public key, that was used to encrypt the data |
[in] | iv | Initialization Vector that was used for the encryption |
YACA_ERROR_NONE | Successful |
YACA_ERROR_INVALID_PARAMETER | Required parameters have incorrect values (NULL, invalid algo, bcm, sym_key_bit_len, prv_key, sym_key or iv) |
YACA_ERROR_OUT_OF_MEMORY | Out of memory error |
YACA_ERROR_INTERNAL | Internal error |
int yaca_open_update | ( | yaca_context_h | ctx, |
const char * | ciphertext, | ||
size_t | ciphertext_len, | ||
char * | plaintext, | ||
size_t * | plaintext_len | ||
) |
Decrypts piece of the data.
[in,out] | ctx | Context created by yaca_open_initialize() |
[in] | ciphertext | Ciphertext to be decrypted |
[in] | ciphertext_len | Length of the ciphertext |
[out] | plaintext | Buffer for the decrypted data (must be allocated by client, see yaca_context_get_output_length()) |
[out] | plaintext_len | Length of the decrypted data, actual number of bytes written will be returned here |
YACA_ERROR_NONE | Successful |
YACA_ERROR_INVALID_PARAMETER | Required parameters have incorrect values (NULL, 0, invalid ctx), wrong YACA_PROPERTY_CCM_AAD or wrong YACA_PROPERTY_CCM_TAG was used |
YACA_ERROR_INTERNAL | Internal error |
int yaca_randomize_bytes | ( | char * | data, |
size_t | data_len | ||
) |
Generates random data.
[in,out] | data | Pointer to the memory to be randomized |
[in] | data_len | Length of the memory to be randomized |
YACA_ERROR_NONE | Successful |
YACA_ERROR_INVALID_PARAMETER | Required parameters have incorrect values (NULL, 0) |
YACA_ERROR_INTERNAL | Internal error |
int yaca_realloc | ( | size_t | size, |
void ** | memory | ||
) |
Re-allocates the memory.
[in] | size | Size of the new allocation (bytes) |
[in,out] | memory | Memory to be reallocated |
YACA_ERROR_NONE | Successful |
YACA_ERROR_INVALID_PARAMETER | Required parameters have incorrect values (NULL, 0) |
YACA_ERROR_OUT_OF_MEMORY | Out of memory error |
int yaca_seal_finalize | ( | yaca_context_h | ctx, |
char * | ciphertext, | ||
size_t * | ciphertext_len | ||
) |
Encrypts the final piece of the data.
[in,out] | ctx | A valid seal context |
[out] | ciphertext | Final piece of the encrypted data (must be allocated by client, see yaca_context_get_output_length()) |
[out] | ciphertext_len | Length of the final piece, actual number of bytes written will be returned here |
YACA_ERROR_NONE | Successful |
YACA_ERROR_INVALID_PARAMETER | Required parameters have incorrect values (NULL, invalid ctx) |
YACA_ERROR_INTERNAL | Internal error |
int yaca_seal_initialize | ( | yaca_context_h * | ctx, |
const yaca_key_h | pub_key, | ||
yaca_encrypt_algorithm_e | algo, | ||
yaca_block_cipher_mode_e | bcm, | ||
size_t | sym_key_bit_len, | ||
yaca_key_h * | sym_key, | ||
yaca_key_h * | iv | ||
) |
Initializes an asymmetric encryption context and generates symmetric key and Initialization Vector.
[out] | ctx | Newly created context |
[in] | pub_key | Public key of the peer that will receive the encrypted data |
[in] | algo | Symmetric algorithm that will be used |
[in] | bcm | Block chaining mode for the symmetric algorithm |
[in] | sym_key_bit_len | Symmetric key length (in bits) that will be generated |
[out] | sym_key | Generated symmetric key that will be used, it is encrypted with peer's public key |
[out] | iv | Generated Initialization Vector that will be used |
YACA_ERROR_NONE | Successful |
YACA_ERROR_INVALID_PARAMETER | Required parameters have incorrect values (NULL, invalid algo, bcm, sym_key_bit_len or pub_key) |
YACA_ERROR_OUT_OF_MEMORY | Out of memory error |
YACA_ERROR_INTERNAL | Internal error |
int yaca_seal_update | ( | yaca_context_h | ctx, |
const char * | plaintext, | ||
size_t | plaintext_len, | ||
char * | ciphertext, | ||
size_t * | ciphertext_len | ||
) |
Encrypts piece of the data.
[in,out] | ctx | Context created by yaca_seal_initialize() |
[in] | plaintext | Plaintext to be encrypted |
[in] | plaintext_len | Length of the plaintext |
[out] | ciphertext | Buffer for the encrypted data (must be allocated by client, see yaca_context_get_output_length()) |
[out] | ciphertext_len | Length of the encrypted data, actual number of bytes written will be returned here |
YACA_ERROR_NONE | Successful |
YACA_ERROR_INVALID_PARAMETER | Required parameters have incorrect values (NULL, 0, invalid ctx) |
YACA_ERROR_INTERNAL | Internal error |
int yaca_zalloc | ( | size_t | size, |
void ** | memory | ||
) |
Allocates the zeroed memory.
[in] | size | Size of the allocation (bytes) |
[out] | memory | Allocated memory |
YACA_ERROR_NONE | Successful |
YACA_ERROR_INVALID_PARAMETER | Required parameters have incorrect values (NULL, 0) |
YACA_ERROR_OUT_OF_MEMORY | Out of memory error |