Coverage Report

Created: 2023-09-25 06:41

/src/openssl/providers/implementations/include/prov/ciphercommon.h
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright 2019-2023 The OpenSSL Project Authors. All Rights Reserved.
3
 *
4
 * Licensed under the Apache License 2.0 (the "License").  You may not use
5
 * this file except in compliance with the License.  You can obtain a copy
6
 * in the file LICENSE in the source distribution or at
7
 * https://www.openssl.org/source/license.html
8
 */
9
10
#ifndef OSSL_PROV_CIPHERCOMMON_H
11
# define OSSL_PROV_CIPHERCOMMON_H
12
# pragma once
13
14
# include <openssl/params.h>
15
# include <openssl/core_dispatch.h>
16
# include <openssl/core_names.h>
17
# include <openssl/evp.h>
18
# include "internal/cryptlib.h"
19
# include "crypto/modes.h"
20
21
0
# define MAXCHUNK    ((size_t)1 << 30)
22
0
# define MAXBITCHUNK ((size_t)1 << (sizeof(size_t) * 8 - 4))
23
24
# define GENERIC_BLOCK_SIZE 16
25
0
# define IV_STATE_UNINITIALISED 0  /* initial state is not initialized */
26
0
# define IV_STATE_BUFFERED      1  /* iv has been copied to the iv buffer */
27
0
# define IV_STATE_COPIED        2  /* iv has been copied from the iv buffer */
28
0
# define IV_STATE_FINISHED      3  /* the iv has been used - so don't reuse it */
29
30
# define PROV_CIPHER_FUNC(type, name, args) typedef type (* OSSL_##name##_fn)args
31
32
typedef struct prov_cipher_hw_st PROV_CIPHER_HW;
33
typedef struct prov_cipher_ctx_st PROV_CIPHER_CTX;
34
35
typedef int (PROV_CIPHER_HW_FN)(PROV_CIPHER_CTX *dat, unsigned char *out,
36
                                const unsigned char *in, size_t len);
