c448_error_t c448_ed448_sign(
                        uint8_t signature[EDDSA_448_SIGNATURE_BYTES],
                        const uint8_t privkey[EDDSA_448_PRIVATE_BYTES],
                        const uint8_t pubkey[EDDSA_448_PUBLIC_BYTES],
                        const uint8_t *message, size_t message_len,
                        uint8_t prehashed, const uint8_t *context,
                        size_t context_len)
{
    curve448_scalar_t secret_scalar;
    EVP_MD_CTX *hashctx = EVP_MD_CTX_new();
    c448_error_t ret = C448_FAILURE;
    curve448_scalar_t nonce_scalar;
    uint8_t nonce_point[EDDSA_448_PUBLIC_BYTES] = { 0 };
    unsigned int c;
    curve448_scalar_t challenge_scalar;
    if (hashctx == NULL)
        return C448_FAILURE;
    {
        uint8_t expanded[EDDSA_448_PRIVATE_BYTES * 2];
        if (!oneshot_hash(expanded, sizeof(expanded), privkey,
                          EDDSA_448_PRIVATE_BYTES))
            goto err;
        clamp(expanded);
        curve448_scalar_decode_long(secret_scalar, expanded,
                                    EDDSA_448_PRIVATE_BYTES);
        if (!hash_init_with_dom(hashctx, prehashed, 0, context, context_len)
                || !EVP_DigestUpdate(hashctx,
                                     expanded + EDDSA_448_PRIVATE_BYTES,
                                     EDDSA_448_PRIVATE_BYTES)
                || (message_len > 0
                    && !EVP_DigestUpdate(hashctx, message, message_len))) {
            OPENSSL_cleanse(expanded, sizeof(expanded));
            goto err;
        }
        OPENSSL_cleanse(expanded, sizeof(expanded));
    }
    {
        uint8_t nonce[2 * EDDSA_448_PRIVATE_BYTES];
        if (!EVP_DigestFinalXOF(hashctx, nonce, sizeof(nonce)))
            goto err;
        curve448_scalar_decode_long(nonce_scalar, nonce, sizeof(nonce));
        OPENSSL_cleanse(nonce, sizeof(nonce));
    }
    {
        curve448_scalar_t nonce_scalar_2;
        curve448_point_t p;
        curve448_scalar_halve(nonce_scalar_2, nonce_scalar);
        for (c = 2; c < C448_EDDSA_ENCODE_RATIO; c <<= 1)
            curve448_scalar_halve(nonce_scalar_2, nonce_scalar_2);
        curve448_precomputed_scalarmul(p, curve448_precomputed_base,
                                       nonce_scalar_2);
        curve448_point_mul_by_ratio_and_encode_like_eddsa(nonce_point, p);
        curve448_point_destroy(p);
        curve448_scalar_destroy(nonce_scalar_2);
    }
    {
        uint8_t challenge[2 * EDDSA_448_PRIVATE_BYTES];
        if (!hash_init_with_dom(hashctx, prehashed, 0, context, context_len)
                || !EVP_DigestUpdate(hashctx, nonce_point, sizeof(nonce_point))
                || !EVP_DigestUpdate(hashctx, pubkey, EDDSA_448_PUBLIC_BYTES)
                || (message_len > 0
                    && !EVP_DigestUpdate(hashctx, message, message_len))
                || !EVP_DigestFinalXOF(hashctx, challenge, sizeof(challenge)))
            goto err;
        curve448_scalar_decode_long(challenge_scalar, challenge,
                                    sizeof(challenge));
        OPENSSL_cleanse(challenge, sizeof(challenge));
    }
    curve448_scalar_mul(challenge_scalar, challenge_scalar, secret_scalar);
    curve448_scalar_add(challenge_scalar, challenge_scalar, nonce_scalar);
    OPENSSL_cleanse(signature, EDDSA_448_SIGNATURE_BYTES);
    memcpy(signature, nonce_point, sizeof(nonce_point));
    curve448_scalar_encode(&signature[EDDSA_448_PUBLIC_BYTES],
                           challenge_scalar);
    curve448_scalar_destroy(secret_scalar);
    curve448_scalar_destroy(nonce_scalar);
    curve448_scalar_destroy(challenge_scalar);
    ret = C448_SUCCESS;
 err:
    EVP_MD_CTX_free(hashctx);
    return ret;
}
['c448_error_t c448_ed448_sign(\n                        uint8_t signature[EDDSA_448_SIGNATURE_BYTES],\n                        const uint8_t privkey[EDDSA_448_PRIVATE_BYTES],\n                        const uint8_t pubkey[EDDSA_448_PUBLIC_BYTES],\n                        const uint8_t *message, size_t message_len,\n                        uint8_t prehashed, const uint8_t *context,\n                        size_t context_len)\n{\n    curve448_scalar_t secret_scalar;\n    EVP_MD_CTX *hashctx = EVP_MD_CTX_new();\n    c448_error_t ret = C448_FAILURE;\n    curve448_scalar_t nonce_scalar;\n    uint8_t nonce_point[EDDSA_448_PUBLIC_BYTES] = { 0 };\n    unsigned int c;\n    curve448_scalar_t challenge_scalar;\n    if (hashctx == NULL)\n        return C448_FAILURE;\n    {\n        uint8_t expanded[EDDSA_448_PRIVATE_BYTES * 2];\n        if (!oneshot_hash(expanded, sizeof(expanded), privkey,\n                          EDDSA_448_PRIVATE_BYTES))\n            goto err;\n        clamp(expanded);\n        curve448_scalar_decode_long(secret_scalar, expanded,\n                                    EDDSA_448_PRIVATE_BYTES);\n        if (!hash_init_with_dom(hashctx, prehashed, 0, context, context_len)\n                || !EVP_DigestUpdate(hashctx,\n                                     expanded + EDDSA_448_PRIVATE_BYTES,\n                                     EDDSA_448_PRIVATE_BYTES)\n                || (message_len > 0\n                    && !EVP_DigestUpdate(hashctx, message, message_len))) {\n            OPENSSL_cleanse(expanded, sizeof(expanded));\n            goto err;\n        }\n        OPENSSL_cleanse(expanded, sizeof(expanded));\n    }\n    {\n        uint8_t nonce[2 * EDDSA_448_PRIVATE_BYTES];\n        if (!EVP_DigestFinalXOF(hashctx, nonce, sizeof(nonce)))\n            goto err;\n        curve448_scalar_decode_long(nonce_scalar, nonce, sizeof(nonce));\n        OPENSSL_cleanse(nonce, sizeof(nonce));\n    }\n    {\n        curve448_scalar_t nonce_scalar_2;\n        curve448_point_t p;\n        curve448_scalar_halve(nonce_scalar_2, nonce_scalar);\n        for (c = 2; c < C448_EDDSA_ENCODE_RATIO; c <<= 1)\n            curve448_scalar_halve(nonce_scalar_2, nonce_scalar_2);\n        curve448_precomputed_scalarmul(p, curve448_precomputed_base,\n                                       nonce_scalar_2);\n        curve448_point_mul_by_ratio_and_encode_like_eddsa(nonce_point, p);\n        curve448_point_destroy(p);\n        curve448_scalar_destroy(nonce_scalar_2);\n    }\n    {\n        uint8_t challenge[2 * EDDSA_448_PRIVATE_BYTES];\n        if (!hash_init_with_dom(hashctx, prehashed, 0, context, context_len)\n                || !EVP_DigestUpdate(hashctx, nonce_point, sizeof(nonce_point))\n                || !EVP_DigestUpdate(hashctx, pubkey, EDDSA_448_PUBLIC_BYTES)\n                || (message_len > 0\n                    && !EVP_DigestUpdate(hashctx, message, message_len))\n                || !EVP_DigestFinalXOF(hashctx, challenge, sizeof(challenge)))\n            goto err;\n        curve448_scalar_decode_long(challenge_scalar, challenge,\n                                    sizeof(challenge));\n        OPENSSL_cleanse(challenge, sizeof(challenge));\n    }\n    curve448_scalar_mul(challenge_scalar, challenge_scalar, secret_scalar);\n    curve448_scalar_add(challenge_scalar, challenge_scalar, nonce_scalar);\n    OPENSSL_cleanse(signature, EDDSA_448_SIGNATURE_BYTES);\n    memcpy(signature, nonce_point, sizeof(nonce_point));\n    curve448_scalar_encode(&signature[EDDSA_448_PUBLIC_BYTES],\n                           challenge_scalar);\n    curve448_scalar_destroy(secret_scalar);\n    curve448_scalar_destroy(nonce_scalar);\n    curve448_scalar_destroy(challenge_scalar);\n    ret = C448_SUCCESS;\n err:\n    EVP_MD_CTX_free(hashctx);\n    return ret;\n}', 'EVP_MD_CTX *EVP_MD_CTX_new(void)\n{\n    return OPENSSL_zalloc(sizeof(EVP_MD_CTX));\n}', 'void *CRYPTO_zalloc(size_t num, const char *file, int line)\n{\n    void *ret = CRYPTO_malloc(num, file, line);\n    FAILTEST();\n    if (ret != NULL)\n        memset(ret, 0, num);\n    return ret;\n}', 'void *CRYPTO_malloc(size_t num, const char *file, int line)\n{\n    void *ret = NULL;\n    INCREMENT(malloc_count);\n    if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)\n        return malloc_impl(num, file, line);\n    if (num == 0)\n        return NULL;\n    FAILTEST();\n    allow_customize = 0;\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        CRYPTO_mem_debug_malloc(NULL, num, 0, file, line);\n        ret = malloc(num);\n        CRYPTO_mem_debug_malloc(ret, num, 1, file, line);\n    } else {\n        ret = malloc(num);\n    }\n#else\n    (void)(file); (void)(line);\n    ret = malloc(num);\n#endif\n    return ret;\n}', 'static c448_error_t oneshot_hash(uint8_t *out, size_t outlen,\n                                 const uint8_t *in, size_t inlen)\n{\n    EVP_MD_CTX *hashctx = EVP_MD_CTX_new();\n    if (hashctx == NULL)\n        return C448_FAILURE;\n    if (!EVP_DigestInit_ex(hashctx, EVP_shake256(), NULL)\n            || !EVP_DigestUpdate(hashctx, in, inlen)\n            || !EVP_DigestFinalXOF(hashctx, out, outlen)) {\n        EVP_MD_CTX_free(hashctx);\n        return C448_FAILURE;\n    }\n    EVP_MD_CTX_free(hashctx);\n    return C448_SUCCESS;\n}', 'EVP_MD_SHAKE(256)', 'void EVP_MD_CTX_free(EVP_MD_CTX *ctx)\n{\n    EVP_MD_CTX_reset(ctx);\n    OPENSSL_free(ctx);\n}', 'void CRYPTO_free(void *str, const char *file, int line)\n{\n    INCREMENT(free_count);\n    if (free_impl != NULL && free_impl != &CRYPTO_free) {\n        free_impl(str, file, line);\n        return;\n    }\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        CRYPTO_mem_debug_free(str, 0, file, line);\n        free(str);\n        CRYPTO_mem_debug_free(str, 1, file, line);\n    } else {\n        free(str);\n    }\n#else\n    free(str);\n#endif\n}']