Is this not supposed to work in OpenSSL 3.0.x+?
Karl Denninger <[email protected]>
| Newsgroups | gmane.comp.encryption.openssl.user |
|---|---|
| Message-ID | <[email protected]> |
[karl@NewFS ~/tmp]$ cat test.c
#include <stdio.h>
#include <string.h>
#include <openssl/evp.h>
#include <openssl/hmac.h>
int main() {
const char *key = "secretkey";
const char *msg = "This is the message";
unsigned char hmac_result[EVP_MAX_MD_SIZE];
unsigned int hmac_len;
HMAC(EVP_sha256(), key, strlen(key), (unsigned char*)msg, strlen(msg),
hmac_result, &hmac_len);
printf("HMAC-SHA256: ");
for (int i = 0; i < hmac_len; i++) {
printf("%02x", hmac_result[i]);
}
printf("\n");
return 0;
}
[karl@NewFS ~/tmp]$ cc -o test test.c -lssl
ld: error: undefined symbol: EVP_sha256
>>> referenced by test.c
>>> /tmp/test-8e4787.o:(main)
ld: error: undefined symbol: HMAC
>>> referenced by test.c
>>> /tmp/test-8e4787.o:(main)
cc: error: linker command failed with exit code 1 (use -v to see invocation)
[karl@NewFS ~/tmp]$ openssl version
OpenSSL 3.0.16 11 Feb 2025 (Library: OpenSSL 3.0.16 11 Feb 2025)
[karl@NewFS ~/tmp]$
If I do a "strings" on /usr/lib/libssl.so I do indeed see an HMAC function
-- but not the EVP_sha256() one.
This is on FreeBSD 14.2-STABLE if that matters. I only need a one-shot
HMAC computation so doing the entire EVP setup is a waste.
--
You received this message because you are subscribed to the Google Groups "openssl-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openssl-users+unsubscribe-MCmKBN63+Bmbup2nOX2J7Q@public.gmane.org
To view this discussion visit https://groups.google.com/a/openssl.org/d/msgid/openssl-users/5023285b-416c-457a-b67d-f9b5fef76229n%40openssl.org.