summaryrefslogtreecommitdiffstats
path: root/crypto/sha/sha1dgst.c
diff options
context:
space:
mode:
authorShane Lontis <shane.lontis@oracle.com>2019-04-11 20:27:59 +1000
committerShane Lontis <shane.lontis@oracle.com>2019-06-04 12:09:50 +1000
commitd5e5e2ffafc7dbc861f7d285508cf129c5e8f5ac (patch)
tree3920b0febd6d2716940fb022b57894fe2ebf565d /crypto/sha/sha1dgst.c
parentbf5b04ea25d6ac7d31e388b4e87d3eb5cd1e1e2b (diff)
Move digests to providers
Move digest code into the relevant providers (fips, default, legacy). The headers are temporarily moved to be internal, and will be moved into providers after all external references are resolved. The deprecated digest code can not be removed until EVP_PKEY (signing) is supported by providers. EVP_MD data can also not yet be cleaned up for the same reasons. Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/8763)
Diffstat (limited to 'crypto/sha/sha1dgst.c')
-rw-r--r--crypto/sha/sha1dgst.c61
1 files changed, 59 insertions, 2 deletions
diff --git a/crypto/sha/sha1dgst.c b/crypto/sha/sha1dgst.c
index d31a5d4bc8..4881bcb17a 100644
--- a/crypto/sha/sha1dgst.c
+++ b/crypto/sha/sha1dgst.c
@@ -10,8 +10,65 @@
#include <openssl/crypto.h>
#include <openssl/opensslconf.h>
-# include <openssl/opensslv.h>
+#include <openssl/opensslv.h>
+#include <openssl/evp.h>
+#include <openssl/sha.h>
/* The implementation is in ../md32_common.h */
-# include "sha_locl.h"
+#include "sha_locl.h"
+#include "internal/sha.h"
+
+int sha1_ctrl(SHA_CTX *sha1, int cmd, int mslen, void *ms)
+{
+ unsigned char padtmp[40];
+ unsigned char sha1tmp[SHA_DIGEST_LENGTH];
+
+ if (cmd != EVP_CTRL_SSL3_MASTER_SECRET)
+ return -2;
+
+ if (sha1 == NULL)
+ return 0;
+
+ /* 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;
+}