mdc2_prov.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * Copyright 2019-2021 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. * MDC2 low level APIs are deprecated for public use, but still ok for
  11. * internal use.
  12. */
  13. #include "internal/deprecated.h"
  14. #include <openssl/crypto.h>
  15. #include <openssl/params.h>
  16. #include <openssl/mdc2.h>
  17. #include <openssl/core_names.h>
  18. #include <openssl/err.h>
  19. #include <openssl/proverr.h>
  20. #include "prov/digestcommon.h"
  21. #include "prov/implementations.h"
  22. static OSSL_FUNC_digest_set_ctx_params_fn mdc2_set_ctx_params;
  23. static OSSL_FUNC_digest_settable_ctx_params_fn mdc2_settable_ctx_params;
  24. static const OSSL_PARAM known_mdc2_settable_ctx_params[] = {
  25. OSSL_PARAM_uint(OSSL_DIGEST_PARAM_PAD_TYPE, NULL),
  26. OSSL_PARAM_END
  27. };
  28. static const OSSL_PARAM *mdc2_settable_ctx_params(ossl_unused void *ctx,
  29. ossl_unused void *provctx)
  30. {
  31. return known_mdc2_settable_ctx_params;
  32. }
  33. static int mdc2_set_ctx_params(void *vctx, const OSSL_PARAM params[])
  34. {
  35. const OSSL_PARAM *p;
  36. MDC2_CTX *ctx = (MDC2_CTX *)vctx;
  37. if (ctx == NULL)
  38. return 0;
  39. if (params == NULL)
  40. return 1;
  41. p = OSSL_PARAM_locate_const(params, OSSL_DIGEST_PARAM_PAD_TYPE);
  42. if (p != NULL && !OSSL_PARAM_get_uint(p, &ctx->pad_type)) {
  43. ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_GET_PARAMETER);
  44. return 0;
  45. }
  46. return 1;
  47. }
  48. /* ossl_mdc2_functions */
  49. IMPLEMENT_digest_functions_with_settable_ctx(
  50. mdc2, MDC2_CTX, MDC2_BLOCK, MDC2_DIGEST_LENGTH, 0,
  51. MDC2_Init, MDC2_Update, MDC2_Final,
  52. mdc2_settable_ctx_params, mdc2_set_ctx_params)