/*
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
*
- * Licensed under the OpenSSL license (the "License"). You may not use
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
* in the file LICENSE in the source distribution or at
* https://www.openssl.org/source/license.html
#include <openssl/objects.h>
#include <openssl/sha.h>
#include <openssl/rsa.h>
-#include "internal/evp_int.h"
-#include "internal/sha.h"
+#include "crypto/evp.h"
+#include "crypto/sha.h"
static int init(EVP_MD_CTX *ctx)
{
return SHA1_Final(md, EVP_MD_CTX_md_data(ctx));
}
-static int ctrl(EVP_MD_CTX *ctx, int cmd, int mslen, void *ms)
+static int ctrl(EVP_MD_CTX *ctx, int cmd, int p1, void *p2)
{
- unsigned char padtmp[40];
- unsigned char sha1tmp[SHA_DIGEST_LENGTH];
-
- SHA_CTX *sha1;
-
- if (cmd != EVP_CTRL_SSL3_MASTER_SECRET)
- return -2;
-
- if (ctx == NULL)
- return 0;
-
- sha1 = EVP_MD_CTX_md_data(ctx);
-
- /* SSLv3 client auth handling: see RFC-6101 5.6.8 */
- if (mslen != 48)
- return 0;
-
- /* At this point hash contains all handshake messages, update
- * with master secret and pad_1.
- */
-
- if (SHA1_Update(sha1, ms, mslen) <= 0)
- return 0;
-
- /* Set padtmp to pad_1 value */
- memset(padtmp, 0x36, sizeof(padtmp));
-
- if (!SHA1_Update(sha1, padtmp, sizeof(padtmp)))
- return 0;
-
- if (!SHA1_Final(sha1tmp, sha1))
- return 0;
-
- /* Reinitialise context */
-
- if (!SHA1_Init(sha1))
- return 0;
-
- if (SHA1_Update(sha1, ms, mslen) <= 0)
- return 0;
-
- /* Set padtmp to pad_2 value */
- memset(padtmp, 0x5c, sizeof(padtmp));
-
- if (!SHA1_Update(sha1, padtmp, sizeof(padtmp)))
- return 0;
-
- if (!SHA1_Update(sha1, sha1tmp, sizeof(sha1tmp)))
- return 0;
-
- /* Now when ctx is finalised it will return the SSL v3 hash value */
- OPENSSL_cleanse(sha1tmp, sizeof(sha1tmp));
-
- return 1;
-
+ return sha1_ctrl(ctx != NULL ? EVP_MD_CTX_md_data(ctx) : NULL, cmd, p1, p2);
}
static const EVP_MD sha1_md = {