gettables: provider changes to pass the provider context.
[openssl.git] / providers / implementations / digests / sha3_prov.c
index 5adc7b2976b73b21ef80f71b7c1f55a4ce2597f7..0703dbe9e0910416e923b55e77a01fa1c3c39adb 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2019-2020 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
 #include <openssl/err.h>
 #include "internal/sha3.h"
 #include "prov/digestcommon.h"
-#include "internal/provider_algs.h"
-#include "internal/providercommonerr.h"
+#include "prov/implementations.h"
+#include "prov/providercommonerr.h"
 
 /*
  * Forward declaration of any unique methods implemented here. This is not strictly
  * necessary for the compiler, but provides an assurance that the signatures
  * of the functions in the dispatch table are correct.
  */
-static OSSL_OP_digest_init_fn keccak_init;
-static OSSL_OP_digest_update_fn keccak_update;
-static OSSL_OP_digest_final_fn keccak_final;
-static OSSL_OP_digest_freectx_fn keccak_freectx;
-static OSSL_OP_digest_dupctx_fn keccak_dupctx;
-static OSSL_OP_digest_set_ctx_params_fn shake_set_ctx_params;
-static OSSL_OP_digest_settable_ctx_params_fn shake_settable_ctx_params;
+static OSSL_FUNC_digest_init_fn keccak_init;
+static OSSL_FUNC_digest_update_fn keccak_update;
+static OSSL_FUNC_digest_final_fn keccak_final;
+static OSSL_FUNC_digest_freectx_fn keccak_freectx;
+static OSSL_FUNC_digest_dupctx_fn keccak_dupctx;
+static OSSL_FUNC_digest_set_ctx_params_fn shake_set_ctx_params;
+static OSSL_FUNC_digest_settable_ctx_params_fn shake_settable_ctx_params;
 static sha3_absorb_fn generic_sha3_absorb;
 static sha3_final_fn generic_sha3_final;
 
@@ -182,7 +182,7 @@ static PROV_SHA3_METHOD shake_s390x_md =
 #endif /* S390_SHA3 */
 
 #define SHA3_newctx(typ, uname, name, bitlen, pad)                             \
-static OSSL_OP_digest_newctx_fn name##_newctx;                                 \
+static OSSL_FUNC_digest_newctx_fn name##_newctx;                               \
 static void *name##_newctx(void *provctx)                                      \
 {                                                                              \
     KECCAK1600_CTX *ctx = OPENSSL_zalloc(sizeof(*ctx));                        \
@@ -195,7 +195,7 @@ static void *name##_newctx(void *provctx)                                      \
 }
 
 #define KMAC_newctx(uname, bitlen, pad)                                        \
-static OSSL_OP_digest_newctx_fn uname##_newctx;                                \
+static OSSL_FUNC_digest_newctx_fn uname##_newctx;                              \
 static void *uname##_newctx(void *provctx)                                     \
 {                                                                              \
     KECCAK1600_CTX *ctx = OPENSSL_zalloc(sizeof(*ctx));                        \
@@ -241,15 +241,16 @@ static void *keccak_dupctx(void *ctx)
     KECCAK1600_CTX *in = (KECCAK1600_CTX *)ctx;
     KECCAK1600_CTX *ret = OPENSSL_malloc(sizeof(*ret));
 
-    *ret = *in;
+    if (ret != NULL)
+        *ret = *in;
     return ret;
 }
 
 static const OSSL_PARAM known_shake_settable_ctx_params[] = {
-    {OSSL_DIGEST_PARAM_SSL3_MS, OSSL_PARAM_OCTET_STRING, NULL, 0, 0},
+    {OSSL_DIGEST_PARAM_XOFLEN, OSSL_PARAM_UNSIGNED_INTEGER, NULL, 0, 0},
     OSSL_PARAM_END
 };
-static const OSSL_PARAM *shake_settable_ctx_params(void)
+static const OSSL_PARAM *shake_settable_ctx_params(void *provctx)
 {
     return known_shake_settable_ctx_params;
 }