-
Notifications
You must be signed in to change notification settings - Fork 254
feat: use sha256 if using a fips provider #370
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
base: master
Are you sure you want to change the base?
Conversation
9c2e9bd to
bd9bdfd
Compare
bd9bdfd to
53cb79a
Compare
|
Hi, I agree that we should not be calling MD5 in a FIPs environment. But what we should be doing is looking at all the "algorithm=XXX" strings in the HTTP Response from the ONVIF Device and picking a suitable hashing function that is accepted by the ONVIF device and by FIPS. Is it possible to have some remote access to the ONVIF device you are using which uses SHA256 for some testing. And then I think we need a change that does the following This would make it future proof for SHA512 or anything else the camera offers up. Are you up for making this change, or giving me some remote access from the UK Thanks |
|
I've made changes to the master branch which should help you. Tested with a Hik Camera in MD5-Then-SHA256 mode. So I'll close this PR but please re-open a new one if there are problems. |
|
Hello! |
|
Hi Andrew, _> And if getFips() is ok and hashAlgorithm also is SHA256, then use it. Otherwise use MD5. It is easier than this. What FIPS does is throw an exception if you try and use crypto.createHash with MD5. So instead of a test for _hashAlgorith SHA256, we really need a test for MD5 and getFips() So in Cam.prototype.createHash I can add these two lines I already support this via a try/catch when calling crypto.createHash(). But I can make my code clearer and test for FIPS first. So you are correct that we need to use _hashAlgorith, but we do not need to check for FIPS to use SHA256. It is also worth noting that the ONVIF Core Spec allows a Camera to advertise MD5 and SHA256 support, OR to only use SHA256. I do have to thank @bryopsida for the original PR as it showed up a weakness that the Digest code was hard coded to MD5 and as not using the algorithm=XXX value provided by the ONVIF device. |
When Node.JS is using a FIPS provider,
md5is an unsupported algorithm/routine and calls using it will throw/fail. This adjusts the digest authentication method to check crypto.getFips() and if fips is enabled, it will try to use sha256 instead which can be a supported hashing algorithm for onvif devices.See section 5.9.2