37
38
/* Internal flags that can be queried */
39
131
# define PROV_CIPHER_FLAG_AEAD             0x0001
40
132
# define PROV_CIPHER_FLAG_CUSTOM_IV        0x0002
41
130
# define PROV_CIPHER_FLAG_CTS              0x0004
42
130
# define PROV_CIPHER_FLAG_TLS1_MULTIBLOCK  0x0008
43
130
# define PROV_CIPHER_FLAG_RAND_KEY         0x0010
44
/* Internal flags that are only used within the provider */
45
5
# define PROV_CIPHER_FLAG_VARIABLE_LENGTH  0x0100
46
5
# define PROV_CIPHER_FLAG_INVERSE_CIPHER   0x0200
47
48
struct prov_cipher_ctx_st {
49
    /* place buffer at the beginning for memory alignment */
50
    /* The original value of the iv */
51
    unsigned char oiv[GENERIC_BLOCK_SIZE];
52
    /* Buffer of partial blocks processed via update calls */
53
    unsigned char buf[GENERIC_BLOCK_SIZE];
54
    unsigned char iv[GENERIC_BLOCK_SIZE];
55
56
    block128_f block;
57
    union {
58
        cbc128_f cbc;
59
        ctr128_f ctr;
60
        ecb128_f ecb;
61
    } stream;
62
63
    unsigned int mode;
64
    size_t keylen;           /* key size (in bytes) */
65
    size_t ivlen;
66
    size_t blocksize;
67
    size_t bufsz;            /* Number of bytes in buf */
68
    unsigned int cts_mode;   /* Use to set the type for CTS modes */
69
    unsigned int pad : 1;    /* Whether padding should be used or not */
70
    unsigned int enc : 1;    /* Set to 1 for encrypt, or 0 otherwise */
71
    unsigned int iv_set : 1; /* Set when the iv is copied to the iv/oiv buffers */
72
    unsigned int updated : 1; /* Set to 1 during update for one shot ciphers */
73
    unsigned int variable_keylength : 1;
74
    unsigned int inverse_cipher : 1; /* set to 1 to use inverse cipher */
75
    unsigned int use_bits : 1; /* Set to 0 for cfb1 to use bits instead of bytes */
76
77
    unsigned int tlsversion; /* If TLS padding is in use the TLS version number */
78
    unsigned char *tlsmac;   /* tls MAC extracted from the last record */
79
    int alloced;             /*
80
                              * Whether the tlsmac data has been allocated or
81
                              * points into the user buffer.
82
                              */
83
    size_t tlsmacsize;       /* Size of the TLS MAC */
84
    int removetlspad;        /* Whether TLS padding should be removed or not */
85
    size_t removetlsfixed;   /*
86
                              * Length of the fixed size data to remove when
87
                              * processing TLS data (equals mac size plus
88
                              * IV size if applicable)
89
                              */
90
91
    /*
92
     * num contains the number of bytes of |iv| which are valid for modes that
93
     * manage partial blocks themselves.
94
     */
95
    unsigned int num;
96
    const PROV_CIPHER_HW *hw; /* hardware specific functions */
97
    const void *ks; /* Pointer to algorithm specific key data */
98
    OSSL_LIB_CTX *libctx;
99
};
100
101
struct prov_cipher_hw_st {
102
    int (*init)(PROV_CIPHER_CTX *dat, const uint8_t *key, size_t keylen);
103
    PROV_CIPHER_HW_FN *cipher;
104
    void (*copyctx)(PROV_CIPHER_CTX *dst, const PROV_CIPHER_CTX *src);
105
};
106
107
void ossl_cipher_generic_reset_ctx(PROV_CIPHER_CTX *ctx);
108
OSSL_FUNC_cipher_encrypt_init_fn ossl_cipher_generic_einit;
109
OSSL_FUNC_cipher_decrypt_init_fn ossl_cipher_generic_dinit;
110
OSSL_FUNC_cipher_update_fn ossl_cipher_generic_block_update;
111
OSSL_FUNC_cipher_final_fn ossl_cipher_generic_block_final;
112
OSSL_FUNC_cipher_update_fn ossl_cipher_generic_stream_update;
113
OSSL_FUNC_cipher_final_fn ossl_cipher_generic_stream_final;
114
OSSL_FUNC_cipher_cipher_fn ossl_cipher_generic_cipher;
115
OSSL_FUNC_cipher_get_ctx_params_fn ossl_cipher_generic_get_ctx_params;
116
OSSL_FUNC_cipher_set_ctx_params_fn ossl_cipher_generic_set_ctx_params;
117
OSSL_FUNC_cipher_gettable_params_fn     ossl_cipher_generic_gettable_params;
118
OSSL_FUNC_cipher_gettable_ctx_params_fn ossl_cipher_generic_gettable_ctx_params;
119
OSSL_FUNC_cipher_settable_ctx_params_fn ossl_cipher_generic_settable_ctx_params;
120
OSSL_FUNC_cipher_set_ctx_params_fn ossl_cipher_var_keylen_set_ctx_params;
121
OSSL_FUNC_cipher_settable_ctx_params_fn ossl_cipher_var_keylen_settable_ctx_params;
122
OSSL_FUNC_cipher_gettable_ctx_params_fn ossl_cipher_aead_gettable_ctx_params;
123
OSSL_FUNC_cipher_settable_ctx_params_fn ossl_cipher_aead_settable_ctx_params;
124
125
int ossl_cipher_generic_get_params(OSSL_PARAM params[], unsigned int md,
126
                                   uint64_t flags,
127
                                   size_t kbits, size_t blkbits, size_t ivbits);
128
void ossl_cipher_generic_initkey(void *vctx, size_t kbits, size_t blkbits,
129
                                 size_t ivbits, unsigned int mode,
130
                                 uint64_t flags,
131
                                 const PROV_CIPHER_HW *hw, void *provctx);
132
133
# define IMPLEMENT_generic_cipher_func(alg, UCALG, lcmode, UCMODE, flags, kbits,\
134
                                      blkbits, ivbits, typ)                    \
