Skip to main content
  • Home
  • login
  • Browse the archive

    swh mirror partner logo
swh logo
SoftwareHeritage
Software
Heritage
Mirror
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

Revision f2c2857accd5650cbcb0767019abd75925b51a3e authored by Matt Caswell on 19 October 2023, 13:54:58 UTC, committed by Matt Caswell on 23 October 2023, 09:08:22 UTC
Don't run the QUIC client fuzzer if QUIC is disabled
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22368)
1 parent 49f5d95
  • Files
  • Changes
  • 5f10889
  • /
  • providers
  • /
  • implementations
  • /
  • ciphers
  • /
  • cipher_sm4_xts_hw.c
Raw File
Cook and download a directory from the Software Heritage Vault

You have requested the cooking of the directory with identifier None into a standard tar.gz archive.

Are you sure you want to continue ?

Download a directory from the Software Heritage Vault

You have requested the download of the directory with identifier None as a standard tar.gz archive.

Are you sure you want to continue ?

Cook and download a revision from the Software Heritage Vault

You have requested the cooking of the history heading to revision with identifier swh:1:rev:f2c2857accd5650cbcb0767019abd75925b51a3e into a bare git archive.

Are you sure you want to continue ?

Download a revision from the Software Heritage Vault

You have requested the download of the history heading to revision with identifier swh:1:rev:f2c2857accd5650cbcb0767019abd75925b51a3e as a bare git archive.

Are you sure you want to continue ?

Invalid Email !

The provided email is not well-formed.

Download link has expired

The requested archive is no longer available for download from the Software Heritage Vault.

Do you want to cook it again ?

Permalinks

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • revision
  • content
revision badge
swh:1:rev:f2c2857accd5650cbcb0767019abd75925b51a3e
content badge Iframe embedding
swh:1:cnt:44af243a6924165fb565eb0b1daf4288365ba8af
cipher_sm4_xts_hw.c
/*
 * Copyright 2022-2023 The OpenSSL Project Authors. All Rights Reserved.
 *
 * Licensed under the Apache License 2.0 (the "License").  You may not use
 * this file except in compliance with the License.  You can obtain a copy
 * in the file LICENSE in the source distribution or at
 * https://www.openssl.org/source/license.html
 */

#include "cipher_sm4_xts.h"

#define XTS_SET_KEY_FN(fn_set_enc_key, fn_set_dec_key,                         \
                       fn_block_enc, fn_block_dec,                             \
                       fn_stream, fn_stream_gb) {                              \
    size_t bytes = keylen / 2;                                                 \
                                                                               \
    if (ctx->enc) {                                                            \
        fn_set_enc_key(key, &xctx->ks1.ks);                                    \
        xctx->xts.block1 = (block128_f)fn_block_enc;                           \
    } else {                                                                   \
        fn_set_dec_key(key, &xctx->ks1.ks);                                    \
        xctx->xts.block1 = (block128_f)fn_block_dec;                           \
    }                                                                          \
    fn_set_enc_key(key + bytes, &xctx->ks2.ks);                                \
    xctx->xts.block2 = (block128_f)fn_block_enc;                               \
    xctx->xts.key1 = &xctx->ks1;                                               \
    xctx->xts.key2 = &xctx->ks2;                                               \
    xctx->stream = fn_stream;                                                  \
    xctx->stream_gb = fn_stream_gb;                                            \
}

static int cipher_hw_sm4_xts_generic_initkey(PROV_CIPHER_CTX *ctx,
                                             const unsigned char *key,
                                             size_t keylen)
{
    PROV_SM4_XTS_CTX *xctx = (PROV_SM4_XTS_CTX *)ctx;
    OSSL_xts_stream_fn stream = NULL;
    OSSL_xts_stream_fn stream_gb = NULL;
#ifdef HWSM4_CAPABLE
    if (HWSM4_CAPABLE) {
        XTS_SET_KEY_FN(HWSM4_set_encrypt_key, HWSM4_set_decrypt_key,
                       HWSM4_encrypt, HWSM4_decrypt, stream, stream_gb);
        return 1;
    } else
#endif /* HWSM4_CAPABLE */
#ifdef VPSM4_EX_CAPABLE
    if (VPSM4_EX_CAPABLE) {
        stream = vpsm4_ex_xts_encrypt;
        stream_gb = vpsm4_ex_xts_encrypt_gb;
        XTS_SET_KEY_FN(vpsm4_ex_set_encrypt_key, vpsm4_ex_set_decrypt_key,
                       vpsm4_ex_encrypt, vpsm4_ex_decrypt, stream, stream_gb);
        return 1;
    } else
#endif /* VPSM4_EX_CAPABLE */
#ifdef VPSM4_CAPABLE
    if (VPSM4_CAPABLE) {
        stream = vpsm4_xts_encrypt;
        stream_gb = vpsm4_xts_encrypt_gb;
        XTS_SET_KEY_FN(vpsm4_set_encrypt_key, vpsm4_set_decrypt_key,
                       vpsm4_encrypt, vpsm4_decrypt, stream, stream_gb);
        return 1;
    } else
#endif /* VPSM4_CAPABLE */
    {
        (void)0;
    }
    {
        XTS_SET_KEY_FN(ossl_sm4_set_key, ossl_sm4_set_key, ossl_sm4_encrypt,
                       ossl_sm4_decrypt, stream, stream_gb);
    }
    return 1;
}

static void cipher_hw_sm4_xts_copyctx(PROV_CIPHER_CTX *dst,
                                      const PROV_CIPHER_CTX *src)
{
    PROV_SM4_XTS_CTX *sctx = (PROV_SM4_XTS_CTX *)src;
    PROV_SM4_XTS_CTX *dctx = (PROV_SM4_XTS_CTX *)dst;

    *dctx = *sctx;
    dctx->xts.key1 = &dctx->ks1.ks;
    dctx->xts.key2 = &dctx->ks2.ks;
}


static const PROV_CIPHER_HW sm4_generic_xts = {
    cipher_hw_sm4_xts_generic_initkey,
    NULL,
    cipher_hw_sm4_xts_copyctx
};
const PROV_CIPHER_HW *ossl_prov_cipher_hw_sm4_xts(size_t keybits)
{
    return &sm4_generic_xts;
}
The diff you're trying to view is too large. Only the first 1000 changed files have been loaded.
Showing with 0 additions and 0 deletions (0 / 0 diffs computed)
swh spinner

Computing file changes ...

ENEA — Copyright (C), ENEA. License: GNU AGPLv3+.
Legal notes  ::  JavaScript license information ::  Web API

back to top