Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace deprecated SHA1 functions #1520

Open
icraggs opened this issue Sep 4, 2024 · 0 comments
Open

Replace deprecated SHA1 functions #1520

icraggs opened this issue Sep 4, 2024 · 0 comments
Milestone

Comments

@icraggs
Copy link
Contributor

icraggs commented Sep 4, 2024

Warnings:


/home/icraggs/git/paho.mqtt.c/src/WebSocket.c:1324:17: warning: ‘SHA1_Init’ is deprecated: Since OpenSSL 3.0 [-Wdeprecated-declarations]
 1324 |                 SHA1_Init( &ctx );

/home/icraggs/git/paho.mqtt.c/src/WebSocket.c:1325:17: warning: ‘SHA1_Update’ is deprecated: Since OpenSSL 3.0 [-Wdeprecated-declarations]
 1325 |                 SHA1_Update( &ctx, ws_key, strlen(ws_key));

/home/icraggs/git/paho.mqtt.c/src/WebSocket.c:1326:17: warning: ‘SHA1_Final’ is deprecated: Since OpenSSL 3.0 [-Wdeprecated-declarations]
 1326 |                 SHA1_Final( sha_hash, &ctx );

Old code:

   SHA_CTX c;
   SHA1_Init(&c);
   SHA1_Update(&c, (const unsigned char *)str, length < 0 ? (unsigned)strlen(str) : (unsigned)length);
   SHA1_Final(&(md[0]), &c);

Replace with:

   EVP_MD_CTX *sha1_ctx = EVP_MD_CTX_new();
   EVP_DigestInit(sha1_ctx, EVP_sha1());
   EVP_DigestUpdate(sha1_ctx, (const unsigned char *)str, length < 0 ? (unsigned)strlen(str) : (unsigned)length);
   EVP_DigestFinal(sha1_ctx, md, NULL);
@icraggs icraggs added this to the 1.3.14 milestone Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant