ossl_get_gcm_auth_tag(EVP_CIPHER_CTX *ctx, int len)
{
    unsigned char *tag;
    VALUE ret;

    tag = ALLOC_N(unsigned char, len);

    if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_GET_TAG, len, tag))
        ossl_raise(eCipherError, "retrieving the authentication tag failed");

    ret = rb_str_new((const char *) tag, len);
    xfree(tag);
    return ret;
}
ossl_get_gcm_auth_tag(EVP_CIPHER_CTX *ctx, int len)
{
    unsigned char *tag;
    VALUE ret;

    tag = ALLOC_N(unsigned char, len);

    if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_GET_TAG, len, tag))
        ossl_raise(eCipherError, "retrieving the authentication tag failed");

    ret = rb_str_new((const char *) tag, len);
    xfree(tag);
    return ret;
}