: null_key();
size_t tag_len = tag.size();
- auto tag_output = create_yaca_buffer(tag_len);
+ char *tag_output;
// encryption
Buffer encrypt_output;
YACA_SUCCESS(yaca_context_set_property(enc_ctx_ptr.get(), YACA_PROPERTY_GCM_TAG_LEN,
(void*)&tag_len, sizeof(tag_len)));
YACA_SUCCESS(yaca_context_get_property(enc_ctx_ptr.get(), YACA_PROPERTY_GCM_TAG,
- (void**)tag_output.get(), &tag_len));
+ (void**)&tag_output, &tag_len));
+ ChrPtr tag_ptr = wrap_ptr(tag_output);
YACA_ASSERT_MSG(output.size() == encrypt_output.size(), "Ciphertext size after encrypt differs\n");
YACA_ASSERT_MSG(output == encrypt_output, "Ciphertext after encrypt differs\n");
YACA_ASSERT_MSG(tag.size() == tag_len, "Tag size after encrypt differs\n");
- YACA_ASSERT_MSG(yaca_memcmp(tag.data(), tag_output.get(), tag_len) == YACA_ERROR_NONE,
+ YACA_ASSERT_MSG(yaca_memcmp(tag.data(), tag_output, tag_len) == YACA_ERROR_NONE,
"Tag after encrypt differs\n");
// decryption
: null_key();
size_t tag_len = tag.size();
- auto tag_output = create_yaca_buffer(tag_len);
+ char *tag_output;
// encryption
Buffer encrypt_output;
encrypt_output.insert(encrypt_output.end(), final_ptr.get(), final_ptr.get() + final_len);
YACA_SUCCESS(yaca_context_get_property(enc_ctx_ptr.get(), YACA_PROPERTY_CCM_TAG,
- (void**)tag_output.get(), &tag_len));
+ (void**)&tag_output, &tag_len));
+ ChrPtr tag_ptr = wrap_ptr(tag_output);
YACA_ASSERT_MSG(output.size() == encrypt_output.size(), "Ciphertext size after encrypt differs \n");
YACA_ASSERT_MSG(output == encrypt_output, "ciphertext after encrypt differs\n");
YACA_ASSERT_MSG(tag.size() == tag_len, "Tag size after encrypt differs\n");
- YACA_ASSERT_MSG(yaca_memcmp(tag.data(), tag_output.get(), tag_len) == YACA_ERROR_NONE,
+ YACA_ASSERT_MSG(yaca_memcmp(tag.data(), tag_output, tag_len) == YACA_ERROR_NONE,
"Tag after encrypt differs\n");
// decryption
{
KeyIvPair key_iv_pair;
size_t tag_len = 14;
- auto tag = create_yaca_buffer(tag_len);
+ char *tag;
auto aad = random_buffer(16);
Buffer encrypt_output;
Buffer decrypt_output;
auto final_ptr = out_buf_alloc(enc_ctx_ptr, 0, final_len);
YACA_INVALID_PARAM(yaca_context_set_property(enc_ctx_ptr.get(), YACA_PROPERTY_GCM_TAG,
- tag.get(), tag_len));
+ tag, tag_len));
YACA_INVALID_PARAM(yaca_context_get_property(enc_ctx_ptr.get(), YACA_PROPERTY_GCM_TAG,
- (void**)tag.get(), &tag_len));
+ (void**)&tag, &tag_len));
YACA_INVALID_PARAM(yaca_context_set_property(enc_ctx_ptr.get(), YACA_PROPERTY_GCM_TAG_LEN,
(void*)&tag_len, sizeof(tag_len)));
YACA_INVALID_PARAM(yaca_context_set_property(enc_ctx_ptr.get(), YACA_PROPERTY_GCM_AAD,
aad.data(), aad.size()));
YACA_INVALID_PARAM(yaca_context_set_property(enc_ctx_ptr.get(), YACA_PROPERTY_GCM_TAG,
- tag.get(), tag_len));
+ tag, tag_len));
YACA_INVALID_PARAM(yaca_context_get_property(enc_ctx_ptr.get(), YACA_PROPERTY_GCM_TAG,
- (void**)tag.get(), &tag_len));
+ (void**)&tag, &tag_len));
YACA_INVALID_PARAM(yaca_context_set_property(enc_ctx_ptr.get(), YACA_PROPERTY_GCM_TAG_LEN,
(void*)&tag_len, sizeof(tag_len)));
YACA_INVALID_PARAM(yaca_context_set_property(enc_ctx_ptr.get(), YACA_PROPERTY_GCM_AAD,
aad.data(), aad.size()));
YACA_INVALID_PARAM(yaca_context_set_property(enc_ctx_ptr.get(), YACA_PROPERTY_GCM_TAG,
- tag.get(), tag_len));
+ tag, tag_len));
YACA_SUCCESS(yaca_context_set_property(enc_ctx_ptr.get(), YACA_PROPERTY_GCM_TAG_LEN,
(void*)&tag_len, sizeof(tag_len)));
YACA_SUCCESS(yaca_context_get_property(enc_ctx_ptr.get(), YACA_PROPERTY_GCM_TAG,
- (void**)tag.get(), &tag_len));
+ (void**)&tag, &tag_len));
+ ChrPtr tag_ptr = wrap_ptr(tag);
+
YACA_INVALID_PARAM(yaca_context_set_property(enc_ctx_ptr.get(), YACA_PROPERTY_GCM_TAG_LEN,
(void*)&tag_len, sizeof(tag_len)));
final_ptr = out_buf_alloc(dec_ctx_ptr, 0, final_len);
YACA_INVALID_PARAM(yaca_context_get_property(dec_ctx_ptr.get(), YACA_PROPERTY_GCM_TAG,
- (void**)tag.get(), &tag_len));
+ (void**)&tag, &tag_len));
YACA_INVALID_PARAM(yaca_context_set_property(dec_ctx_ptr.get(), YACA_PROPERTY_GCM_TAG_LEN,
(void*)&tag_len, sizeof(tag_len)));
YACA_INVALID_PARAM(yaca_context_set_property(dec_ctx_ptr.get(), YACA_PROPERTY_GCM_TAG_LEN,
(void*)&tag_len, sizeof(tag_len)));
YACA_INVALID_PARAM(yaca_context_get_property(dec_ctx_ptr.get(), YACA_PROPERTY_GCM_TAG,
- (void**)tag.get(), &tag_len));
+ (void**)&tag, &tag_len));
YACA_INVALID_PARAM(yaca_context_set_property(dec_ctx_ptr.get(), YACA_PROPERTY_GCM_TAG,
- tag.get(), tag_len + 42));
+ tag, tag_len + 42));
- YACA_SUCCESS(yaca_context_set_property(dec_ctx_ptr.get(), YACA_PROPERTY_GCM_TAG,
- tag.get(), tag_len));
+ YACA_SUCCESS(yaca_context_set_property(dec_ctx_ptr.get(), YACA_PROPERTY_GCM_TAG, tag, tag_len));
YACA_SUCCESS(yaca_decrypt_finalize(dec_ctx_ptr.get(), final_ptr.get(), &final_len));
decrypt_output.insert(decrypt_output.end(), final_ptr.get(), final_ptr.get() + final_len);
YACA_INVALID_PARAM(yaca_context_set_property(dec_ctx_ptr.get(), YACA_PROPERTY_GCM_AAD,
aad.data(), aad.size()));
YACA_INVALID_PARAM(yaca_context_set_property(dec_ctx_ptr.get(), YACA_PROPERTY_GCM_TAG,
- tag.get(), tag_len));
+ tag, tag_len));
YACA_INVALID_PARAM(yaca_context_set_property(dec_ctx_ptr.get(), YACA_PROPERTY_GCM_TAG_LEN,
(void*)&tag_len, sizeof(tag_len)));
YACA_INVALID_PARAM(yaca_context_get_property(dec_ctx_ptr.get(), YACA_PROPERTY_GCM_TAG,
- (void**)tag.get(), &tag_len));
+ (void**)&tag, &tag_len));
YACA_ASSERT_MSG(DATA.size() == decrypt_output.size(), "Size after encrypt-decrypt differs\n");
YACA_ASSERT_MSG(DATA == decrypt_output, "Text after encrypt-decrypt has changed\n");
KeyPtr key = generate_key(YACA_KEY_TYPE_SYMMETRIC, YACA_KEY_LENGTH_256BIT);
KeyPtr iv = generate_key(YACA_KEY_TYPE_IV, YACA_KEY_LENGTH_IV_64BIT);
size_t tag_len = 16;
- auto tag = create_yaca_buffer(tag_len);
+ char *tag;
auto aad = random_buffer(16);
Buffer encrypt_output;
Buffer decrypt_output;
auto final_ptr = out_buf_alloc(enc_ctx_ptr, 0, final_len);
YACA_INVALID_PARAM(yaca_context_set_property(enc_ctx_ptr.get(), YACA_PROPERTY_CCM_TAG,
- tag.get(), tag_len));
+ tag, tag_len));
YACA_INVALID_PARAM(yaca_context_get_property(enc_ctx_ptr.get(), YACA_PROPERTY_CCM_TAG,
- (void**)tag.get(), &tag_len));
+ (void**)&tag, &tag_len));
YACA_SUCCESS(yaca_context_set_property(enc_ctx_ptr.get(), YACA_PROPERTY_CCM_TAG_LEN,
(void*)&tag_len, sizeof(tag_len)));
YACA_INVALID_PARAM(yaca_context_set_property(enc_ctx_ptr.get(), YACA_PROPERTY_CCM_AAD,
aad.data(), aad.size()));
YACA_INVALID_PARAM(yaca_context_set_property(enc_ctx_ptr.get(), YACA_PROPERTY_CCM_TAG,
- tag.get(), tag_len));
+ tag, tag_len));
YACA_INVALID_PARAM(yaca_context_set_property(enc_ctx_ptr.get(), YACA_PROPERTY_CCM_TAG_LEN,
(void*)&tag_len, sizeof(tag_len)));
YACA_INVALID_PARAM(yaca_context_get_property(enc_ctx_ptr.get(), YACA_PROPERTY_CCM_TAG,
- (void**)tag.get(), &tag_len));
+ (void**)&tag, &tag_len));
YACA_SUCCESS(yaca_encrypt_finalize(enc_ctx_ptr.get(), final_ptr.get(), &final_len));
encrypt_output.insert(encrypt_output.end(), final_ptr.get(), final_ptr.get() + final_len);
YACA_INVALID_PARAM(yaca_context_set_property(enc_ctx_ptr.get(), YACA_PROPERTY_CCM_AAD,
aad.data(), aad.size()));
YACA_INVALID_PARAM(yaca_context_set_property(enc_ctx_ptr.get(), YACA_PROPERTY_CCM_TAG,
- tag.get(), tag_len));
+ tag, tag_len));
YACA_INVALID_PARAM(yaca_context_set_property(enc_ctx_ptr.get(), YACA_PROPERTY_CCM_TAG_LEN,
(void*)&tag_len, sizeof(tag_len)));
YACA_SUCCESS(yaca_context_get_property(enc_ctx_ptr.get(), YACA_PROPERTY_CCM_TAG,
- (void**)tag.get(), &tag_len));
+ (void**)&tag, &tag_len));
+ ChrPtr tag_ptr = wrap_ptr(tag);
// decryption
auto dec_ctx_ptr = decrypt_init(YACA_ENCRYPT_AES, YACA_BCM_CCM, key, iv);
YACA_INVALID_PARAM(yaca_context_set_property(dec_ctx_ptr.get(), YACA_PROPERTY_CCM_TAG_LEN,
(void*)&tag_len, sizeof(tag_len)));
YACA_INVALID_PARAM(yaca_context_get_property(dec_ctx_ptr.get(), YACA_PROPERTY_CCM_TAG,
- (void**)tag.get(), &tag_len));
+ (void**)&tag, &tag_len));
YACA_INVALID_PARAM(yaca_context_set_property(dec_ctx_ptr.get(), YACA_PROPERTY_CCM_TAG,
- tag.get(), tag_len + 42));
+ tag, tag_len + 42));
- YACA_SUCCESS(yaca_context_set_property(dec_ctx_ptr.get(), YACA_PROPERTY_CCM_TAG,
- tag.get(), tag_len));
+ YACA_SUCCESS(yaca_context_set_property(dec_ctx_ptr.get(), YACA_PROPERTY_CCM_TAG, tag, tag_len));
YACA_SUCCESS(yaca_decrypt_update(dec_ctx_ptr.get(), NULL, encrypt_output.size(),
NULL, &update_len));
YACA_SUCCESS(yaca_context_set_property(dec_ctx_ptr.get(), YACA_PROPERTY_CCM_AAD,
aad.data(), aad.size()));
YACA_INVALID_PARAM(yaca_context_set_property(dec_ctx_ptr.get(), YACA_PROPERTY_CCM_TAG,
- tag.get(), tag_len));
+ tag, tag_len));
YACA_SUCCESS(yaca_decrypt_update(dec_ctx_ptr.get(), encrypt_output.data(), encrypt_output.size(),
update_ptr.get(), &update_len));
YACA_INVALID_PARAM(yaca_context_set_property(dec_ctx_ptr.get(), YACA_PROPERTY_CCM_AAD,
aad.data(), aad.size()));
YACA_INVALID_PARAM(yaca_context_set_property(dec_ctx_ptr.get(), YACA_PROPERTY_CCM_TAG,
- tag.get(), tag_len));
+ tag, tag_len));
YACA_INVALID_PARAM(yaca_context_set_property(dec_ctx_ptr.get(), YACA_PROPERTY_CCM_TAG_LEN,
(void*)&tag_len, sizeof(tag_len)));
YACA_INVALID_PARAM(yaca_context_get_property(dec_ctx_ptr.get(), YACA_PROPERTY_CCM_TAG,
- (void**)tag.get(), &tag_len));
+ (void**)&tag, &tag_len));
YACA_SUCCESS(yaca_decrypt_finalize(dec_ctx_ptr.get(), final_ptr.get(), &final_len));
decrypt_output.insert(decrypt_output.end(), final_ptr.get(), final_ptr.get() + final_len);
YACA_INVALID_PARAM(yaca_context_set_property(dec_ctx_ptr.get(), YACA_PROPERTY_CCM_AAD,
aad.data(), aad.size()));
YACA_INVALID_PARAM(yaca_context_set_property(dec_ctx_ptr.get(), YACA_PROPERTY_CCM_TAG,
- tag.get(), tag_len));
+ tag, tag_len));
YACA_INVALID_PARAM(yaca_context_set_property(dec_ctx_ptr.get(), YACA_PROPERTY_CCM_TAG_LEN,
(void*)&tag_len, sizeof(tag_len)));
YACA_INVALID_PARAM(yaca_context_get_property(dec_ctx_ptr.get(), YACA_PROPERTY_CCM_TAG,
- (void**)tag.get(), &tag_len));
+ (void**)&tag, &tag_len));
YACA_ASSERT_MSG(DATA.size() == decrypt_output.size(), "Size after encrypt-decrypt differs\n");
YACA_ASSERT_MSG(DATA == decrypt_output, "Text after encrypt-decrypt has changed\n");
size_t aad_len = 16;
Buffer aad = random_buffer(aad_len);
size_t tag_len = 16;
- ChrPtr tag = create_yaca_buffer(tag_len);
+ char *tag;
size_t update_len, final_len;
YACA_INVALID_PARAM(yaca_context_set_property(enc_ctx.get(), YACA_PROPERTY_GCM_TAG_LEN,
(void*)(&tag_len), sizeof(tag_len)));
YACA_INVALID_PARAM(yaca_context_get_property(enc_ctx.get(), YACA_PROPERTY_GCM_TAG,
- (void**)tag.get(), &tag_len));
+ (void**)&tag, &tag_len));
CtxPtr dec_ctx = decrypt_init(YACA_ENCRYPT_AES, YACA_BCM_CTR, key, iv);
YACA_INVALID_PARAM(yaca_context_set_property(dec_ctx.get(), YACA_PROPERTY_GCM_AAD,
update.get(), &update_len));
YACA_INVALID_PARAM(yaca_context_set_property(dec_ctx.get(), YACA_PROPERTY_GCM_TAG,
- tag.get(), tag_len));
+ tag, tag_len));
YACA_SUCCESS(yaca_decrypt_finalize(dec_ctx.get(), final.get(), &final_len));
(void*)(&tag_len), sizeof(char)));
YACA_INVALID_PARAM(yaca_context_get_property(enc_ctx.get(), YACA_PROPERTY_CCM_TAG,
- (void**)tag.get(), &tag_len));
+ (void**)&tag, &tag_len));
YACA_INVALID_PARAM(yaca_context_get_property(enc_ctx.get(), YACA_PROPERTY_GCM_TAG,
nullptr, &tag_len));
YACA_INVALID_PARAM(yaca_context_get_property(enc_ctx.get(), YACA_PROPERTY_GCM_TAG,
- (void**)tag.get(), nullptr));
+ (void**)&tag, nullptr));
YACA_SUCCESS(yaca_context_get_property(enc_ctx.get(), YACA_PROPERTY_GCM_TAG,
- (void**)tag.get(), &tag_len));
+ (void**)&tag, &tag_len));
+ ChrPtr tag_ptr = wrap_ptr(tag);
dec_ctx = decrypt_init(YACA_ENCRYPT_AES, YACA_BCM_GCM, key, gcm_iv);
YACA_INVALID_PARAM(yaca_context_set_property(dec_ctx.get(), YACA_PROPERTY_CCM_AAD,
update.get(), &update_len));
YACA_INVALID_PARAM(yaca_context_set_property(dec_ctx.get(), YACA_PROPERTY_CCM_TAG,
- tag.get(), tag_len));
+ tag, tag_len));
- YACA_SUCCESS(yaca_context_set_property(dec_ctx.get(), YACA_PROPERTY_GCM_TAG,
- tag.get(), tag_len));
+ YACA_SUCCESS(yaca_context_set_property(dec_ctx.get(), YACA_PROPERTY_GCM_TAG, tag, tag_len));
YACA_SUCCESS(yaca_decrypt_finalize(dec_ctx.get(), final.get(), &final_len));
}
size_t aad_len = 16;
Buffer aad = random_buffer(aad_len);
size_t tag_len = 12;
- ChrPtr tag = create_yaca_buffer(tag_len);
+ char *tag;
size_t update_len, final_len;
encrypt_output.insert(encrypt_output.end(), final.get(), final.get() + final_len);
YACA_INVALID_PARAM(yaca_context_get_property(enc_ctx.get(), YACA_PROPERTY_CCM_TAG,
- (void**)tag.get(), &tag_len));
+ (void**)&tag, &tag_len));
CtxPtr dec_ctx = decrypt_init(YACA_ENCRYPT_3DES_3TDEA, YACA_BCM_CFB, key, iv);
YACA_INVALID_PARAM(yaca_context_set_property(dec_ctx.get(), YACA_PROPERTY_CCM_TAG,
- tag.get(), tag_len));
+ tag, tag_len));
YACA_INVALID_PARAM(yaca_decrypt_update(dec_ctx.get(), NULL, encrypt_output.size(), NULL,
&update_len));
YACA_INVALID_PARAM(yaca_context_set_property(dec_ctx.get(), YACA_PROPERTY_CCM_AAD,
encrypt_output.insert(encrypt_output.end(), final.get(), final.get() + final_len);
YACA_INVALID_PARAM(yaca_context_get_property(enc_ctx.get(), YACA_PROPERTY_GCM_TAG,
- (void**)tag.get(), &tag_len));
+ (void**)&tag, &tag_len));
YACA_INVALID_PARAM(yaca_context_get_property(enc_ctx.get(), YACA_PROPERTY_CCM_TAG,
nullptr, &tag_len));
YACA_INVALID_PARAM(yaca_context_get_property(enc_ctx.get(), YACA_PROPERTY_CCM_TAG,
- (void**)tag.get(), nullptr));
+ (void**)&tag, nullptr));
YACA_SUCCESS(yaca_context_get_property(enc_ctx.get(), YACA_PROPERTY_CCM_TAG,
- (void**)tag.get(), &tag_len));
+ (void**)&tag, &tag_len));
+ ChrPtr tag_ptr = wrap_ptr(tag);
dec_ctx = decrypt_init(YACA_ENCRYPT_AES, YACA_BCM_CCM, key, iv);
YACA_INVALID_PARAM(yaca_context_set_property(dec_ctx.get(), YACA_PROPERTY_GCM_TAG,
- tag.get(), tag_len));
+ tag, tag_len));
- YACA_SUCCESS(yaca_context_set_property(dec_ctx.get(), YACA_PROPERTY_CCM_TAG,
- tag.get(), tag_len));
+ YACA_SUCCESS(yaca_context_set_property(dec_ctx.get(), YACA_PROPERTY_CCM_TAG, tag, tag_len));
YACA_SUCCESS(yaca_decrypt_update(dec_ctx.get(), NULL, encrypt_output.size(), NULL,
&update_len));
size_t aad_len = 16;
Buffer aad = random_buffer(aad_len);
size_t tag_len = 16;
- ChrPtr tag = create_yaca_buffer(tag_len);
+ char *tag;
CtxPtr enc_ctx = encrypt_init(YACA_ENCRYPT_AES, YACA_BCM_GCM, key, iv);
update.get(), &update_len));
YACA_SUCCESS(yaca_encrypt_finalize(enc_ctx.get(), final.get(), &final_len));
YACA_SUCCESS(yaca_context_get_property(enc_ctx.get(), YACA_PROPERTY_GCM_TAG,
- (void**)tag.get(), &tag_len));
+ (void**)&tag, &tag_len));
+ ChrPtr tag_ptr = wrap_ptr(tag);
encrypt_output.insert(encrypt_output.end(), update.get(), update.get() + update_len);
encrypt_output.insert(encrypt_output.end(), final.get(), final.get() + final_len);
final = out_buf_alloc(dec_ctx, 0, final_len);
// Invalid AAD
- YACA_SUCCESS(yaca_context_set_property(dec_ctx.get(), YACA_PROPERTY_GCM_AAD,
- tag.get(), aad.size()));
+ YACA_SUCCESS(yaca_context_set_property(dec_ctx.get(), YACA_PROPERTY_GCM_AAD, tag, aad.size()));
YACA_SUCCESS(yaca_decrypt_update(dec_ctx.get(), encrypt_output.data(), encrypt_output.size(),
update.get(), &update_len));
// Valid TAG
- YACA_SUCCESS(yaca_context_set_property(dec_ctx.get(), YACA_PROPERTY_GCM_TAG,
- tag.get(), tag_len));
+ YACA_SUCCESS(yaca_context_set_property(dec_ctx.get(), YACA_PROPERTY_GCM_TAG, tag, tag_len));
YACA_INVALID_PARAM(yaca_decrypt_finalize(dec_ctx.get(), final.get(), &final_len));
size_t aad_len = 16;
Buffer aad = random_buffer(aad_len);
size_t tag_len = 12;
- ChrPtr tag = create_yaca_buffer(tag_len);
+ char *tag;
CtxPtr enc_ctx = encrypt_init(YACA_ENCRYPT_AES, YACA_BCM_CCM, key, iv);
update.get(), &update_len));
YACA_SUCCESS(yaca_encrypt_finalize(enc_ctx.get(), final.get(), &final_len));
YACA_SUCCESS(yaca_context_get_property(enc_ctx.get(), YACA_PROPERTY_CCM_TAG,
- (void**)tag.get(), &tag_len));
+ (void**)&tag, &tag_len));
+ ChrPtr tag_ptr = wrap_ptr(tag);
encrypt_output.insert(encrypt_output.end(), update.get(), update.get() + update_len);
encrypt_output.insert(encrypt_output.end(), final.get(), final.get() + final_len);
dec_ctx = decrypt_init(YACA_ENCRYPT_AES, YACA_BCM_CCM, key, iv);
// Valid TAG
- YACA_SUCCESS(yaca_context_set_property(dec_ctx.get(), YACA_PROPERTY_CCM_TAG,
- tag.get(), tag_len));
+ YACA_SUCCESS(yaca_context_set_property(dec_ctx.get(), YACA_PROPERTY_CCM_TAG, tag, tag_len));
// Invalid AAD
YACA_SUCCESS(yaca_decrypt_update(dec_ctx.get(), NULL, encrypt_output.size(), NULL,
&update_len));
YACA_SUCCESS(yaca_context_set_property(dec_ctx.get(), YACA_PROPERTY_CCM_AAD,
- tag.get(), aad.size()));
+ tag, aad.size()));
YACA_INVALID_PARAM(yaca_decrypt_update(dec_ctx.get(), encrypt_output.data(), encrypt_output.size(),
update.get(), &update_len));