135
const OSSL_DISPATCH ossl_##alg##kbits##lcmode##_functions[] = {                \
136
    { OSSL_FUNC_CIPHER_NEWCTX,                                                 \
137
      (void (*)(void)) alg##_##kbits##_##lcmode##_newctx },                    \
138
    { OSSL_FUNC_CIPHER_FREECTX, (void (*)(void)) alg##_freectx },              \
139
    { OSSL_FUNC_CIPHER_DUPCTX, (void (*)(void)) alg##_dupctx },                \
140
    { OSSL_FUNC_CIPHER_ENCRYPT_INIT, (void (*)(void))ossl_cipher_generic_einit },   \
141
    { OSSL_FUNC_CIPHER_DECRYPT_INIT, (void (*)(void))ossl_cipher_generic_dinit },   \
142
    { OSSL_FUNC_CIPHER_UPDATE, (void (*)(void))ossl_cipher_generic_##typ##_update },\
143
    { OSSL_FUNC_CIPHER_FINAL, (void (*)(void))ossl_cipher_generic_##typ##_final },  \
144
    { OSSL_FUNC_CIPHER_CIPHER, (void (*)(void))ossl_cipher_generic_cipher },        \
145
    { OSSL_FUNC_CIPHER_GET_PARAMS,                                             \
146
      (void (*)(void)) alg##_##kbits##_##lcmode##_get_params },                \
147
    { OSSL_FUNC_CIPHER_GET_CTX_PARAMS,                                         \
148
      (void (*)(void))ossl_cipher_generic_get_ctx_params },                    \
149
    { OSSL_FUNC_CIPHER_SET_CTX_PARAMS,                                         \
150
      (void (*)(void))ossl_cipher_generic_set_ctx_params },                    \
151
    { OSSL_FUNC_CIPHER_GETTABLE_PARAMS,                                        \
152
      (void (*)(void))ossl_cipher_generic_gettable_params },                   \
153
    { OSSL_FUNC_CIPHER_GETTABLE_CTX_PARAMS,                                    \
154
      (void (*)(void))ossl_cipher_generic_gettable_ctx_params },               \
155
    { OSSL_FUNC_CIPHER_SETTABLE_CTX_PARAMS,                                    \
156
     (void (*)(void))ossl_cipher_generic_settable_ctx_params },                \
157
    OSSL_DISPATCH_END                                                          \
158
};
159
160
# define IMPLEMENT_var_keylen_cipher_func(alg, UCALG, lcmode, UCMODE, flags,    \
161
                                         kbits, blkbits, ivbits, typ)          \
162
const OSSL_DISPATCH ossl_##alg##kbits##lcmode##_functions[] = {                \
163
    { OSSL_FUNC_CIPHER_NEWCTX,                                                 \
164
      (void (*)(void)) alg##_##kbits##_##lcmode##_newctx },                    \
165
    { OSSL_FUNC_CIPHER_FREECTX, (void (*)(void)) alg##_freectx },              \
166
    { OSSL_FUNC_CIPHER_DUPCTX, (void (*)(void)) alg##_dupctx },                \
167
    { OSSL_FUNC_CIPHER_ENCRYPT_INIT, (void (*)(void))ossl_cipher_generic_einit },\
168
    { OSSL_FUNC_CIPHER_DECRYPT_INIT, (void (*)(void))ossl_cipher_generic_dinit },\
169
    { OSSL_FUNC_CIPHER_UPDATE, (void (*)(void))ossl_cipher_generic_##typ##_update },\
170
    { OSSL_FUNC_CIPHER_FINAL, (void (*)(void))ossl_cipher_generic_##typ##_final },  \
171
    { OSSL_FUNC_CIPHER_CIPHER, (void (*)(void))ossl_cipher_generic_cipher },   \
172
    { OSSL_FUNC_CIPHER_GET_PARAMS,                                             \
173
      (void (*)(void)) alg##_##kbits##_##lcmode##_get_params },                \
174
    { OSSL_FUNC_CIPHER_GET_CTX_PARAMS,                                         \
175
      (void (*)(void))ossl_cipher_generic_get_ctx_params },                    \
176
    { OSSL_FUNC_CIPHER_SET_CTX_PARAMS,                                         \
177
      (void (*)(void))ossl_cipher_var_keylen_set_ctx_params },                 \
178
    { OSSL_FUNC_CIPHER_GETTABLE_PARAMS,                                        \
179
      (void (*)(void))ossl_cipher_generic_gettable_params },                   \
180
    { OSSL_FUNC_CIPHER_GETTABLE_CTX_PARAMS,                                    \
181
      (void (*)(void))ossl_cipher_generic_gettable_ctx_params },               \
182
    { OSSL_FUNC_CIPHER_SETTABLE_CTX_PARAMS,                                    \
183
     (void (*)(void))ossl_cipher_var_keylen_settable_ctx_params },             \
184
    OSSL_DISPATCH_END                                                          \
185
};
186
187
188
# define IMPLEMENT_generic_cipher_genfn(alg, UCALG, lcmode, UCMODE, flags,      \
189
                                       kbits, blkbits, ivbits, typ)            \
190
static OSSL_FUNC_cipher_get_params_fn alg##_##kbits##_##lcmode##_get_params;   \
191
68
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
68
{                                                                              \
193
68
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
68
                                          flags, kbits, blkbits, ivbits);      \
195
68
}                                                                              \
cipher_aes.c:aes_256_ecb_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_aes.c:aes_192_ecb_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_aes.c:aes_128_ecb_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_aes.c:aes_256_cbc_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_aes.c:aes_192_cbc_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_aes.c:aes_128_cbc_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_aes.c:aes_256_ofb_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_aes.c:aes_192_ofb_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_aes.c:aes_128_ofb_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_aes.c:aes_256_cfb_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_aes.c:aes_192_cfb_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_aes.c:aes_128_cfb_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_aes.c:aes_256_cfb1_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_aes.c:aes_192_cfb1_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_aes.c:aes_128_cfb1_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_aes.c:aes_256_cfb8_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_aes.c:aes_192_cfb8_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_aes.c:aes_128_cfb8_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_aes.c:aes_256_ctr_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_aes.c:aes_192_ctr_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_aes.c:aes_128_ctr_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_aria.c:aria_256_ecb_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_aria.c:aria_192_ecb_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_aria.c:aria_128_ecb_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_aria.c:aria_256_cbc_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_aria.c:aria_192_cbc_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_aria.c:aria_128_cbc_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_aria.c:aria_256_ofb_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_aria.c:aria_192_ofb_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_aria.c:aria_128_ofb_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_aria.c:aria_256_cfb_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_aria.c:aria_192_cfb_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_aria.c:aria_128_cfb_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_aria.c:aria_256_cfb1_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_aria.c:aria_192_cfb1_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_aria.c:aria_128_cfb1_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_aria.c:aria_256_cfb8_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_aria.c:aria_192_cfb8_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_aria.c:aria_128_cfb8_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_aria.c:aria_256_ctr_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_aria.c:aria_192_ctr_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_aria.c:aria_128_ctr_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_camellia.c:camellia_256_ecb_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_camellia.c:camellia_192_ecb_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_camellia.c:camellia_128_ecb_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_camellia.c:camellia_256_cbc_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_camellia.c:camellia_192_cbc_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_camellia.c:camellia_128_cbc_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_camellia.c:camellia_256_ofb_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_camellia.c:camellia_192_ofb_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_camellia.c:camellia_128_ofb_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_camellia.c:camellia_256_cfb_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_camellia.c:camellia_192_cfb_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_camellia.c:camellia_128_cfb_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_camellia.c:camellia_256_cfb1_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_camellia.c:camellia_192_cfb1_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_camellia.c:camellia_128_cfb1_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_camellia.c:camellia_256_cfb8_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_camellia.c:camellia_192_cfb8_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_camellia.c:camellia_128_cfb8_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_camellia.c:camellia_256_ctr_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_camellia.c:camellia_192_ctr_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_camellia.c:camellia_128_ctr_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_sm4.c:sm4_128_ecb_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_sm4.c:sm4_128_cbc_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_sm4.c:sm4_128_ctr_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_sm4.c:sm4_128_ofb128_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
cipher_sm4.c:sm4_128_cfb128_get_params
Line
Count
Source
191
1
static int alg##_##kbits##_##lcmode##_get_params(OSSL_PARAM params[])          \
192
1
{                                                                              \
193
1
    return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
194
1
                                          flags, kbits, blkbits, ivbits);      \
195
1
}                                                                              \
196
static OSSL_FUNC_cipher_newctx_fn alg##_##kbits##_##lcmode##_newctx;           \
197
5
static void * alg##_##kbits##_##lcmode##_newctx(void *provctx)                 \
198
5
{                                                                              \
199
5
     PROV_##UCALG##_CTX *ctx = ossl_prov_is_running() ? OPENSSL_zalloc(sizeof(*ctx))\
200
5
                                                     : NULL;                   \
201
5
     if (ctx != NULL) {                                                        \
202
5
         ossl_cipher_generic_initkey(ctx, kbits, blkbits, ivbits,              \
203
5
                                     EVP_CIPH_##UCMODE##_MODE, flags,          \
204
5
                                     ossl_prov_cipher_hw_##alg##_##lcmode(kbits),\
205
5
                                     provctx);                                 \
206
5
     }                                                                         \
207
5
     return ctx;                                                               \
208
5
}                                                                              \
cipher_aes.c:aes_256_ecb_newctx
Line
Count
Source
197
3
static void * alg##_##kbits##_##lcmode##_newctx(void *provctx)                 \
198
3
{                                                                              \
199
3
     PROV_##UCALG##_CTX *ctx = ossl_prov_is_running() ? OPENSSL_zalloc(sizeof(*ctx))\
200
3
                                                     : NULL;                   \
201
3
     if (ctx != NULL) {                                                        \
202
3
         ossl_cipher_generic_initkey(ctx, kbits, blkbits, ivbits,              \
203
3
                                     EVP_CIPH_##UCMODE##_MODE, flags,          \
204
3
                                     ossl_prov_cipher_hw_##alg##_##lcmode(kbits),\
205
3
                                     provctx);                                 \
206
3
     }                                                                         \
207
3
     return ctx;                                                               \
208
3
}                                                                              \
Unexecuted instantiation: cipher_aes.c:aes_192_ecb_newctx
Unexecuted instantiation: cipher_aes.c:aes_128_ecb_newctx
Unexecuted instantiation: cipher_aes.c:aes_256_cbc_newctx
Unexecuted instantiation: cipher_aes.c:aes_192_cbc_newctx
Unexecuted instantiation: cipher_aes.c:aes_128_cbc_newctx
Unexecuted instantiation: cipher_aes.c:aes_256_ofb_newctx
Unexecuted instantiation: cipher_aes.c:aes_192_ofb_newctx
Unexecuted instantiation: cipher_aes.c:aes_128_ofb_newctx
Unexecuted instantiation: cipher_aes.c:aes_256_cfb_newctx
Unexecuted instantiation: cipher_aes.c:aes_192_cfb_newctx
Unexecuted instantiation: cipher_aes.c:aes_128_cfb_newctx
Unexecuted instantiation: cipher_aes.c:aes_256_cfb1_newctx
Unexecuted instantiation: cipher_aes.c:aes_192_cfb1_newctx
Unexecuted instantiation: cipher_aes.c:aes_128_cfb1_newctx
Unexecuted instantiation: cipher_aes.c:aes_256_cfb8_newctx
Unexecuted instantiation: cipher_aes.c:aes_192_cfb8_newctx
Unexecuted instantiation: cipher_aes.c:aes_128_cfb8_newctx
cipher_aes.c:aes_256_ctr_newctx
Line
Count
Source
197
2
static void * alg##_##kbits##_##lcmode##_newctx(void *provctx)                 \
198
2
{                                                                              \
199
2
     PROV_##UCALG##_CTX *ctx = ossl_prov_is_running() ? OPENSSL_zalloc(sizeof(*ctx))\
200
2
                                                     : NULL;                   \
201
2
     if (ctx != NULL) {                                                        \
202
2
         ossl_cipher_generic_initkey(ctx, kbits, blkbits, ivbits,              \
203
2
                                     EVP_CIPH_##UCMODE##_MODE, flags,          \
204
2
                                     ossl_prov_cipher_hw_##alg##_##lcmode(kbits),\
205
2
                                     provctx);                                 \
206
2
     }                                                                         \
207
2
     return ctx;                                                               \
208
2
}                                                                              \
Unexecuted instantiation: cipher_aes.c:aes_192_ctr_newctx
Unexecuted instantiation: cipher_aes.c:aes_128_ctr_newctx
Unexecuted instantiation: cipher_aria.c:aria_256_ecb_newctx
Unexecuted instantiation: cipher_aria.c:aria_192_ecb_newctx
Unexecuted instantiation: cipher_aria.c:aria_128_ecb_newctx
Unexecuted instantiation: cipher_aria.c:aria_256_cbc_newctx
Unexecuted instantiation: cipher_aria.c:aria_192_cbc_newctx
Unexecuted instantiation: cipher_aria.c:aria_128_cbc_newctx
Unexecuted instantiation: cipher_aria.c:aria_256_ofb_newctx
Unexecuted instantiation: cipher_aria.c:aria_192_ofb_newctx
Unexecuted instantiation: cipher_aria.c:aria_128_ofb_newctx
Unexecuted instantiation: cipher_aria.c:aria_256_cfb_newctx
Unexecuted instantiation: cipher_aria.c:aria_192_cfb_newctx
Unexecuted instantiation: cipher_aria.c:aria_128_cfb_newctx
Unexecuted instantiation: cipher_aria.c:aria_256_cfb1_newctx
Unexecuted instantiation: cipher_aria.c:aria_192_cfb1_newctx
Unexecuted instantiation: cipher_aria.c:aria_128_cfb1_newctx
Unexecuted instantiation: cipher_aria.c:aria_256_cfb8_newctx
Unexecuted instantiation: cipher_aria.c:aria_192_cfb8_newctx
Unexecuted instantiation: cipher_aria.c:aria_128_cfb8_newctx
Unexecuted instantiation: cipher_aria.c:aria_256_ctr_newctx
Unexecuted instantiation: cipher_aria.c:aria_192_ctr_newctx
Unexecuted instantiation: cipher_aria.c:aria_128_ctr_newctx
Unexecuted instantiation: cipher_camellia.c:camellia_256_ecb_newctx
Unexecuted instantiation: cipher_camellia.c:camellia_192_ecb_newctx
Unexecuted instantiation: cipher_camellia.c:camellia_128_ecb_newctx
Unexecuted instantiation: cipher_camellia.c:camellia_256_cbc_newctx
Unexecuted instantiation: cipher_camellia.c:camellia_192_cbc_newctx
Unexecuted instantiation: cipher_camellia.c:camellia_128_cbc_newctx
Unexecuted instantiation: cipher_camellia.c:camellia_256_ofb_newctx
Unexecuted instantiation: cipher_camellia.c:camellia_192_ofb_newctx
Unexecuted instantiation: cipher_camellia.c:camellia_128_ofb_newctx
Unexecuted instantiation: cipher_camellia.c:camellia_256_cfb_newctx
Unexecuted instantiation: cipher_camellia.c:camellia_192_cfb_newctx
Unexecuted instantiation: cipher_camellia.c:camellia_128_cfb_newctx
Unexecuted instantiation: cipher_camellia.c:camellia_256_cfb1_newctx
Unexecuted instantiation: cipher_camellia.c:camellia_192_cfb1_newctx
Unexecuted instantiation: cipher_camellia.c:camellia_128_cfb1_newctx
Unexecuted instantiation: cipher_camellia.c:camellia_256_cfb8_newctx
Unexecuted instantiation: cipher_camellia.c:camellia_192_cfb8_newctx
Unexecuted instantiation: cipher_camellia.c:camellia_128_cfb8_newctx
Unexecuted instantiation: cipher_camellia.c:camellia_256_ctr_newctx
Unexecuted instantiation: cipher_camellia.c:camellia_192_ctr_newctx
Unexecuted instantiation: cipher_camellia.c:camellia_128_ctr_newctx
Unexecuted instantiation: cipher_sm4.c:sm4_128_ecb_newctx
Unexecuted instantiation: cipher_sm4.c:sm4_128_cbc_newctx
Unexecuted instantiation: cipher_sm4.c:sm4_128_ctr_newctx
Unexecuted instantiation: cipher_sm4.c:sm4_128_ofb128_newctx
Unexecuted instantiation: cipher_sm4.c:sm4_128_cfb128_newctx
209
210
# define IMPLEMENT_generic_cipher(alg, UCALG, lcmode, UCMODE, flags, kbits,     \
211
                                 blkbits, ivbits, typ)                         \
212
IMPLEMENT_generic_cipher_genfn(alg, UCALG, lcmode, UCMODE, flags, kbits,       \
213
                               blkbits, ivbits, typ)                           \
214
IMPLEMENT_generic_cipher_func(alg, UCALG, lcmode, UCMODE, flags, kbits,        \
215
                              blkbits, ivbits, typ)
216
217
# define IMPLEMENT_var_keylen_cipher(alg, UCALG, lcmode, UCMODE, flags, kbits,  \
218
                                    blkbits, ivbits, typ)                      \
219
IMPLEMENT_generic_cipher_genfn(alg, UCALG, lcmode, UCMODE, flags, kbits,       \
220
                               blkbits, ivbits, typ)                           \
221
IMPLEMENT_var_keylen_cipher_func(alg, UCALG, lcmode, UCMODE, flags, kbits,     \
222
                                 blkbits, ivbits, typ)
223
224
PROV_CIPHER_HW_FN ossl_cipher_hw_generic_cbc;
225
PROV_CIPHER_HW_FN ossl_cipher_hw_generic_ecb;
226
PROV_CIPHER_HW_FN ossl_cipher_hw_generic_ofb128;
227
PROV_CIPHER_HW_FN ossl_cipher_hw_generic_cfb128;
228
PROV_CIPHER_HW_FN ossl_cipher_hw_generic_cfb8;
229
PROV_CIPHER_HW_FN ossl_cipher_hw_generic_cfb1;
230
PROV_CIPHER_HW_FN ossl_cipher_hw_generic_ctr;
231
PROV_CIPHER_HW_FN ossl_cipher_hw_chunked_cbc;
232
PROV_CIPHER_HW_FN ossl_cipher_hw_chunked_cfb8;
233
PROV_CIPHER_HW_FN ossl_cipher_hw_chunked_cfb128;
234
PROV_CIPHER_HW_FN ossl_cipher_hw_chunked_ofb128;
235
# define ossl_cipher_hw_chunked_ecb  ossl_cipher_hw_generic_ecb
236
# define ossl_cipher_hw_chunked_ctr  ossl_cipher_hw_generic_ctr
237
# define ossl_cipher_hw_chunked_cfb1 ossl_cipher_hw_generic_cfb1
238
239
# define IMPLEMENT_CIPHER_HW_OFB(MODE, NAME, CTX_NAME, KEY_NAME, FUNC_PREFIX)   \
240
static int cipher_hw_##NAME##_##MODE##_cipher(PROV_CIPHER_CTX *ctx,            \
241
                                         unsigned char *out,                   \
242
                                         const unsigned char *in, size_t len)  \
243
{                                                                              \
244
    int num = ctx->num;                                                        \
245
    KEY_NAME *key = &(((CTX_NAME *)ctx)->ks.ks);                               \
246
                                                                               \
247
    while (len >= MAXCHUNK) {                                                  \
248
        FUNC_PREFIX##_encrypt(in, out, MAXCHUNK, key, ctx->iv, &num);          \
249
        len -= MAXCHUNK;                                                       \
250
        in += MAXCHUNK;                                                        \
251
        out += MAXCHUNK;                                                       \
252
    }                                                                          \
253
    if (len > 0) {                                                             \
254
        FUNC_PREFIX##_encrypt(in, out, (long)len, key, ctx->iv, &num);         \
255
    }                                                                          \
256
    ctx->num = num;                                                            \
257
    return 1;                                                                  \
258
}
259
260
# define IMPLEMENT_CIPHER_HW_ECB(MODE, NAME, CTX_NAME, KEY_NAME, FUNC_PREFIX)   \
261
static int cipher_hw_##NAME##_##MODE##_cipher(PROV_CIPHER_CTX *ctx,            \
262
                                         unsigned char *out,                   \
263
                                         const unsigned char *in, size_t len)  \
264
{                                                                              \
265
    size_t i, bl = ctx->blocksize;                                             \
266
    KEY_NAME *key = &(((CTX_NAME *)ctx)->ks.ks);                               \
267
                                                                               \
268
    if (len < bl)                                                              \
269
        return 1;                                                              \
270
    for (i = 0, len -= bl; i <= len; i += bl)                                  \
271
        FUNC_PREFIX##_encrypt(in + i, out + i, key, ctx->enc);                 \
272
    return 1;                                                                  \
273
}
274
275
# define IMPLEMENT_CIPHER_HW_CBC(MODE, NAME, CTX_NAME, KEY_NAME, FUNC_PREFIX)   \
276
static int cipher_hw_##NAME##_##MODE##_cipher(PROV_CIPHER_CTX *ctx,            \
277
                                         unsigned char *out,                   \
278
                                         const unsigned char *in, size_t len)  \
279
{                                                                              \
280
    KEY_NAME *key = &(((CTX_NAME *)ctx)->ks.ks);                               \
281
                                                                               \
282
    while (len >= MAXCHUNK) {                                                  \
283
        FUNC_PREFIX##_encrypt(in, out, MAXCHUNK, key, ctx->iv, ctx->enc);      \
284
        len -= MAXCHUNK;                                                       \
285
        in += MAXCHUNK;                                                        \
286
        out += MAXCHUNK;                                                       \
287
    }                                                                          \
288
    if (len > 0)                                                               \
289
        FUNC_PREFIX##_encrypt(in, out, (long)len, key, ctx->iv, ctx->enc);     \
290
    return 1;                                                                  \
291
}
292
293
# define IMPLEMENT_CIPHER_HW_CFB(MODE, NAME, CTX_NAME, KEY_NAME, FUNC_PREFIX)   \
294
static int cipher_hw_##NAME##_##MODE##_cipher(PROV_CIPHER_CTX *ctx,            \
295
                                         unsigned char *out,                   \
296
                                         const unsigned char *in, size_t len)  \
