Skip to content

Add API support for pipelining in provided ciphers #18298

Closed as not planned
Closed as not planned

Description

@ShuaiYuan21

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!

Activity

  1. added
    issue: question
    on May 12, 2022
  2. added
    triaged: question
    and removed
    issue: question
    on May 12, 2022
  3. daweiq commented on May 16, 2022

    @daweiq

    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?

  4. paulidale commented on May 16, 2022

    @paulidale
    Contributor

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

  5. daweiq commented on May 16, 2022

    @daweiq

    @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?

  6. mattcaswell commented on May 16, 2022

    @mattcaswell
    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.

  7. daweiq commented on May 19, 2022

    @daweiq

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

  8. mattcaswell commented on May 19, 2022

    @mattcaswell
    Member

    Is there any timeline for enabling pipeline support in provider?

    Unfortunately not. It's not currently planned.

  9. added
    triaged: feature
    and removed
    triaged: question
    on Oct 24, 2022
  10. changed the title [-]Does OpenSSL 3.0 cipher support pipeline feature?[/-] [+]Add API support for pipelining in provided ciphers[/+] on Oct 24, 2022
  11. nhorman commented on Jun 9, 2024

    @nhorman
    Contributor

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    triaged: feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions