2
0

md5_sha1_prov.c 2.0 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. * MD5 and SHA-1 low level APIs are deprecated for public use, but still ok for
  11. * internal use.
  12. */
  13. #include "internal/deprecated.h"
  14. #include <string.h>
  15. #include <openssl/crypto.h>
  16. #include <openssl/evp.h>
  17. #include <openssl/params.h>
  18. #include <openssl/core_names.h>
  19. #include "prov/md5_sha1.h"
  20. #include "prov/digestcommon.h"
  21. #include "prov/implementations.h"
  22. static OSSL_FUNC_digest_set_ctx_params_fn md5_sha1_set_ctx_params;
  23. static OSSL_FUNC_digest_settable_ctx_params_fn md5_sha1_settable_ctx_params;
  24. static const OSSL_PARAM known_md5_sha1_settable_ctx_params[] = {
  25. {OSSL_DIGEST_PARAM_SSL3_MS, OSSL_PARAM_OCTET_STRING, NULL, 0, 0},
  26. OSSL_PARAM_END
  27. };
  28. static const OSSL_PARAM *md5_sha1_settable_ctx_params(ossl_unused void *ctx,
  29. ossl_unused void *provctx)
  30. {
  31. return known_md5_sha1_settable_ctx_params;
  32. }
  33. /* Special set_params method for SSL3 */
  34. static int md5_sha1_set_ctx_params(void *vctx, const OSSL_PARAM params[])
  35. {
  36. const OSSL_PARAM *p;
  37. MD5_SHA1_CTX *ctx = (MD5_SHA1_CTX *)vctx;
  38. if (ctx == NULL)
  39. return 0;
  40. if (params == NULL)
  41. return 1;
  42. p = OSSL_PARAM_locate_const(params, OSSL_DIGEST_PARAM_SSL3_MS);
  43. if (p != NULL && p->data_type == OSSL_PARAM_OCTET_STRING)
  44. return ossl_md5_sha1_ctrl(ctx, EVP_CTRL_SSL3_MASTER_SECRET,
  45. p->data_size, p->data);
  46. return 1;
  47. }
  48. /* ossl_md5_sha1_functions */
  49. IMPLEMENT_digest_functions_with_settable_ctx(
  50. md5_sha1, MD5_SHA1_CTX, MD5_SHA1_CBLOCK, MD5_SHA1_DIGEST_LENGTH, 0,
  51. ossl_md5_sha1_init, ossl_md5_sha1_update, ossl_md5_sha1_final,
  52. md5_sha1_settable_ctx_params, md5_sha1_set_ctx_params)