Remove |EVP_MD_CTX_create| and |EVP_MD_CTX_destroy| (dead code).
This commit is contained in:
parent
562ec71e09
commit
c8a7001677
@ -77,16 +77,6 @@ size_t EVP_MD_block_size(const EVP_MD *md) { return md->block_size; }
|
||||
|
||||
void EVP_MD_CTX_init(EVP_MD_CTX *ctx) { memset(ctx, 0, sizeof(EVP_MD_CTX)); }
|
||||
|
||||
EVP_MD_CTX *EVP_MD_CTX_create(void) {
|
||||
EVP_MD_CTX *ctx = OPENSSL_malloc(sizeof(EVP_MD_CTX));
|
||||
|
||||
if (ctx) {
|
||||
EVP_MD_CTX_init(ctx);
|
||||
}
|
||||
|
||||
return ctx;
|
||||
}
|
||||
|
||||
int EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx) {
|
||||
if (ctx->digest && ctx->digest->ctx_size && ctx->md_data) {
|
||||
OPENSSL_cleanse(ctx->md_data, ctx->digest->ctx_size);
|
||||
@ -103,15 +93,6 @@ int EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
void EVP_MD_CTX_destroy(EVP_MD_CTX *ctx) {
|
||||
if (!ctx) {
|
||||
return;
|
||||
}
|
||||
|
||||
EVP_MD_CTX_cleanup(ctx);
|
||||
OPENSSL_free(ctx);
|
||||
}
|
||||
|
||||
int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *engine) {
|
||||
if (ctx->digest != type) {
|
||||
if (ctx->digest && ctx->digest->ctx_size > 0) {
|
||||
|
@ -92,17 +92,10 @@ OPENSSL_EXPORT const EVP_MD *EVP_sha512(void);
|
||||
/* EVP_MD_CTX_init initialises an, already allocated, |EVP_MD_CTX|. */
|
||||
OPENSSL_EXPORT void EVP_MD_CTX_init(EVP_MD_CTX *ctx);
|
||||
|
||||
/* EVP_MD_CTX_create allocates and initialises a fresh |EVP_MD_CTX| and returns
|
||||
* it, or NULL on allocation failure. */
|
||||
OPENSSL_EXPORT EVP_MD_CTX *EVP_MD_CTX_create(void);
|
||||
|
||||
/* EVP_MD_CTX_cleanup frees any resources owned by |ctx| and resets it to a
|
||||
* freshly initialised state. It does not free |ctx| itself. It returns one. */
|
||||
OPENSSL_EXPORT int EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx);
|
||||
|
||||
/* EVP_MD_CTX_destroy calls |EVP_MD_CTX_cleanup| and then frees |ctx| itself. */
|
||||
OPENSSL_EXPORT void EVP_MD_CTX_destroy(EVP_MD_CTX *ctx);
|
||||
|
||||
|
||||
/* Digest operations. */
|
||||
|
||||
|
@ -170,45 +170,6 @@ static bool SpeedRSA(const std::string &key_name, RSA *key,
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool SpeedHashChunk(const EVP_MD *md, const std::string &name,
|
||||
size_t chunk_len) {
|
||||
EVP_MD_CTX *ctx = EVP_MD_CTX_create();
|
||||
uint8_t scratch[8192];
|
||||
|
||||
if (chunk_len > sizeof(scratch)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
TimeResults results;
|
||||
if (!TimeFunction(&results, [ctx, md, chunk_len, &scratch]() -> bool {
|
||||
uint8_t digest[EVP_MAX_MD_SIZE];
|
||||
unsigned int md_len;
|
||||
|
||||
return EVP_DigestInit_ex(ctx, md, NULL /* ENGINE */) &&
|
||||
EVP_DigestUpdate(ctx, scratch, chunk_len) &&
|
||||
EVP_DigestFinal_ex(ctx, digest, &md_len);
|
||||
})) {
|
||||
fprintf(stderr, "EVP_DigestInit_ex failed.\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
results.PrintWithBytes(name, chunk_len);
|
||||
|
||||
EVP_MD_CTX_destroy(ctx);
|
||||
|
||||
return true;
|
||||
}
|
||||
static bool SpeedHash(const EVP_MD *md, const std::string &name,
|
||||
const std::string &selected) {
|
||||
if (!selected.empty() && name.find(selected) == std::string::npos) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return SpeedHashChunk(md, name + " (16 bytes)", 16) &&
|
||||
SpeedHashChunk(md, name + " (256 bytes)", 256) &&
|
||||
SpeedHashChunk(md, name + " (8192 bytes)", 8192);
|
||||
}
|
||||
|
||||
static bool SpeedRandomChunk(const std::string name, size_t chunk_len) {
|
||||
uint8_t scratch[8192];
|
||||
|
||||
@ -383,10 +344,7 @@ bool Speed(const std::vector<std::string> &args) {
|
||||
// AEADs.
|
||||
static const size_t kTLSADLen = 13;
|
||||
|
||||
if (!SpeedHash(EVP_sha1(), "SHA-1", selected) ||
|
||||
!SpeedHash(EVP_sha256(), "SHA-256", selected) ||
|
||||
!SpeedHash(EVP_sha512(), "SHA-512", selected) ||
|
||||
!SpeedRandom(selected) ||
|
||||
if (!SpeedRandom(selected) ||
|
||||
!SpeedECDH(selected) ||
|
||||
!SpeedECDSA(selected)) {
|
||||
return false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user