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
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,24 @@ public static void VerifyEmptyHMAC_Span(HMAC referenceAlgorithm, HashAlgorithmNa
}
}

[Theory]
[MemberData(nameof(GetHMACs))]
public static void VerifyEmptyHMACKey_Cloned(HMAC referenceAlgorithm, HashAlgorithmName hashAlgorithm)
{
using (referenceAlgorithm)
using (IncrementalHash incrementalHash = IncrementalHash.CreateHMAC(hashAlgorithm, Array.Empty<byte>()))
using (IncrementalHash cloned = incrementalHash.Clone())
{
referenceAlgorithm.Key = Array.Empty<byte>();
cloned.AppendData([1, 2, 3]);
byte[] referenceHash = referenceAlgorithm.ComputeHash([1, 2, 3]);
byte[] clonedResult = new byte[referenceHash.Length];
Assert.True(cloned.TryGetHashAndReset(clonedResult, out int bytesWritten));
Assert.Equal(referenceHash.Length, bytesWritten);
Assert.Equal(referenceHash, clonedResult);
}
}

[Theory]
[MemberData(nameof(GetHashAlgorithms))]
public static void VerifyTrivialHash_Span(HashAlgorithm referenceAlgorithm, HashAlgorithmName hashAlgorithm)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@

#include "pal_crypto_config.h"
#include "pal_compiler.h"
#define OPENSSL_VERSION_3_0_2_RTM 0x3000002FL
#define OPENSSL_VERSION_3_0_RTM 0x30000000L
#define OPENSSL_VERSION_1_1_1_RTM 0x10101000L
#define OPENSSL_VERSION_1_1_0_RTM 0x10100000L
Expand Down Expand Up @@ -358,12 +359,14 @@ extern bool g_libSslUses32BitTime;
REQUIRED_FUNCTION(BN_CTX_new) \
REQUIRED_FUNCTION(BN_CTX_free) \
LEGACY_FUNCTION(CRYPTO_add_lock) \
REQUIRED_FUNCTION(CRYPTO_clear_free) \
REQUIRED_FUNCTION(CRYPTO_free) \
REQUIRED_FUNCTION(CRYPTO_get_ex_new_index) \
REQUIRED_FUNCTION(CRYPTO_malloc) \
LEGACY_FUNCTION(CRYPTO_num_locks) \
LEGACY_FUNCTION(CRYPTO_set_locking_callback) \
REQUIRED_FUNCTION(CRYPTO_set_mem_functions) \
REQUIRED_FUNCTION(CRYPTO_zalloc) \
REQUIRED_FUNCTION(d2i_OCSP_RESPONSE) \
REQUIRED_FUNCTION(d2i_PKCS12_fp) \
REQUIRED_FUNCTION(d2i_PKCS7) \
Expand Down Expand Up @@ -517,7 +520,9 @@ extern bool g_libSslUses32BitTime;
RENAMED_FUNCTION(EVP_MD_CTX_new, EVP_MD_CTX_create) \
REQUIRED_FUNCTION(EVP_MD_CTX_set_flags) \
LIGHTUP_FUNCTION(EVP_MD_fetch) \
LIGHTUP_FUNCTION(EVP_MD_get0_name) \
RENAMED_FUNCTION(EVP_MD_get_size, EVP_MD_size) \
LIGHTUP_FUNCTION(EVP_MD_is_a) \
REQUIRED_FUNCTION(EVP_PKCS82PKEY) \
REQUIRED_FUNCTION(EVP_PKEY2PKCS8) \
REQUIRED_FUNCTION(EVP_PKEY_CTX_ctrl) \
Expand Down Expand Up @@ -930,12 +935,14 @@ extern TYPEOF(OPENSSL_gmtime)* OPENSSL_gmtime_ptr;
#define BN_CTX_free BN_CTX_free_ptr
#define BN_CTX_new BN_CTX_new_ptr
#define CRYPTO_add_lock CRYPTO_add_lock_ptr
#define CRYPTO_clear_free CRYPTO_clear_free_ptr
#define CRYPTO_free CRYPTO_free_ptr
#define CRYPTO_get_ex_new_index CRYPTO_get_ex_new_index_ptr
#define CRYPTO_malloc CRYPTO_malloc_ptr
#define CRYPTO_num_locks CRYPTO_num_locks_ptr
#define CRYPTO_set_locking_callback CRYPTO_set_locking_callback_ptr
#define CRYPTO_set_mem_functions CRYPTO_set_mem_functions_ptr
#define CRYPTO_zalloc CRYPTO_zalloc_ptr
#define d2i_OCSP_RESPONSE d2i_OCSP_RESPONSE_ptr
#define d2i_PKCS12_fp d2i_PKCS12_fp_ptr
#define d2i_PKCS7 d2i_PKCS7_ptr
Expand Down Expand Up @@ -1089,7 +1096,9 @@ extern TYPEOF(OPENSSL_gmtime)* OPENSSL_gmtime_ptr;
#define EVP_MD_CTX_new EVP_MD_CTX_new_ptr
#define EVP_MD_CTX_set_flags EVP_MD_CTX_set_flags_ptr
#define EVP_MD_fetch EVP_MD_fetch_ptr
#define EVP_MD_get0_name EVP_MD_get0_name_ptr
#define EVP_MD_get_size EVP_MD_get_size_ptr
#define EVP_MD_is_a EVP_MD_is_a_ptr
#define EVP_PKCS82PKEY EVP_PKCS82PKEY_ptr
#define EVP_PKEY2PKCS8 EVP_PKEY2PKCS8_ptr
#define EVP_PKEY_CTX_ctrl EVP_PKEY_CTX_ctrl_ptr
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#define OSSL_MAC_PARAM_KEY "key"
#define OSSL_MAC_PARAM_CUSTOM "custom"
#define OSSL_MAC_PARAM_DIGEST "digest"
#define OSSL_MAC_PARAM_XOF "xof"
#define OSSL_MAC_PARAM_SIZE "size"

Expand Down Expand Up @@ -81,6 +82,8 @@ void EVP_MAC_free(EVP_MAC *mac);

EVP_MD* EVP_MD_fetch(OSSL_LIB_CTX *ctx, const char *algorithm, const char *properties);
int EVP_MD_get_size(const EVP_MD* md);
const char *EVP_MD_get0_name(const EVP_MD *md);
int EVP_MD_is_a(const EVP_MD *md, const char *name);
EVP_PKEY_CTX *EVP_PKEY_CTX_new_from_name(OSSL_LIB_CTX *libctx, const char *name, const char *propquery);
EVP_PKEY_CTX *EVP_PKEY_CTX_new_from_pkey(OSSL_LIB_CTX *libctx, EVP_PKEY *pkey, const char *propquery);
int EVP_PKEY_CTX_set_params(EVP_PKEY_CTX *ctx, const OSSL_PARAM *params);
Expand Down
Loading
Loading