Make more use of OSSL_PARAM for ciphers
authorRichard Levitte <levitte@openssl.org>
Tue, 9 Jul 2019 05:27:27 +0000 (07:27 +0200)
committerRichard Levitte <levitte@openssl.org>
Thu, 11 Jul 2019 05:27:02 +0000 (07:27 +0200)
A lot of the different numbers associated with ciphers are really
algorithm parameters.  Key length, block size, IV length, that sort of
thing.

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/9328)

crypto/include/internal/evp_int.h
include/openssl/core_names.h
include/openssl/core_numbers.h

index 732fad8d6795dd042a0103b48d8a40ee3b2a9c69..da4ae0f1fb5c072ba6e33cb9f3017cf2e73fc95b 100644 (file)
@@ -257,9 +257,6 @@ struct evp_cipher_st {
     OSSL_OP_cipher_cipher_fn *ccipher;
     OSSL_OP_cipher_freectx_fn *freectx;
     OSSL_OP_cipher_dupctx_fn *dupctx;
-    OSSL_OP_cipher_key_length_fn *key_length;
-    OSSL_OP_cipher_iv_length_fn *iv_length;
-    OSSL_OP_cipher_block_size_fn *blocksize;
     OSSL_OP_cipher_get_params_fn *get_params;
     OSSL_OP_cipher_ctx_get_params_fn *ctx_get_params;
     OSSL_OP_cipher_ctx_set_params_fn *ctx_set_params;
index a9a3b448e5ec50098bac875f701266794ec7a54a..e4dd7330178ed6736a5c37b5a957ff49c9b0ca94 100644 (file)
@@ -39,6 +39,12 @@ extern "C" {
 
 #define OSSL_CIPHER_PARAM_PADDING   "padding"
 #define OSSL_CIPHER_PARAM_MODE      "mode"
+#define OSSL_CIPHER_PARAM_BLOCK_SIZE "blocksize" /* OSSL_PARAM_INTEGER */
+#define OSSL_CIPHER_PARAM_FLAGS     "flags" /* OSSL_PARAM_UNSIGNED_INTEGER */
+#define OSSL_CIPHER_PARAM_KEYLEN    "keylen" /* OSSL_PARAM_INTEGER */
+#define OSSL_CIPHER_PARAM_IVLEN     "ivlen"  /* OSSL_PARAM_INTEGER */
+#define OSSL_CIPHER_PARAM_IV        "iv"  /* OSSL_PARAM_OCTET_PTR */
+#define OSSL_CIPHER_PARAM_NUM       "num" /* OSSL_PARAM_INTEGER */
 
 /* digest parameters */
 #define OSSL_DIGEST_PARAM_XOFLEN    "xoflen"
index ff50636ab5d5a5a6e39831e65337d0827ecb9100..0901ed376dbd5dbf33c695759c7d7bbf9f86f031 100644 (file)
@@ -139,12 +139,9 @@ OSSL_CORE_MAKE_FUNC(int, OP_digest_get_params,
 # define OSSL_FUNC_CIPHER_CIPHER                     6
 # define OSSL_FUNC_CIPHER_FREECTX                    7
 # define OSSL_FUNC_CIPHER_DUPCTX                     8
-# define OSSL_FUNC_CIPHER_KEY_LENGTH                 9
-# define OSSL_FUNC_CIPHER_IV_LENGTH                 10
-# define OSSL_FUNC_CIPHER_BLOCK_SIZE                11
-# define OSSL_FUNC_CIPHER_GET_PARAMS                12
-# define OSSL_FUNC_CIPHER_CTX_GET_PARAMS            13
-# define OSSL_FUNC_CIPHER_CTX_SET_PARAMS            14
+# define OSSL_FUNC_CIPHER_GET_PARAMS                 9
+# define OSSL_FUNC_CIPHER_CTX_GET_PARAMS            10
+# define OSSL_FUNC_CIPHER_CTX_SET_PARAMS            11
 
 OSSL_CORE_MAKE_FUNC(void *, OP_cipher_newctx, (void *provctx))
 OSSL_CORE_MAKE_FUNC(int, OP_cipher_encrypt_init, (void *cctx,
@@ -170,9 +167,6 @@ OSSL_CORE_MAKE_FUNC(int, OP_cipher_cipher,
                      const unsigned char *in, size_t inl))
 OSSL_CORE_MAKE_FUNC(void, OP_cipher_freectx, (void *cctx))
 OSSL_CORE_MAKE_FUNC(void *, OP_cipher_dupctx, (void *cctx))
-OSSL_CORE_MAKE_FUNC(size_t, OP_cipher_key_length, (void))
-OSSL_CORE_MAKE_FUNC(size_t, OP_cipher_iv_length, (void))
-OSSL_CORE_MAKE_FUNC(size_t, OP_cipher_block_size, (void))
 OSSL_CORE_MAKE_FUNC(int, OP_cipher_get_params, (OSSL_PARAM params[]))
 OSSL_CORE_MAKE_FUNC(int, OP_cipher_ctx_get_params, (void *cctx,
                                                     OSSL_PARAM params[]))