297
{                                                                              \
298
    size_t chunk = MAXCHUNK;                                                   \
299
    KEY_NAME *key = &(((CTX_NAME *)ctx)->ks.ks);                               \
300
    int num = ctx->num;                                                        \
301
                                                                               \
302
    if (len < chunk)                                                           \
303
        chunk = len;                                                           \
304
    while (len > 0 && len >= chunk) {                                          \
305
        FUNC_PREFIX##_encrypt(in, out, (long)chunk, key, ctx->iv, &num,        \
306
                              ctx->enc);                                       \
307
        len -= chunk;                                                          \
308
        in += chunk;                                                           \
309
        out += chunk;                                                          \
310
        if (len < chunk)                                                       \
311
            chunk = len;                                                       \
312
    }                                                                          \
313
    ctx->num = num;                                                            \
314
    return 1;                                                                  \
315
}
316
317
# define IMPLEMENT_CIPHER_HW_COPYCTX(name, CTX_TYPE)                            \
318
0
static void name(PROV_CIPHER_CTX *dst, const PROV_CIPHER_CTX *src)             \
319
0
{                                                                              \
320
0
    CTX_TYPE *sctx = (CTX_TYPE *)src;                                          \
321
0
    CTX_TYPE *dctx = (CTX_TYPE *)dst;                                          \
322
0
                                                                               \
323
0
    *dctx = *sctx;                                                             \
324
0
    dst->ks = &dctx->ks.ks;                                                    \
325
0
}
Unexecuted instantiation: cipher_aes_hw.c:cipher_hw_aes_copyctx
Unexecuted instantiation: cipher_aria_hw.c:cipher_hw_aria_copyctx
Unexecuted instantiation: cipher_camellia_hw.c:cipher_hw_camellia_copyctx
Unexecuted instantiation: cipher_sm4_hw.c:cipher_hw_sm4_copyctx
326
327
# define CIPHER_DEFAULT_GETTABLE_CTX_PARAMS_START(name)                         \
328
static const OSSL_PARAM name##_known_gettable_ctx_params[] = {                 \
329
    OSSL_PARAM_size_t(OSSL_CIPHER_PARAM_KEYLEN, NULL),                         \
