| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/evp/m_md5_sha1.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||
|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||
| 2 | - | |||||||
| 3 | - | |||||||
| 4 | - | |||||||
| 5 | struct md5_sha1_ctx { | - | ||||||
| 6 | MD5_CTX md5; | - | ||||||
| 7 | SHA_CTX sha1; | - | ||||||
| 8 | }; | - | ||||||
| 9 | - | |||||||
| 10 | static int init(EVP_MD_CTX *ctx) | - | ||||||
| 11 | { | - | ||||||
| 12 | struct md5_sha1_ctx *mctx = EVP_MD_CTX_md_data(ctx); | - | ||||||
| 13 | if (!MD5_Init(&mctx->md5)
| 0-1758 | ||||||
| 14 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||
| 15 | return executed 1758 times by 1 test: SHA1_Init(&mctx->sha1);return SHA1_Init(&mctx->sha1);Executed by:
executed 1758 times by 1 test: return SHA1_Init(&mctx->sha1);Executed by:
| 1758 | ||||||
| 16 | } | - | ||||||
| 17 | - | |||||||
| 18 | static int update(EVP_MD_CTX *ctx, const void *data, size_t count) | - | ||||||
| 19 | { | - | ||||||
| 20 | struct md5_sha1_ctx *mctx = EVP_MD_CTX_md_data(ctx); | - | ||||||
| 21 | if (!MD5_Update(&mctx->md5, data, count)
| 0-6384 | ||||||
| 22 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||
| 23 | return executed 6384 times by 1 test: SHA1_Update(&mctx->sha1, data, count);return SHA1_Update(&mctx->sha1, data, count);Executed by:
executed 6384 times by 1 test: return SHA1_Update(&mctx->sha1, data, count);Executed by:
| 6384 | ||||||
| 24 | } | - | ||||||
| 25 | - | |||||||
| 26 | static int final(EVP_MD_CTX *ctx, unsigned char *md) | - | ||||||
| 27 | { | - | ||||||
| 28 | struct md5_sha1_ctx *mctx = EVP_MD_CTX_md_data(ctx); | - | ||||||
| 29 | if (!MD5_Final(md, &mctx->md5)
| 0-3181 | ||||||
| 30 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||
| 31 | return executed 3181 times by 1 test: SHA1_Final(md + 16, &mctx->sha1);return SHA1_Final(md + 16, &mctx->sha1);Executed by:
executed 3181 times by 1 test: return SHA1_Final(md + 16, &mctx->sha1);Executed by:
| 3181 | ||||||
| 32 | } | - | ||||||
| 33 | - | |||||||
| 34 | static int ctrl(EVP_MD_CTX *ctx, int cmd, int mslen, void *ms) | - | ||||||
| 35 | { | - | ||||||
| 36 | unsigned char padtmp[48]; | - | ||||||
| 37 | unsigned char md5tmp[16]; | - | ||||||
| 38 | unsigned char sha1tmp[20]; | - | ||||||
| 39 | struct md5_sha1_ctx *mctx; | - | ||||||
| 40 | - | |||||||
| 41 | if (cmd != 0x1d
| 0 | ||||||
| 42 | return never executed: -2;return -2;never executed: return -2; | 0 | ||||||
| 43 | - | |||||||
| 44 | if (ctx ==
| 0 | ||||||
| 45 | ((void *)0)
| 0 | ||||||
| 46 | ) | - | ||||||
| 47 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||
| 48 | - | |||||||
| 49 | mctx = EVP_MD_CTX_md_data(ctx); | - | ||||||
| 50 | - | |||||||
| 51 | - | |||||||
| 52 | if (mslen != 48
| 0 | ||||||
| 53 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||
| 54 | - | |||||||
| 55 | - | |||||||
| 56 | - | |||||||
| 57 | - | |||||||
| 58 | - | |||||||
| 59 | if (update(ctx, ms, mslen) <= 0
| 0 | ||||||
| 60 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||
| 61 | - | |||||||
| 62 | - | |||||||
| 63 | memset(padtmp, 0x36, sizeof(padtmp)); | - | ||||||
| 64 | - | |||||||
| 65 | if (!MD5_Update(&mctx->md5, padtmp, sizeof(padtmp))
| 0 | ||||||
| 66 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||
| 67 | - | |||||||
| 68 | if (!MD5_Final(md5tmp, &mctx->md5)
| 0 | ||||||
| 69 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||
| 70 | - | |||||||
| 71 | if (!SHA1_Update(&mctx->sha1, padtmp, 40)
| 0 | ||||||
| 72 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||
| 73 | - | |||||||
| 74 | if (!SHA1_Final(sha1tmp, &mctx->sha1)
| 0 | ||||||
| 75 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||
| 76 | - | |||||||
| 77 | - | |||||||
| 78 | - | |||||||
| 79 | if (!init(ctx)
| 0 | ||||||
| 80 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||
| 81 | - | |||||||
| 82 | if (update(ctx, ms, mslen) <= 0
| 0 | ||||||
| 83 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||
| 84 | - | |||||||
| 85 | - | |||||||
| 86 | memset(padtmp, 0x5c, sizeof(padtmp)); | - | ||||||
| 87 | - | |||||||
| 88 | if (!MD5_Update(&mctx->md5, padtmp, sizeof(padtmp))
| 0 | ||||||
| 89 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||
| 90 | - | |||||||
| 91 | if (!MD5_Update(&mctx->md5, md5tmp, sizeof(md5tmp))
| 0 | ||||||
| 92 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||
| 93 | - | |||||||
| 94 | if (!SHA1_Update(&mctx->sha1, padtmp, 40)
| 0 | ||||||
| 95 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||
| 96 | - | |||||||
| 97 | if (!SHA1_Update(&mctx->sha1, sha1tmp, sizeof(sha1tmp))
| 0 | ||||||
| 98 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||
| 99 | - | |||||||
| 100 | - | |||||||
| 101 | - | |||||||
| 102 | OPENSSL_cleanse(md5tmp, sizeof(md5tmp)); | - | ||||||
| 103 | OPENSSL_cleanse(sha1tmp, sizeof(sha1tmp)); | - | ||||||
| 104 | - | |||||||
| 105 | return never executed: 1;return 1;never executed: return 1; | 0 | ||||||
| 106 | - | |||||||
| 107 | } | - | ||||||
| 108 | - | |||||||
| 109 | static const EVP_MD md5_sha1_md = { | - | ||||||
| 110 | 114, | - | ||||||
| 111 | 114, | - | ||||||
| 112 | 16 + 20, | - | ||||||
| 113 | 0, | - | ||||||
| 114 | init, | - | ||||||
| 115 | update, | - | ||||||
| 116 | final, | - | ||||||
| 117 | - | |||||||
| 118 | ((void *)0) | - | ||||||
| 119 | , | - | ||||||
| 120 | - | |||||||
| 121 | ((void *)0) | - | ||||||
| 122 | , | - | ||||||
| 123 | 64, | - | ||||||
| 124 | sizeof(EVP_MD *) + sizeof(struct md5_sha1_ctx), | - | ||||||
| 125 | ctrl | - | ||||||
| 126 | }; | - | ||||||
| 127 | - | |||||||
| 128 | const EVP_MD *EVP_md5_sha1(void) | - | ||||||
| 129 | { | - | ||||||
| 130 | return executed 3930 times by 1 test: &md5_sha1_md;return &md5_sha1_md;Executed by:
executed 3930 times by 1 test: return &md5_sha1_md;Executed by:
| 3930 | ||||||
| 131 | } | - | ||||||
| Switch to Source code | Preprocessed file |