digest_common.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * Copyright 2019 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. #include "openssl/err.h"
  10. #include "internal/digestcommon.h"
  11. #include "internal/providercommonerr.h"
  12. int digest_default_get_params(OSSL_PARAM params[], size_t blksz, size_t paramsz,
  13. unsigned long flags)
  14. {
  15. OSSL_PARAM *p = NULL;
  16. p = OSSL_PARAM_locate(params, OSSL_DIGEST_PARAM_BLOCK_SIZE);
  17. if (p != NULL && !OSSL_PARAM_set_size_t(p, blksz)) {
  18. ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_SET_PARAMETER);
  19. return 0;
  20. }
  21. p = OSSL_PARAM_locate(params, OSSL_DIGEST_PARAM_SIZE);
  22. if (p != NULL && !OSSL_PARAM_set_size_t(p, paramsz)) {
  23. ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_SET_PARAMETER);
  24. return 0;
  25. }
  26. p = OSSL_PARAM_locate(params, OSSL_DIGEST_PARAM_FLAGS);
  27. if (p != NULL && !OSSL_PARAM_set_ulong(p, flags)) {
  28. ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_SET_PARAMETER);
  29. return 0;
  30. }
  31. return 1;
  32. }
  33. static const OSSL_PARAM digest_default_known_gettable_params[] = {
  34. OSSL_PARAM_size_t(OSSL_DIGEST_PARAM_BLOCK_SIZE, NULL),
  35. OSSL_PARAM_size_t(OSSL_DIGEST_PARAM_SIZE, NULL),
  36. OSSL_PARAM_ulong(OSSL_DIGEST_PARAM_FLAGS, NULL),
  37. OSSL_PARAM_END
  38. };
  39. const OSSL_PARAM *digest_default_gettable_params(void)
  40. {
  41. return digest_default_known_gettable_params;
  42. }