330
    OSSL_PARAM_size_t(OSSL_CIPHER_PARAM_IVLEN, NULL),                          \
331
    OSSL_PARAM_uint(OSSL_CIPHER_PARAM_PADDING, NULL),                          \
332
    OSSL_PARAM_uint(OSSL_CIPHER_PARAM_NUM, NULL),                              \
333
    OSSL_PARAM_octet_string(OSSL_CIPHER_PARAM_IV, NULL, 0),                    \
334
    OSSL_PARAM_octet_string(OSSL_CIPHER_PARAM_UPDATED_IV, NULL, 0),
335
336
# define CIPHER_DEFAULT_GETTABLE_CTX_PARAMS_END(name)                           \
337
    OSSL_PARAM_END                                                             \
338
};                                                                             \
339
const OSSL_PARAM * name##_gettable_ctx_params(ossl_unused void *cctx,          \
340
100
                                              ossl_unused void *provctx)       \
341
100
{                                                                              \
342
100
    return name##_known_gettable_ctx_params;                                   \
343
100
}
cipher_aes.c:aes_cbc_cts_gettable_ctx_params
Line
Count
Source
340
3
                                              ossl_unused void *provctx)       \
341
3
{                                                                              \
342
3
    return name##_known_gettable_ctx_params;                                   \
343
3
}
cipher_camellia.c:camellia_cbc_cts_gettable_ctx_params
Line
Count
Source
340
3
                                              ossl_unused void *provctx)       \
