Path: blob/main/crypto/openssl/providers/implementations/digests/md5_sha1_prov.c
48383 views
/*1* Copyright 2019-2021 The OpenSSL Project Authors. All Rights Reserved.2*3* Licensed under the Apache License 2.0 (the "License"). You may not use4* this file except in compliance with the License. You can obtain a copy5* in the file LICENSE in the source distribution or at6* https://www.openssl.org/source/license.html7*/89/*10* MD5 and SHA-1 low level APIs are deprecated for public use, but still ok for11* internal use.12*/13#include "internal/deprecated.h"1415#include <string.h>16#include <openssl/crypto.h>17#include <openssl/evp.h>18#include <openssl/params.h>19#include <openssl/core_names.h>20#include "prov/md5_sha1.h"21#include "prov/digestcommon.h"22#include "prov/implementations.h"2324static OSSL_FUNC_digest_set_ctx_params_fn md5_sha1_set_ctx_params;25static OSSL_FUNC_digest_settable_ctx_params_fn md5_sha1_settable_ctx_params;2627static const OSSL_PARAM known_md5_sha1_settable_ctx_params[] = {28{OSSL_DIGEST_PARAM_SSL3_MS, OSSL_PARAM_OCTET_STRING, NULL, 0, 0},29OSSL_PARAM_END30};3132static const OSSL_PARAM *md5_sha1_settable_ctx_params(ossl_unused void *ctx,33ossl_unused void *provctx)34{35return known_md5_sha1_settable_ctx_params;36}3738/* Special set_params method for SSL3 */39static int md5_sha1_set_ctx_params(void *vctx, const OSSL_PARAM params[])40{41const OSSL_PARAM *p;42MD5_SHA1_CTX *ctx = (MD5_SHA1_CTX *)vctx;4344if (ctx == NULL)45return 0;46if (ossl_param_is_empty(params))47return 1;4849p = OSSL_PARAM_locate_const(params, OSSL_DIGEST_PARAM_SSL3_MS);50if (p != NULL && p->data_type == OSSL_PARAM_OCTET_STRING)51return ossl_md5_sha1_ctrl(ctx, EVP_CTRL_SSL3_MASTER_SECRET,52p->data_size, p->data);53return 1;54}5556/* ossl_md5_sha1_functions */57IMPLEMENT_digest_functions_with_settable_ctx(58md5_sha1, MD5_SHA1_CTX, MD5_SHA1_CBLOCK, MD5_SHA1_DIGEST_LENGTH, 0,59ossl_md5_sha1_init, ossl_md5_sha1_update, ossl_md5_sha1_final,60md5_sha1_settable_ctx_params, md5_sha1_set_ctx_params)616263