-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Added pkcs5_pbkdf2_hmac
to lib_crypto.cr
and pkcs5.cr
#5021
Added pkcs5_pbkdf2_hmac
to lib_crypto.cr
and pkcs5.cr
#5021
Conversation
libcrypto was not found if I understood correctly the CircleCI error... |
a141b97
to
dc525e2
Compare
Hey @aurimasniekis, welcome and congrats for your first contribution to Crystal 🎉 |
a377535
to
b2a2921
Compare
Hi, @sdogruyol thanks your welcoming! I can't figure out why build doesn't want to work. I tried the same solution which helped to build on my local machine but it doesn't work. The most interesting thing that original |
@Sija thanks for the suggestion, I will try it out. But why then previous |
@aurimasniekis I guess because it has been changed between OpenSSL versions |
1cb97a4
to
30348ef
Compare
@aurimasniekis FYI, |
37f58c5
to
cf7835c
Compare
I modified |
Makefile
Outdated
@@ -27,7 +27,7 @@ static ?= ## Enable static linking | |||
O := .build | |||
SOURCES := $(shell find src -name '*.cr') | |||
SPEC_SOURCES := $(shell find spec -name '*.cr') | |||
FLAGS := $(if $(release),--release )$(if $(stats),--stats )$(if $(progress),--progress )$(if $(threads),--threads $(threads) )$(if $(debug),-d )$(if $(static),--static ) | |||
FLAGS := $(if $(release),--release )$(if $(stats),--stats )$(if $(progress),--progress )$(if $(threads),--threads $(threads) )$(if $(debug),-d )$(if $(static),--static )$(if $(CRYSTAL_FLAGS),$(CRYSTAL_FLAGS) ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Splitting $(CRYSTAL_FLAGS)
changes into a separate line for sake of clarity might be a good thing here, WDYT @aurimasniekis?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you think it's better than yes I could do it. But personally, I do not think many people go into Makefile
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so, yes. ATM it's the longest line in the whole file and this change would make it even longer, not nice.
spec/std/openssl/pkcs5_spec.cr
Outdated
{2**16, 16, "1b345dd55f62a35aecdb9229bc7ae95b"}, | ||
{2**16, 32, "1b345dd55f62a35aecdb9229bc7ae95b305a8d538940134627e46f82d3a41e5e"}, | ||
].each do |(iterations, key_size, expected)| | ||
OpenSSL::PKCS5.pbkdf2_hmac(:sha1, "password", "salt", iterations, key_size).hexstring.should eq expected |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add samples for other algos as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I should do it... I was bit lazy...
spec/std/openssl/pkcs5_spec.cr
Outdated
@@ -12,4 +12,15 @@ describe OpenSSL::PKCS5 do | |||
OpenSSL::PKCS5.pbkdf2_hmac_sha1("password", "salt", iterations, key_size).hexstring.should eq expected | |||
end | |||
end | |||
|
|||
it "computes pbkdf2_hmac" do | |||
[ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could use a tuple here instead of an array
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will try because I just copied from original test case
We don't have a strong policy about supported OpenSSL versions in Crystal, but v0.9.8 is still used and deployed a lot. If an OpenSSL feature is only available on "recent" OpenSSL release, there should be an OpenSSL version check to enable the feature, just like we do for other OpenSSL features that are only available in v1.0 or v1.1. |
@Sija sorry, I forgot about this PR after holidays |
cf7835c
to
8b6a2c4
Compare
Could someone explain the CircleCI error
|
@aurimasniekis it's a check done by |
8b6a2c4
to
7438838
Compare
@Sija thanks, fixed |
Is there any more movement on this PR? |
Hi - I really need this - I've taken the code and patched my library to get it to work - but it would be really awesome if would be integrated into Crystal so I could avoid the patching |
Resolved by #6975 |
Added
pkcs5_pbkdf2_hmac
function to support pbkdf2 with multiple algorithm