Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add API support for pipelining in provided ciphers #18298

Open
ShuaiYuan21 opened this issue May 12, 2022 · 7 comments
Open

Add API support for pipelining in provided ciphers #18298

ShuaiYuan21 opened this issue May 12, 2022 · 7 comments
Labels
inactive triaged: feature The issue/pr requests/adds a feature

Comments

@ShuaiYuan21
Copy link
Contributor

Hi,

We are developing our own provider under OpenSSL 3.0 framework.

However, when it comes to aes_cbc_hmac_sha algorithm, we cannot find a way to setup the EVP_CIPHER structure.

Previously, take the engine in OpenSSL 1.1.1 as an example, after we created the EVP_CIPHER_CTX generated by EVP_CIPHER_CTX_new(), it can be initialized by EVP_CipherInit_ex(), which will call some of the preset functions in engine, and *EVP_CIPHER_meth_set_flags(EVP_CIPHER cipher, unsigned long flags) is one of them, and we can use this function to set the flags variable of cipher in the EVP_CIPHER_CTX structure.

Like this:

ctx = EVP_CIPHER_CTX_new();
    if (ctx == NULL)
        return NULL;
if (EVP_CipherInit_ex(ctx, EVP_aes_128_cbc_hmac_sha1(),
                        engine, key, _ivec, enc) != 1)
    goto err;

However, in openssl3.0, the entire framework has changed, EVP_CIPHER has been finalized as early as after EVP_CIPHER_fetch() function is excuted, we have no way to make any changes to the member variable flags of EVP_CIPHER.

static int evp_cipher_init_internal(EVP_CIPHER_CTX *ctx,
                                    const EVP_CIPHER *cipher,
                                    ENGINE *impl, const unsigned char *key,
                                    const unsigned char *iv, int enc,
                                    const OSSL_PARAM params[])
{
    ......

    if (cipher->prov == NULL) {
    ......
        EVP_CIPHER *provciph =
            EVP_CIPHER_fetch(NULL,
                             cipher->nid == NID_undef ? "NULL"
                                                      : OBJ_nid2sn(cipher->nid),
                             "");

        if (provciph == NULL)
            return 0;
        cipher = provciph;
        EVP_CIPHER_free(ctx->fetched_cipher);
        ctx->fetched_cipher = provciph;
#endif
    }

    ......

    ctx->cipher = cipher;
    if (ctx->algctx == NULL) {
        ctx->algctx = ctx->cipher->newctx(ossl_provider_ctx(cipher->prov));
        if (ctx->algctx == NULL) {
            ERR_raise(ERR_LIB_EVP, EVP_R_INITIALIZATION_ERROR);
            return 0;
        }
    }

    ......
}

What we want to do is to be able to configure EVP_CIPHER to support the pipeline feature by adding EVP_CIPH_FLAG_PIPELINE to its flags variable.

We can still find the definition of pipeline in the code of openssl 3.0, but the flags variable in cipher is marked as legacy,
so does openssl 3.0 still support the pipeline feature? And if so, then how to configure it?

  • The definition of EVP_CIPH_FLAG_PIPELINE:
/* Cipher can handle pipeline operations */
# define         EVP_CIPH_FLAG_PIPELINE          0X800000
  • EVP_CIPHER structure:
struct evp_cipher_st {
    ......
    /* Legacy structure members */
    /* Various flags */
    unsigned long flags;
    ......
} /* EVP_CIPHER */ ;

Thanks!

@ShuaiYuan21 ShuaiYuan21 added the issue: question The issue was opened to ask a question label May 12, 2022
@t8m t8m added triaged: question The issue contains a question and removed issue: question The issue was opened to ask a question labels May 12, 2022
@daweiq
Copy link

daweiq commented May 16, 2022

We have enabled the pipeline in our engine which need to set the EVP_CIPHER->flags to EVP_CIPH_FLAG_PIPELINE in engine.
Does OpenSSL-3.0 provider support pipeline?
If yes, how to updating EVP_CIPHER->flags inside provider?

@paulidale
Copy link
Contributor

The 3.0 method would be to implement the entire algorithm in the provider.

@daweiq
Copy link

daweiq commented May 16, 2022

@paulidale Do you mean using the void *ossl_method_construct(OSSL_LIB_CTX *ctx, int operation_id,
to construct a method for storing the cipher->flags?

@mattcaswell
Copy link
Member

Does OpenSSL-3.0 provider support pipeline?

No. There is no support for pipelining in OpenSSL 3.0 provided ciphers at the moment. We might like to add it in the future.

@daweiq
Copy link

daweiq commented May 19, 2022

Is there any timeline for enabling pipeline support in provider?
We are relaying on this feature to accelerate bulk-crypto through HW.

@mattcaswell
Copy link
Member

Is there any timeline for enabling pipeline support in provider?

Unfortunately not. It's not currently planned.

@t8m t8m added triaged: feature The issue/pr requests/adds a feature and removed triaged: question The issue contains a question labels Oct 24, 2022
@t8m t8m changed the title Does OpenSSL 3.0 cipher support pipeline feature? Add API support for pipelining in provided ciphers Oct 24, 2022
@nhorman
Copy link
Contributor

nhorman commented Jun 9, 2024

Marking as inactive, to be closed when 3.4 dev cycle ends, barring further input

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
inactive triaged: feature The issue/pr requests/adds a feature
Projects
None yet
Development

No branches or pull requests

6 participants