When built against OpenSSL 3.0.0-beta2 (my own build), the C program
#include <openssl/evp.h>
int main(void)
{
const char *const name = "MD5";
const unsigned char key[] = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b";
const int key_len = 16;
const unsigned char data[] = "Hi There";
const int data_len = 8;
EVP_MD_CTX *ctx;
EVP_PKEY *pkey;
unsigned char buf[EVP_MAX_MD_SIZE];
size_t buf_len;
int ret;
size_t i, n;
ctx = EVP_MD_CTX_new();
if (ctx == NULL) abort();
pkey = EVP_PKEY_new_mac_key(EVP_PKEY_HMAC, NULL, key, key_len);
if (pkey == NULL) abort();
ret = EVP_DigestSignInit(ctx, NULL, EVP_get_digestbyname(name), NULL, pkey);
if (ret != 1) abort();
EVP_PKEY_free(pkey);
ret = EVP_DigestSignUpdate(ctx, data, data_len);
if (ret != 1) abort();
for (n = 0; n < 2; n += 1) {
ret = EVP_DigestSignFinal(ctx, buf, &buf_len);
if (ret != 1) abort();
printf("0x");
for (i = 0; i < buf_len; i += 1)
printf("%02x", buf[i]);
printf("\n");
}
return 0;
}
prints out
0x9294727a3638bb1c13f48ef8158bfc9d
0x47de897f45806cf1a5a78277cd74b5dc
I am not sure if this is a bug or not, but this behavior is inconsistent with 1.1.1k (Gentoo) with which EVP_DigestSignFinal places the same value as the signature every time when called consecutively.
When built against OpenSSL 3.0.0-beta2 (my own build), the C program
prints out
I am not sure if this is a bug or not, but this behavior is inconsistent with 1.1.1k (Gentoo) with which
EVP_DigestSignFinalplaces the same value as the signature every time when called consecutively.