summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crypto/err/openssl.txt1
-rw-r--r--crypto/evp/digest.c5
-rw-r--r--crypto/evp/evp_err.c1
-rw-r--r--crypto/evp/evp_lib.c8
-rw-r--r--crypto/include/internal/evp_int.h1
-rw-r--r--include/openssl/core_numbers.h2
-rw-r--r--include/openssl/evperr.h1
-rw-r--r--providers/common/digests/sha2.c6
8 files changed, 25 insertions, 0 deletions
diff --git a/crypto/err/openssl.txt b/crypto/err/openssl.txt
index fbf35d14bf..f15fc9c1bd 100644
--- a/crypto/err/openssl.txt
+++ b/crypto/err/openssl.txt
@@ -800,6 +800,7 @@ EVP_F_EVP_MAC_CTRL_STR:210:EVP_MAC_ctrl_str
EVP_F_EVP_MAC_CTX_COPY:211:EVP_MAC_CTX_copy
EVP_F_EVP_MAC_CTX_NEW:213:EVP_MAC_CTX_new
EVP_F_EVP_MAC_INIT:212:EVP_MAC_init
+EVP_F_EVP_MD_BLOCK_SIZE:229:EVP_MD_block_size
EVP_F_EVP_MD_CTX_COPY_EX:110:EVP_MD_CTX_copy_ex
EVP_F_EVP_MD_SIZE:162:EVP_MD_size
EVP_F_EVP_OPENINIT:102:EVP_OpenInit
diff --git a/crypto/evp/digest.c b/crypto/evp/digest.c
index 89f8e54a91..b93a014564 100644
--- a/crypto/evp/digest.c
+++ b/crypto/evp/digest.c
@@ -549,6 +549,11 @@ static void *evp_md_from_dispatch(int mdtype, const OSSL_DISPATCH *fns,
break;
md->size = OSSL_get_OP_digest_size(fns);
break;
+ case OSSL_FUNC_DIGEST_BLOCK_SIZE:
+ if (md->dblock_size != NULL)
+ break;
+ md->dblock_size = OSSL_get_OP_digest_block_size(fns);
+ break;
}
}
if ((fncnt != 0 && fncnt != 5)
diff --git a/crypto/evp/evp_err.c b/crypto/evp/evp_err.c
index 6e72b6b427..a3e01fdd5d 100644
--- a/crypto/evp/evp_err.c
+++ b/crypto/evp/evp_err.c
@@ -71,6 +71,7 @@ static const ERR_STRING_DATA EVP_str_functs[] = {
{ERR_PACK(ERR_LIB_EVP, EVP_F_EVP_MAC_CTX_COPY, 0), "EVP_MAC_CTX_copy"},
{ERR_PACK(ERR_LIB_EVP, EVP_F_EVP_MAC_CTX_NEW, 0), "EVP_MAC_CTX_new"},
{ERR_PACK(ERR_LIB_EVP, EVP_F_EVP_MAC_INIT, 0), "EVP_MAC_init"},
+ {ERR_PACK(ERR_LIB_EVP, EVP_F_EVP_MD_BLOCK_SIZE, 0), "EVP_MD_block_size"},
{ERR_PACK(ERR_LIB_EVP, EVP_F_EVP_MD_CTX_COPY_EX, 0), "EVP_MD_CTX_copy_ex"},
{ERR_PACK(ERR_LIB_EVP, EVP_F_EVP_MD_SIZE, 0), "EVP_MD_size"},
{ERR_PACK(ERR_LIB_EVP, EVP_F_EVP_OPENINIT, 0), "EVP_OpenInit"},
diff --git a/crypto/evp/evp_lib.c b/crypto/evp/evp_lib.c
index f99e905e42..914a19cc5e 100644
--- a/crypto/evp/evp_lib.c
+++ b/crypto/evp/evp_lib.c
@@ -298,6 +298,14 @@ int EVP_CIPHER_CTX_nid(const EVP_CIPHER_CTX *ctx)
int EVP_MD_block_size(const EVP_MD *md)
{
+ if (md == NULL) {
+ EVPerr(EVP_F_EVP_MD_BLOCK_SIZE, EVP_R_MESSAGE_DIGEST_IS_NULL);
+ return -1;
+ }
+
+ if (md->prov != NULL && md->dblock_size != NULL)
+ return (int)md->dblock_size();
+
return md->block_size;
}
diff --git a/crypto/include/internal/evp_int.h b/crypto/include/internal/evp_int.h
index ab8ce00e47..c932898139 100644
--- a/crypto/include/internal/evp_int.h
+++ b/crypto/include/internal/evp_int.h
@@ -204,6 +204,7 @@ struct evp_md_st {
OSSL_OP_digest_freectx_fn *freectx;
OSSL_OP_digest_dupctx_fn *dupctx;
OSSL_OP_digest_size_fn *size;
+ OSSL_OP_digest_block_size_fn *dblock_size;
} /* EVP_MD */ ;
diff --git a/include/openssl/core_numbers.h b/include/openssl/core_numbers.h
index a7238547aa..1e53627706 100644
--- a/include/openssl/core_numbers.h
+++ b/include/openssl/core_numbers.h
@@ -84,6 +84,7 @@ OSSL_CORE_MAKE_FUNC(const OSSL_ALGORITHM *,provider_query_operation,
# define OSSL_FUNC_DIGEST_FREECTX 6
# define OSSL_FUNC_DIGEST_DUPCTX 7
# define OSSL_FUNC_DIGEST_SIZE 8
+# define OSSL_FUNC_DIGEST_BLOCK_SIZE 9
OSSL_CORE_MAKE_FUNC(void *, OP_digest_newctx, (void))
OSSL_CORE_MAKE_FUNC(int, OP_digest_init, (void *vctx))
@@ -98,6 +99,7 @@ OSSL_CORE_MAKE_FUNC(void, OP_digest_cleanctx, (void *vctx))
OSSL_CORE_MAKE_FUNC(void, OP_digest_freectx, (void *vctx))
OSSL_CORE_MAKE_FUNC(void *, OP_digest_dupctx, (void *vctx))
OSSL_CORE_MAKE_FUNC(size_t, OP_digest_size, (void))
+OSSL_CORE_MAKE_FUNC(size_t, OP_digest_block_size, (void))
# ifdef __cplusplus
}
diff --git a/include/openssl/evperr.h b/include/openssl/evperr.h
index d60402cdc2..317be14a13 100644
--- a/include/openssl/evperr.h
+++ b/include/openssl/evperr.h
@@ -70,6 +70,7 @@ int ERR_load_EVP_strings(void);
# define EVP_F_EVP_MAC_CTX_COPY 211
# define EVP_F_EVP_MAC_CTX_NEW 213
# define EVP_F_EVP_MAC_INIT 212
+# define EVP_F_EVP_MD_BLOCK_SIZE 229
# define EVP_F_EVP_MD_CTX_COPY_EX 110
# define EVP_F_EVP_MD_SIZE 162
# define EVP_F_EVP_OPENINIT 102
diff --git a/providers/common/digests/sha2.c b/providers/common/digests/sha2.c
index b538ab9c4a..4332e9818e 100644
--- a/providers/common/digests/sha2.c
+++ b/providers/common/digests/sha2.c
@@ -50,6 +50,11 @@ static size_t sha256_size(void)
return SHA256_DIGEST_LENGTH;
}
+static size_t sha256_block_size(void)
+{
+ return SHA256_CBLOCK;
+}
+
extern const OSSL_DISPATCH sha256_functions[];
const OSSL_DISPATCH sha256_functions[] = {
{ OSSL_FUNC_DIGEST_NEWCTX, (void (*)(void))sha256_newctx },
@@ -59,5 +64,6 @@ const OSSL_DISPATCH sha256_functions[] = {
{ OSSL_FUNC_DIGEST_FREECTX, (void (*)(void))sha256_freectx },
{ OSSL_FUNC_DIGEST_DUPCTX, (void (*)(void))sha256_dupctx },
{ OSSL_FUNC_DIGEST_SIZE, (void (*)(void))sha256_size },
+ { OSSL_FUNC_DIGEST_BLOCK_SIZE, (void (*)(void))sha256_block_size },
{ 0, NULL }
};