OpenCoverage

m_md5_sha1.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/evp/m_md5_sha1.c
Source codeSwitch to Preprocessed file
LineSourceCount
1/*-
2 * Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.-
3 *-
4 * Licensed under the OpenSSL license (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#if !defined(OPENSSL_NO_MD5)-
11-
12# include <openssl/evp.h>-
13# include <openssl/objects.h>-
14# include <openssl/x509.h>-
15# include <openssl/md5.h>-
16# include <openssl/sha.h>-
17# include "internal/cryptlib.h"-
18# include "internal/evp_int.h"-
19# include <openssl/rsa.h>-
20-
21struct md5_sha1_ctx {-
22 MD5_CTX md5;-
23 SHA_CTX sha1;-
24};-
25-
26static int init(EVP_MD_CTX *ctx)-
27{-
28 struct md5_sha1_ctx *mctx = EVP_MD_CTX_md_data(ctx);-
29 if (!MD5_Init(&mctx->md5))
!MD5_Init(&mctx->md5)Description
TRUEnever evaluated
FALSEevaluated 1758 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1758
30 return 0;
never executed: return 0;
0
31 return SHA1_Init(&mctx->sha1);
executed 1758 times by 1 test: return SHA1_Init(&mctx->sha1);
Executed by:
  • libcrypto.so.1.1
1758
32}-
33-
34static int update(EVP_MD_CTX *ctx, const void *data, size_t count)-
35{-
36 struct md5_sha1_ctx *mctx = EVP_MD_CTX_md_data(ctx);-
37 if (!MD5_Update(&mctx->md5, data, count))
!MD5_Update(&m..., data, count)Description
TRUEnever evaluated
FALSEevaluated 6384 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-6384
38 return 0;
never executed: return 0;
0
39 return SHA1_Update(&mctx->sha1, data, count);
executed 6384 times by 1 test: return SHA1_Update(&mctx->sha1, data, count);
Executed by:
  • libcrypto.so.1.1
6384
40}-
41-
42static int final(EVP_MD_CTX *ctx, unsigned char *md)-
43{-
44 struct md5_sha1_ctx *mctx = EVP_MD_CTX_md_data(ctx);-
45 if (!MD5_Final(md, &mctx->md5))
!MD5_Final(md, &mctx->md5)Description
TRUEnever evaluated
FALSEevaluated 3181 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-3181
46 return 0;
never executed: return 0;
0
47 return SHA1_Final(md + MD5_DIGEST_LENGTH, &mctx->sha1);
executed 3181 times by 1 test: return SHA1_Final(md + 16, &mctx->sha1);
Executed by:
  • libcrypto.so.1.1
3181
48}-
49-
50static int ctrl(EVP_MD_CTX *ctx, int cmd, int mslen, void *ms)-
51{-
52 unsigned char padtmp[48];-
53 unsigned char md5tmp[MD5_DIGEST_LENGTH];-
54 unsigned char sha1tmp[SHA_DIGEST_LENGTH];-
55 struct md5_sha1_ctx *mctx;-
56-
57 if (cmd != EVP_CTRL_SSL3_MASTER_SECRET)
cmd != 0x1dDescription
TRUEnever evaluated
FALSEnever evaluated
0
58 return -2;
never executed: return -2;
0
59-
60 if (ctx == NULL)
ctx == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
61 return 0;
never executed: return 0;
0
62-
63 mctx = EVP_MD_CTX_md_data(ctx);-
64-
65 /* SSLv3 client auth handling: see RFC-6101 5.6.8 */-
66 if (mslen != 48)
mslen != 48Description
TRUEnever evaluated
FALSEnever evaluated
0
67 return 0;
never executed: return 0;
0
68-
69 /* At this point hash contains all handshake messages, update-
70 * with master secret and pad_1.-
71 */-
72-
73 if (update(ctx, ms, mslen) <= 0)
update(ctx, ms, mslen) <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
74 return 0;
never executed: return 0;
0
75-
76 /* Set padtmp to pad_1 value */-
77 memset(padtmp, 0x36, sizeof(padtmp));-
78-
79 if (!MD5_Update(&mctx->md5, padtmp, sizeof(padtmp)))
!MD5_Update(&m...izeof(padtmp))Description
TRUEnever evaluated
FALSEnever evaluated
0
80 return 0;
never executed: return 0;
0
81-
82 if (!MD5_Final(md5tmp, &mctx->md5))
!MD5_Final(md5tmp, &mctx->md5)Description
TRUEnever evaluated
FALSEnever evaluated
0
83 return 0;
never executed: return 0;
0
84-
85 if (!SHA1_Update(&mctx->sha1, padtmp, 40))
!SHA1_Update(&...1, padtmp, 40)Description
TRUEnever evaluated
FALSEnever evaluated
0
86 return 0;
never executed: return 0;
0
87-
88 if (!SHA1_Final(sha1tmp, &mctx->sha1))
!SHA1_Final(sh..., &mctx->sha1)Description
TRUEnever evaluated
FALSEnever evaluated
0
89 return 0;
never executed: return 0;
0
90-
91 /* Reinitialise context */-
92-
93 if (!init(ctx))
!init(ctx)Description
TRUEnever evaluated
FALSEnever evaluated
0
94 return 0;
never executed: return 0;
0
95-
96 if (update(ctx, ms, mslen) <= 0)
update(ctx, ms, mslen) <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
97 return 0;
never executed: return 0;
0
98-
99 /* Set padtmp to pad_2 value */-
100 memset(padtmp, 0x5c, sizeof(padtmp));-
101-
102 if (!MD5_Update(&mctx->md5, padtmp, sizeof(padtmp)))
!MD5_Update(&m...izeof(padtmp))Description
TRUEnever evaluated
FALSEnever evaluated
0
103 return 0;
never executed: return 0;
0
104-
105 if (!MD5_Update(&mctx->md5, md5tmp, sizeof(md5tmp)))
!MD5_Update(&m...izeof(md5tmp))Description
TRUEnever evaluated
FALSEnever evaluated
0
106 return 0;
never executed: return 0;
0
107-
108 if (!SHA1_Update(&mctx->sha1, padtmp, 40))
!SHA1_Update(&...1, padtmp, 40)Description
TRUEnever evaluated
FALSEnever evaluated
0
109 return 0;
never executed: return 0;
0
110-
111 if (!SHA1_Update(&mctx->sha1, sha1tmp, sizeof(sha1tmp)))
!SHA1_Update(&...zeof(sha1tmp))Description
TRUEnever evaluated
FALSEnever evaluated
0
112 return 0;
never executed: return 0;
0
113-
114 /* Now when ctx is finalised it will return the SSL v3 hash value */-
115-
116 OPENSSL_cleanse(md5tmp, sizeof(md5tmp));-
117 OPENSSL_cleanse(sha1tmp, sizeof(sha1tmp));-
118-
119 return 1;
never executed: return 1;
0
120-
121}-
122-
123static const EVP_MD md5_sha1_md = {-
124 NID_md5_sha1,-
125 NID_md5_sha1,-
126 MD5_DIGEST_LENGTH + SHA_DIGEST_LENGTH,-
127 0,-
128 init,-
129 update,-
130 final,-
131 NULL,-
132 NULL,-
133 MD5_CBLOCK,-
134 sizeof(EVP_MD *) + sizeof(struct md5_sha1_ctx),-
135 ctrl-
136};-
137-
138const EVP_MD *EVP_md5_sha1(void)-
139{-
140 return &md5_sha1_md;
executed 3930 times by 1 test: return &md5_sha1_md;
Executed by:
  • libcrypto.so.1.1
3930
141}-
142#endif-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.2