Example #1
0
static int bind_ossltest(ENGINE *e)
{
    /* Ensure the ossltest error handling is set up */
    ERR_load_OSSLTEST_strings();

    if (!ENGINE_set_id(e, engine_ossltest_id)
        || !ENGINE_set_name(e, engine_ossltest_name)
        || !ENGINE_set_digests(e, ossltest_digests)
        || !ENGINE_set_ciphers(e, ossltest_ciphers)
        || !ENGINE_set_destroy_function(e, ossltest_destroy)
        || !ENGINE_set_init_function(e, ossltest_init)
        || !ENGINE_set_finish_function(e, ossltest_finish)) {
        OSSLTESTerr(OSSLTEST_F_BIND_OSSLTEST, OSSLTEST_R_INIT_FAILED);
        return 0;
    }

    return 1;
}
Example #2
0
int ossltest_aes128_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
                             const unsigned char *iv, int enc)
{
    if (ctx->cipher_data == NULL) {
        /*
         * Normally cipher_data is allocated automatically for an engine but
         * we don't know the ctx_size as compile time so we have to do it at
         * run time
         */
        ctx->cipher_data = OPENSSL_zalloc(EVP_aes_128_cbc()->ctx_size);
        if (ctx->cipher_data == NULL) {
            OSSLTESTerr(OSSLTEST_F_OSSLTEST_AES128_INIT_KEY,
                        ERR_R_MALLOC_FAILURE);
            return 0;
        }
    }
    return EVP_aes_128_cbc()->init(ctx, key, iv, enc);
}