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

Request for an API to verify signatures #16

Open
sethladd opened this issue Sep 16, 2015 · 6 comments
Open

Request for an API to verify signatures #16

sethladd opened this issue Sep 16, 2015 · 6 comments
Labels
contributions-welcome Contributions welcome to help resolve this (the resolution is expected to be clear from the issue) type-enhancement A request for a change that isn't a bug

Comments

@sethladd
Copy link
Contributor

A customer asked for "anything to help me check a payload against an RSA public key signature? (I think I want to use the sha256WithRSAEncryption algo)." and "I only need the functionality of Chrome's SignatureVerifier class[1], which uses openssl's EVP_PKEY_* and EVP_DigestVerify* and friends."

@sethladd sethladd added the type-enhancement A request for a change that isn't a bug label Sep 16, 2015
@sethladd
Copy link
Contributor Author

cc @mpcomplete

@nex3
Copy link
Member

nex3 commented Sep 23, 2015

@mpcomplete @sethladd Can one of you provide a link to the specification for the signature-verification algorithm you're referring to?

@nex3 nex3 added the contributions-welcome Contributions welcome to help resolve this (the resolution is expected to be clear from the issue) label Sep 23, 2015
@sethladd
Copy link
Contributor Author

I defer to @mpcomplete

@mpcomplete
Copy link

I can't find a spec, but it's part of the X509 signature block. I want to be able to verify a X509 SubjectPublicKeyInfo block using the sha256WithRSAEncryption algorithm. In other words, given a signature, key, and file generated on the command line like so:

echo "Verified text." > file.txt
echo "Invalid text." > tampered.txt
openssl genrsa -out privatekey.pem 2048
openssl rsa -in privatekey.pem -outform PEM -pubout -out publickey.pem
openssl dgst -sha256 -sign privatekey.pem -binary -out signature.sign file.txt

I want to be able to do the equivalent to:

openssl dgst -sha256 -verify publickey.pem -signature signature.sign file.txt ; # should verify OK
openssl dgst -sha256 -verify publickey.pem -signature signature.sign tampered.txt ; # should FAIL

This might just be a matter of exposing the appropriate openssl methods to dart.

Something with the functionality of Chrome's SignatureVerifier would work: https://code.google.com/p/chromium/codesearch#chromium/src/crypto/signature_verifier_openssl.cc&sq=package:chromium&type=cs .

@nex3
Copy link
Member

nex3 commented Sep 23, 2015

It looks like sha256WithRSAEncryption() is described in RFC 5754, section 3.2, although I'm not sure how to read that.

This might just be a matter of exposing the appropriate openssl methods to dart.

Unfortunately, there's not a good way to get access to native code in Dart, at least from a package. Unless we want to put this into the core libraries somehow, someone will need to port the algorithm to Dart.

@mpcomplete
Copy link

Actually, Julien Tinnes recommended against using RSA for signing purposes. Instead, he recommends "SHA256 + ECDSA on P-256".

Equivalent openssl commands:

echo "Verified text." > file.txt
echo "Invalid text." > tampered.txt
openssl ecparam -genkey -name prime256v1 -out privatekey.pem
openssl ec -in privatekey.pem -outform PEM -pubout -out publickey.pem

openssl dgst -sha256 -sign privatekey.pem -binary -out signature.sign file.txt

openssl dgst -sha256 -verify publickey.pem -signature signature.sign file.txt
openssl dgst -sha256 -verify publickey.pem -signature signature.sign tampered.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributions-welcome Contributions welcome to help resolve this (the resolution is expected to be clear from the issue) type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

3 participants