1e1051a39Sopenharmony_ci/* 2e1051a39Sopenharmony_ci * Copyright 2019-2021 The OpenSSL Project Authors. All Rights Reserved. 3e1051a39Sopenharmony_ci * 4e1051a39Sopenharmony_ci * Licensed under the Apache License 2.0 (the "License"). You may not use 5e1051a39Sopenharmony_ci * this file except in compliance with the License. You can obtain a copy 6e1051a39Sopenharmony_ci * in the file LICENSE in the source distribution or at 7e1051a39Sopenharmony_ci * https://www.openssl.org/source/license.html 8e1051a39Sopenharmony_ci */ 9e1051a39Sopenharmony_ci 10e1051a39Sopenharmony_ci/* 11e1051a39Sopenharmony_ci * MD5 and SHA-1 low level APIs are deprecated for public use, but still ok for 12e1051a39Sopenharmony_ci * internal use. 13e1051a39Sopenharmony_ci */ 14e1051a39Sopenharmony_ci#include "internal/deprecated.h" 15e1051a39Sopenharmony_ci 16e1051a39Sopenharmony_ci#include <string.h> 17e1051a39Sopenharmony_ci#include <openssl/crypto.h> 18e1051a39Sopenharmony_ci#include <openssl/evp.h> 19e1051a39Sopenharmony_ci#include <openssl/params.h> 20e1051a39Sopenharmony_ci#include <openssl/core_names.h> 21e1051a39Sopenharmony_ci#include "prov/md5_sha1.h" 22e1051a39Sopenharmony_ci#include "prov/digestcommon.h" 23e1051a39Sopenharmony_ci#include "prov/implementations.h" 24e1051a39Sopenharmony_ci 25e1051a39Sopenharmony_cistatic OSSL_FUNC_digest_set_ctx_params_fn md5_sha1_set_ctx_params; 26e1051a39Sopenharmony_cistatic OSSL_FUNC_digest_settable_ctx_params_fn md5_sha1_settable_ctx_params; 27e1051a39Sopenharmony_ci 28e1051a39Sopenharmony_cistatic const OSSL_PARAM known_md5_sha1_settable_ctx_params[] = { 29e1051a39Sopenharmony_ci {OSSL_DIGEST_PARAM_SSL3_MS, OSSL_PARAM_OCTET_STRING, NULL, 0, 0}, 30e1051a39Sopenharmony_ci OSSL_PARAM_END 31e1051a39Sopenharmony_ci}; 32e1051a39Sopenharmony_ci 33e1051a39Sopenharmony_cistatic const OSSL_PARAM *md5_sha1_settable_ctx_params(ossl_unused void *ctx, 34e1051a39Sopenharmony_ci ossl_unused void *provctx) 35e1051a39Sopenharmony_ci{ 36e1051a39Sopenharmony_ci return known_md5_sha1_settable_ctx_params; 37e1051a39Sopenharmony_ci} 38e1051a39Sopenharmony_ci 39e1051a39Sopenharmony_ci/* Special set_params method for SSL3 */ 40e1051a39Sopenharmony_cistatic int md5_sha1_set_ctx_params(void *vctx, const OSSL_PARAM params[]) 41e1051a39Sopenharmony_ci{ 42e1051a39Sopenharmony_ci const OSSL_PARAM *p; 43e1051a39Sopenharmony_ci MD5_SHA1_CTX *ctx = (MD5_SHA1_CTX *)vctx; 44e1051a39Sopenharmony_ci 45e1051a39Sopenharmony_ci if (ctx == NULL) 46e1051a39Sopenharmony_ci return 0; 47e1051a39Sopenharmony_ci if (params == NULL) 48e1051a39Sopenharmony_ci return 1; 49e1051a39Sopenharmony_ci 50e1051a39Sopenharmony_ci p = OSSL_PARAM_locate_const(params, OSSL_DIGEST_PARAM_SSL3_MS); 51e1051a39Sopenharmony_ci if (p != NULL && p->data_type == OSSL_PARAM_OCTET_STRING) 52e1051a39Sopenharmony_ci return ossl_md5_sha1_ctrl(ctx, EVP_CTRL_SSL3_MASTER_SECRET, 53e1051a39Sopenharmony_ci p->data_size, p->data); 54e1051a39Sopenharmony_ci return 1; 55e1051a39Sopenharmony_ci} 56e1051a39Sopenharmony_ci 57e1051a39Sopenharmony_ci/* ossl_md5_sha1_functions */ 58e1051a39Sopenharmony_ciIMPLEMENT_digest_functions_with_settable_ctx( 59e1051a39Sopenharmony_ci md5_sha1, MD5_SHA1_CTX, MD5_SHA1_CBLOCK, MD5_SHA1_DIGEST_LENGTH, 0, 60e1051a39Sopenharmony_ci ossl_md5_sha1_init, ossl_md5_sha1_update, ossl_md5_sha1_final, 61e1051a39Sopenharmony_ci md5_sha1_settable_ctx_params, md5_sha1_set_ctx_params) 62