-
Notifications
You must be signed in to change notification settings - Fork 84
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
tls: set selfsigned Elliptic Curve (EC) function #17
Conversation
315b5e0
to
cef92be
Compare
src/tls/openssl/tls.c
Outdated
X509_free(cert); | ||
|
||
|
||
return err = 0; |
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.
This return assignment looks a bit strange should it return err;
?
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 u are right. should be a normal return err;
cef92be
to
47ac5b5
Compare
src/tls/openssl/tls.c
Outdated
|
||
if (!X509_set_pubkey(cert, key)) | ||
goto out; | ||
|
||
if (!X509_sign(cert, key, EVP_sha1())) | ||
if (!X509_sign(cert, key, EVP_sha256())) |
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.
is this change done on purpose ?
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.
not on purpose for this PR.
but on purpose in general. Since the SHA1 algo. is broken. This effects the cert. signatures with SHA1 as well. Using SHA2 alogs. is a small but effective change.
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 agree to the change, but I think it should be a separate PR.
also very important to test that it works.
have you done any interop testing with WebRTC browsers ? |
I'm working on a setup baresip-asterisk-sipML5 to test the dtls-srtp with the EC certificates. I will give you more information of my results asap. |
The setup is now baresip<->asterisk<->sipML5. The communication happens between these points. The key exchange via DTLSv1.2 is working with the cert. signed via ECDSA-SHA256 version. The media stream is established and audio data is transmitted. |
did you try to call in both directions ? the DTLS server is normally the caller. also please test with Chrome and Firefox. |
I have tested this patch with Chrome and CtxSip. The calling direction is from baresip to CtxSip. The DTLS handshake fails:
|
at Wire I implemented this function to generate ECDSA cert: https://github.com/wireapp/wire-audio-video-signaling/blob/master/src/cert/cert.c#L37 perhaps this missing part will make it work:
|
47ac5b5
to
0a50d64
Compare
The test-setup is running with the original RSA method. I tested RSA and EC signed certificates against CtxSip with Firefox and Chrome. Both (RSA and EC) worked for both browsers. Call direction was barsip->CtxSip. |
I tested the original code (no patches) between Safari and baresip-webrtc:
please note that in most cases, the DTLS Server is normally the same as the caller. the negotiated cipher depends heavily on the calling direction. try to add this in your code: info(" >> dtls cipher: %s\n", tls_cipher_name(comp->tls_conn)); and try to call in both directions, and then check if the cipher is different. |
additional test with ctxSip, calling both directions: chrome -> baresip: baresip -> chrome: |
with your patch and _ec function used in baresip dtls_srtp module, DTLS handshake fails:
calling direction is from baresip to chrome/ctxsip. |
src/tls/openssl/tls.c
Outdated
int r, err = ENOMEM; | ||
|
||
if (!tls || !cn) | ||
return EINVAL; | ||
|
||
rsa = RSA_new(); | ||
if (!rsa) | ||
eckey = EC_KEY_new_by_curve_name(NID_secp521r1); |
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.
perhaps the curve name can be added as a function argument.
then the application can choose which one to use.
perhaps this curve will make it work: "prime256v1" |
please have a look at this specification: https://tools.ietf.org/html/draft-ietf-rtcweb-security-arch-20#section-6.5
if I change the curve name in your patch to use "prime256v1", it works fine. suggest using this curve or make it configurable via argument string. |
77d76b5
to
f573e27
Compare
this looks good. a small ccheck warning must be fixed before merging:
|
f573e27
to
c963268
Compare
@cHuberCoffee please prevent force-push, its easier to review normal commits and the changes. for cleanup we can squash the pull request afterwards (if necessary). |
looks good now. ready to merge to master, I would say .. |
A new function to generate a self signed cert using elliptic curve cryptographic primitives.
The used elliptic curve is hardcoded with NID_secp521r1.
One can use this function in the barsip dtls_srtp module.