341
3
{                                                                              \
342
3
    return name##_known_gettable_ctx_params;                                   \
343
3
}
ossl_tdes_gettable_ctx_params
Line
Count
Source
340
11
                                              ossl_unused void *provctx)       \
341
11
{                                                                              \
342
11
    return name##_known_gettable_ctx_params;                                   \
343
11
}
ossl_cipher_generic_gettable_ctx_params
Line
Count
Source
340
83
                                              ossl_unused void *provctx)       \
341
83
{                                                                              \
342
83
    return name##_known_gettable_ctx_params;                                   \
343
83
}
344
345
# define CIPHER_DEFAULT_SETTABLE_CTX_PARAMS_START(name)                         \
346
static const OSSL_PARAM name##_known_settable_ctx_params[] = {                 \
347
    OSSL_PARAM_uint(OSSL_CIPHER_PARAM_PADDING, NULL),                          \
348
    OSSL_PARAM_uint(OSSL_CIPHER_PARAM_NUM, NULL),
349
# define CIPHER_DEFAULT_SETTABLE_CTX_PARAMS_END(name)                           \
350
    OSSL_PARAM_END                                                             \
351
};                                                                             \
352
const OSSL_PARAM * name##_settable_ctx_params(ossl_unused void *cctx,          \
353
0
                                              ossl_unused void *provctx)       \
354
0
{                                                                              \
355
0
    return name##_known_settable_ctx_params;                                   \
356
0
}
Unexecuted instantiation: cipher_aes.c:aes_cbc_cts_settable_ctx_params
Unexecuted instantiation: cipher_camellia.c:camellia_cbc_cts_settable_ctx_params
Unexecuted instantiation: ossl_cipher_generic_settable_ctx_params
Unexecuted instantiation: ossl_cipher_var_keylen_settable_ctx_params
357
358
int ossl_cipher_generic_initiv(PROV_CIPHER_CTX *ctx, const unsigned char *iv,
359
                               size_t ivlen);
360
361
size_t ossl_cipher_fillblock(unsigned char *buf, size_t *buflen,
362
                             size_t blocksize,
363
                             const unsigned char **in, size_t *inlen);
364
int ossl_cipher_trailingdata(unsigned char *buf, size_t *buflen,
365
                             size_t blocksize,
366
                             const unsigned char **in, size_t *inlen);
367
368
#endif