char *buffer = NULL;
long size;
- // generate private, public key
+ /* generate private, public key */
ret = yaca_key_generate(YACA_KEY_TYPE_DH_PRIV, YACA_KEY_LENGTH_2048BIT, &private_key);
if (ret != YACA_ERROR_NONE)
goto exit;
if (ret != YACA_ERROR_NONE)
goto exit;
- // get peer public key from file
- // add helper to read key from file to buffer?
+ /* get peer public key */
+ // TODO: read key from file to buffer can be replaced with read_file() from misc.h
fp = fopen("key.pub", "r");
if (!fp) goto exit;
if (ret != YACA_ERROR_NONE)
goto exit;
- // derive secret
+ /* derive secret */
ret = yaca_key_derive_dh(private_key, peer_key, &secret);
if (ret != YACA_ERROR_NONE)
goto exit;
char *buffer = NULL;
long size;
- // generate private, public key
+ /* generate private, public key */
ret = yaca_key_generate(YACA_KEY_TYPE_EC_PRIV, YACA_KEY_CURVE_P256, &private_key);
if (ret != YACA_ERROR_NONE)
goto exit;
if (ret != YACA_ERROR_NONE)
goto exit;
- // get peer public key from file
+ /* get peer public key */
+ // TODO: read key from file to buffer can be replaced with read_file() from misc.h
fp = fopen("key.pub", "r");
if (fp == NULL)
goto exit;
if (ret != YACA_ERROR_NONE)
goto exit;
- // derive secret
+ /* derive secret */
ret = yaca_key_derive_dh(private_key, peer_key, &secret);
if (ret != YACA_ERROR_NONE)
goto exit;
#include "misc.h"
#include "../src/debug.h"
-// Signature creation and verification using simple API
+/* Signature creation and verification using simple API */
void simple_sign_verify_asym(yaca_key_type_e type, const char *algo)
{
char *signature = NULL;
yaca_key_h prv = YACA_KEY_NULL;
yaca_key_h pub = YACA_KEY_NULL;
- // GENERATE
+ /* GENERATE */
if (yaca_key_generate(type, YACA_KEY_LENGTH_1024BIT, &prv) != YACA_ERROR_NONE)
return;
if (yaca_key_extract_public(prv, &pub) != YACA_ERROR_NONE)
goto exit;
- // SIGN
+ /* SIGN */
if (yaca_simple_calculate_signature(YACA_DIGEST_SHA512,
prv,
lorem4096,
dump_hex(signature, signature_len, "[Simple API] %s Signature of lorem4096:", algo);
- // VERIFY
+ /* VERIFY */
if (yaca_simple_verify_signature(YACA_DIGEST_SHA512,
pub,
lorem4096,
yaca_key_h key = YACA_KEY_NULL;
- // GENERATE
+ /* GENERATE */
if (yaca_key_generate(YACA_KEY_TYPE_SYMMETRIC, YACA_KEY_LENGTH_256BIT, &key) != YACA_ERROR_NONE)
return;
- // SIGN
+ /* SIGN */
if (yaca_simple_calculate_hmac(YACA_DIGEST_SHA512,
key,
lorem4096,
dump_hex(signature1, signature_len, "[Simple API] HMAC Signature of lorem4096:");
- // VERIFY
+ /* VERIFY */
if (yaca_simple_calculate_hmac(YACA_DIGEST_SHA512,
key,
lorem4096,
yaca_key_h key = YACA_KEY_NULL;
- // GENERATE
+ /* GENERATE */
if (yaca_key_generate(YACA_KEY_TYPE_SYMMETRIC, YACA_KEY_LENGTH_256BIT, &key))
return;
- // SIGN
+ /* SIGN */
if (yaca_simple_calculate_cmac(YACA_ENCRYPT_AES,
key,
lorem4096,
dump_hex(signature1, signature_len, "[Simple API] CMAC Signature of lorem4096:");
- // VERIFY
+ /* VERIFY */
if (yaca_simple_calculate_cmac(YACA_ENCRYPT_AES,
key,
lorem4096,
yaca_key_destroy(key);
}
-// Signature creation and verification using advanced API
+/* Signature creation and verification using advanced API */
void sign_verify_asym(yaca_key_type_e type, const char *algo)
{
char *signature = NULL;
yaca_key_h pub = YACA_KEY_NULL;
yaca_padding_e padding = YACA_PADDING_PKCS1_PSS;
- // GENERATE
+ /* GENERATE */
if (yaca_key_generate(type, YACA_KEY_LENGTH_1024BIT, &prv) != YACA_ERROR_NONE)
return;
if (yaca_key_extract_public(prv, &pub) != YACA_ERROR_NONE)
goto exit;
- // SIGN
+ /* SIGN */
if (yaca_sign_initialize(&ctx, YACA_DIGEST_SHA512, prv) != YACA_ERROR_NONE)
goto exit;
dump_hex(signature, signature_len, "[Advanced API] %s Signature of lorem4096:", algo);
- // CLEANUP
+ /* CLEANUP */
yaca_context_destroy(ctx);
ctx = YACA_CONTEXT_NULL;
- // VERIFY
+ /* VERIFY */
if (yaca_verify_initialize(&ctx, YACA_DIGEST_SHA512, pub) != YACA_ERROR_NONE)
goto exit;
yaca_context_h ctx = YACA_CONTEXT_NULL;
yaca_key_h key = YACA_KEY_NULL;
- // GENERATE
+ /* GENERATE */
if (yaca_key_generate(YACA_KEY_TYPE_SYMMETRIC, YACA_KEY_LENGTH_256BIT, &key) != YACA_ERROR_NONE)
return;
- // SIGN
+ /* SIGN */
if (yaca_sign_initialize_hmac(&ctx, YACA_DIGEST_SHA512, key) != YACA_ERROR_NONE)
goto exit;
dump_hex(signature1, signature_len, "[Advanced API] HMAC Signature of lorem4096:");
- // CLEANUP
+ /* CLEANUP */
yaca_context_destroy(ctx);
ctx = YACA_CONTEXT_NULL;
- // VERIFY
+ /* VERIFY */
if (yaca_sign_initialize_hmac(&ctx, YACA_DIGEST_SHA512, key) != YACA_ERROR_NONE)
goto exit;
yaca_context_h ctx = YACA_CONTEXT_NULL;
yaca_key_h key = YACA_KEY_NULL;
- // GENERATE
+ /* GENERATE */
if (yaca_key_generate(YACA_KEY_TYPE_SYMMETRIC, YACA_KEY_LENGTH_256BIT, &key))
return;
- // SIGN
+ /* SIGN */
if (yaca_sign_initialize_cmac(&ctx, YACA_ENCRYPT_AES, key) != YACA_ERROR_NONE)
goto exit;
dump_hex(signature1, signature_len, "[Advanced API] CMAC Signature of lorem4096:");
- // CLEANUP
+ /* CLEANUP */
yaca_context_destroy(ctx);
ctx = YACA_CONTEXT_NULL;
- // VERIFY
+ /* VERIFY */
if (yaca_sign_initialize_cmac(&ctx, YACA_ENCRYPT_AES, key) != YACA_ERROR_NONE)
goto exit;