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

build: add missing randomness checks #2772

Merged
merged 3 commits into from
Jul 17, 2024

Conversation

div72
Copy link
Member

@div72 div72 commented Jul 3, 2024

No description provided.

@div72 div72 self-assigned this Jul 3, 2024
@jamescowens jamescowens self-requested a review July 3, 2024 16:09
@jamescowens jamescowens added this to the Natasha milestone Jul 3, 2024
Copy link
Member

@jamescowens jamescowens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK. This is marked still in progress, but looks good to me.

@div72
Copy link
Member Author

div72 commented Jul 4, 2024

@wilkart What version of FreeBSD are you using?

@wilkart
Copy link
Contributor

wilkart commented Jul 4, 2024

@div72 My recent approach was on FreeBSD 14.0 but I use many FreeBSD releases so I can easily verify the build on all supported if we need.
https://www.freebsd.org/security/#sup

@div72
Copy link
Member Author

div72 commented Jul 4, 2024

@wilkart I got use of undeclared identifier: 'be32enc' with 14.1 on this PR, can you try that?

@wilkart
Copy link
Contributor

wilkart commented Jul 10, 2024

Dear @div72, it seems on FreeBSD 14.1 the change I pass below (reverting to original) allows building. I suggest we revert my solution. I will check in future release of 13.4-RELEASE.
In next step I will update document how to build on FreeBSD 14.1 and higher releases.

[gridcoin@amarara ~/Gridcoin-Research]$ git diff
diff --git a/src/pbkdf2.cpp b/src/pbkdf2.cpp
index bcd75f3f8..588b50e7d 100644
--- a/src/pbkdf2.cpp
+++ b/src/pbkdf2.cpp
@@ -16,7 +16,6 @@ be32dec(const void *pp)
 }
 */

-#ifndef __FreeBSD__
 static inline void
 be32enc(void *pp, uint32_t x)
 {
@@ -27,7 +26,6 @@ be32enc(void *pp, uint32_t x)
     p[1] = (x >> 16) & 0xff;
     p[0] = (x >> 24) & 0xff;
 }
-#endif

 /**
  * PBKDF2_SHA256(passwd, passwdlen, salt, saltlen, c, buf, dkLen):

1a6f001 introduced code using new
defines from checks not implemented yet. This is ok as the fallback
code that reads /dev/urandom is triggered instead but let's use the
proper interface.
be32enc is a function on BSDs which can lead to conflicts. Use the
WriteBE32 function that's used in crypto code instead.
@div72 div72 marked this pull request as ready for review July 15, 2024 18:59
@wilkart
Copy link
Contributor

wilkart commented Jul 17, 2024

@div72
I confirm I have successfully built on both FreeBSD 13.3-RELEASE and FreeBSD 14.1-RELEASE after your refactoring to use WriteBE32.

Copy link
Member

@jamescowens jamescowens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK

@jamescowens jamescowens merged commit 4ae471e into gridcoin-community:development Jul 17, 2024
21 checks passed
@div72 div72 deleted the add-checks branch September 3, 2024 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants