Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/openssl/ossl_typ.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ typedef struct evp_pkey_st EVP_PKEY;

typedef struct engine_st ENGINE;
typedef struct rand_meth_st RAND_METHOD;
typedef struct ossl_lib_ctx_st OSSL_LIB_CTX;

#define ASN1_GENERALIZEDTIME ASN1_STRING

Expand Down
30 changes: 30 additions & 0 deletions source/evp_override.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <openssl/rsa.h>

#include <assert.h>
#include <string.h>

#define DEFAULT_IV_LEN 12 // For GCM AES and OCB AES the default is 12 (i.e. 96 bits).
#define DEFAULT_KEY_LEN 32
Expand Down Expand Up @@ -706,6 +707,35 @@ const EVP_MD *EVP_sha512() {
return &md;
}

EVP_MD *EVP_MD_fetch(OSSL_LIB_CTX *ctx, const char *algorithm, const char *properties) {
// Assume this method is always called without a library context
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be:

Suggested change
// Assume this method is always called without a library context
// Assume this method is never called without a library context

?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... as written, yes. But actually I meant to assume the ctx is always NULL. s2n-tls always calls it with NULL. Let me investigate why this is working. s2n-tls's proofs wouldn't have cared about my other dumb mistakes, but this one they really should have cared about.

assert(ctx != NULL);

// Reuse the old initialization values to set value
EVP_MD *md_value = NULL;
if (strcmp(algorithm, "MD5") == 0) {
md_value = EVP_md5();
} else if (strcmp(algorithm, "SHA1") == 0) {
md_value = EVP_sha1();
} else if (strcmp(algorithm, "SHA224") == 0) {
md_value = EVP_sha224();
} else if (strcmp(algorithm, "SHA256") == 0) {
md_value = EVP_sha256();
} else if (strcmp(algorithm, "SHA384") == 0) {
md_value = EVP_sha384();
} else if (strcmp(algorithm, "SHA512") == 0) {
md_value = EVP_sha512();
}

if (md_value) {
EVP_MD *md = malloc(sizeof(EVP_MD));
Comment thread
lrstewart marked this conversation as resolved.
*md = *md_value;
return md;
} else {
return NULL;
}
}

/* Description: Return the size of the message digest when passed an EVP_MD or an EVP_MD_CTX structure, i.e. the size of
* the hash.
*/
Expand Down