Perl 6 - the future is here, just unevenly distributed

IRC log for #perl6-lwp-gsoc, 2014-06-30

| Channels | #perl6-lwp-gsoc index | Today | | Search | Google Search | Plain-Text | summary

All times shown according to UTC.

Time Nick Message
01:15 FROGGS joined #perl6-lwp-gsoc
02:17 FROGGS joined #perl6-lwp-gsoc
07:22 sergot morning o/
07:44 FROGGS joined #perl6-lwp-gsoc
08:04 FROGGS morning
09:50 sergot Should I clone this https://github.com/grondilu/openssl repo ?
10:10 sergot I did this anyway: https://github.com/sergot/openssl
10:14 sergot Ok, I assume I must bind some openssl functions to start ssl connection, for handshakes and stuff.
10:14 sergot So I should check how can I do this in C.
10:14 sergot Am I right?
10:17 sergot um, s/fork/clone/
10:58 FROGGS that repo might be a good base, yes
10:58 FROGGS but... you want to do stuff in C directly? I don't think that is the right way for the first prototype at least
11:05 sergot Hmm
11:06 sergot My first thought was to create a .c file to wrap some openssl functions
11:06 sergot any way, this looks promising: http://www.ibm.com/developerworks/linux/library/l-openssl/index.html
11:07 sergot FROGGS: nevertheless I should know how to do this in C, just to know which functions should I bind.
11:07 sergot I should bind*
11:14 sergot http://www.openssl.org/docs/ssl/ssl.html
11:16 FROGGS yes, you have to know what you need at some point....
11:16 FROGGS but, in either way you need NativeCall to do the bindings for every function you need, right?
11:17 FROGGS so I don't think you really want to wrap openssl's functions, just to bind your newly created wrapper function
11:18 FROGGS I'd think you bind the low level openssl function directly, and then do further magic in perl
11:18 FROGGS ohh, that article from ibm looks promising
11:23 sergot FROGGS: ok :)
11:29 FROGGS I mean, there might be some opportunity to write C, but you exactly need to know what information you want to pass to C land...
11:30 FROGGS or in case you know that you always call the same three functions in a row
11:48 sergot Ok I'll create a draft file containing my thoughts :)
11:49 sergot I mean .p6 file with bindings
11:52 FROGGS looks like I have to read more about TLS fundamentals...
11:53 sergot same here :)
11:53 sergot But I have some knowledge so far, trying to use it now :)
11:55 FROGGS ++sergot :o)
12:19 sergot NativeCall ... just works, awesome :)
12:26 dalek openssl: 63a4a2b | sergot++ | test.p6:
12:26 dalek openssl: brainstorming
12:26 dalek openssl: review: https://github.com/sergot/openssl/commit/63a4a2b3be
12:26 sergot It's something! :D
12:26 sergot so good so far, but it's not usefule yet
12:30 FROGGS yes, that struct unpacking is just awesome in NativeCall... especially when you know how to do that in XS
12:33 sergot XS? What do you mean?
12:34 FROGGS Perl 5's XS
12:35 FROGGS https://www.youtube.com/watch?v=sD1-bgKm36c
12:36 sergot oh, ok.
12:39 sergot a question FROGGS
12:39 sergot struct { SSL_METHOD *method };
12:39 FROGGS yes
12:39 sergot where SSL_METHOD is a struct too, how should I write this in P6?
12:39 sergot (see test.p6 above)
12:39 FROGGS class Foo { has SSL_METHOD $method }
12:40 FROGGS the members of a struct in C are the attributes of a Perl 6 class
12:40 sergot hmm, I tried that way, and got:
12:41 dalek openssl: e08a813 | sergot++ | test.p6:
12:41 dalek openssl: fail
12:41 dalek openssl: review: https://github.com/sergot/openssl/commit/e08a8134f1
12:41 sergot Cannot look up attributes in a type object
12:41 sergot this
12:42 sergot $.version works for SSL_METHOD
12:42 sergot probably, it contains 768, whatever it is
12:43 FROGGS sergot: can you 'say $ctx' ?
12:44 sergot yes, it's:
12:44 FROGGS looks like it is the type object itself, which means that the SSL_CTX_new function returned NULL
12:44 sergot (SSL_CTX)
12:44 FROGGS see
12:44 sergot hmm
12:45 sergot class SSL_METHOD is incomplete, maybe that's the reason
12:46 FROGGS yes, that seems to be a good bet :o)
12:47 sergot but... http://h71000.www7.hp.com/doc/83final/ba554_90007/apas04.html
12:47 sergot the only field it has is 'version'
12:47 sergot other things are just "methods"
12:47 sergot which needs class (struct) SSL.
12:48 sergot So.. I should start with struct SSL, which needs SSL_METHOD :D
12:48 sergot ym, it needs SSL_CTX
12:48 sergot but CTX needs METHOD
12:48 sergot nvm, I need more info about libssl :)
12:48 FROGGS give me a minute... I need to fix my panda to reinstall NativeCall to actually run it
12:49 sergot okok :)
12:49 sergot Another question, how can I store for example "unsigned long" in P6?
12:52 FROGGS 'int' would translate to 'long' according to https://github.com/jnthn/zavolaj/blob/master/lib/NativeCall.pm6#L73
12:52 FROGGS but it does not handle the unsigned case...
12:52 sergot does it matter in our case?
12:53 FROGGS no idea
12:53 sergot the h71000 site above is not correct, I think. I should use my local source of openssl.
12:55 sergot but it's the same , hmm :)
12:57 sergot FROGGS: anyway, are we able to bind struct's functions into class' methods?
12:58 sergot method ssl_version() is native('libssl') { * }
12:58 sergot will fail
12:58 sergot because it passed Mu as a first argument when calling methods, doesn't it?
12:58 sergot passes
12:58 sergot Should I ask you those questions, or jnthn?
12:59 FROGGS I don't think that NativeCall will pack the Perl 6 methods into a C struct at all
12:59 FROGGS jnthn can also answer this question, yes
13:00 sergot So, what can I do in this case? struct { ...   int (*ssl_version)(void);    }
13:04 FROGGS do it in C?
13:04 FROGGS ó.ò
13:05 FROGGS or wait...
13:05 sergot haha, ó.ò - is really funny, dunno what it means :D
13:06 FROGGS SSLv3_client_method() already gives you a proper METHOD structure, we are just unable to anpack it...
13:06 FROGGS unpack*
13:06 FROGGS ó.ò <--- puppy eyes
13:06 sergot hha, ok :)
13:06 FROGGS ò.ó <-- in contrast to this
13:08 sergot Are my questions too hmmm, obvious?
13:08 FROGGS damn, I was hoping that it would work when we returned a OpaquePointer from *_method, and then pass that to SSL_CTX_new
13:08 sergot and by obvious I mean "noob-ish" or something
13:08 FROGGS no, valid questions these are
13:09 sergot ok :)
13:09 sergot and it didn't work?
13:09 FROGGS correct
13:11 FROGGS hmpf
13:11 FROGGS read the DESCRIPTION here: https://www.openssl.org/docs/ssl/ssl.html
13:12 FROGGS perl6-m test.p6
13:12 FROGGS OpaquePointer.new()
13:12 FROGGS SSL_CTX.new(method => SSL_METHOD.new(version => 769))
13:12 FROGGS SSL_METHOD.new(version => 769)
13:12 sergot \o/
13:13 sergot added you to collaborators
13:13 FROGGS hehe
13:14 FROGGS have you spotted the error?
13:14 sergot trying it now :)
13:14 sergot SSL_library_init ? :)
13:14 FROGGS yes!
13:15 sergot I read this before, I dont know why I forgot about it ..
13:15 FROGGS and we don't need the OpaquePointer change here I mentioned, even when that perhaps is more sane than passing a METHOD that is not allocated correctly
13:17 sergot FROGGS++ thanks, pushing
13:19 dalek openssl: aa4e9e2 | sergot++ | test.p6:
13:19 dalek openssl: SSL_library_init added
13:19 dalek openssl: review: https://github.com/sergot/openssl/commit/aa4e9e26cf
13:19 sergot How can I say, that $.mode and $.options are correct (the are not I think)?
13:20 sergot They look like just random numbers
13:21 FROGGS will take a look
13:21 sergot http://h71000.www7.hp.com/doc/83final/ba554_90007/apas02.html
13:21 sergot according to this, those are unsigned long
13:21 FROGGS btw, that last commit also adds other stuff, not only the SSL_library_init(), please split these things up so that the commit message makes sense
13:22 FROGGS even when we use uint is comes back as garbage...
13:23 FROGGS lol btw: http://stackoverflow.com/questions/10163968/openssl-unable-to-create-ssl-ctx-using-ssl-ctx-new
13:25 sergot :D
13:25 sergot FROGGS: Ok, I'll keep this in my mind
13:31 FROGGS my ssl.h looks like this:
13:31 FROGGS struct ssl_ctx_st
13:31 FROGGS <------>{
13:31 FROGGS <------>const SSL_METHOD *method;
13:31 FROGGS <------>STACK_OF(SSL_CIPHER) *cipher_list;
13:31 FROGGS <------>/* same as above but sorted for lookup */
13:31 FROGGS <------>STACK_OF(SSL_CIPHER) *cipher_list_by_id;
13:31 FROGGS which explains the values I see
13:31 dalek openssl: e749695 | sergot++ | test.p6:
13:31 dalek openssl: SSL_load_error_strings added
13:31 dalek openssl: review: https://github.com/sergot/openssl/commit/e749695093
13:32 sergot hmmm, yes, here is the difference. You are right, I definitely shouldn't use that site anymore.
13:33 dalek openssl: 0adef53 | sergot++ | test.p6:
13:33 dalek openssl: mode and options removed
13:33 dalek openssl: review: https://github.com/sergot/openssl/commit/0adef530d6
13:34 FROGGS so I'd say you do the most stuff in P6 for now, and when something works we port stuff to C to be more portable
13:34 FROGGS i.e. when my struct looks slightly different because it was compiled with different options
13:35 FROGGS or when the openssl folks add another member to that struct, we can still use it from C land without knowing new fields
13:35 sergot Ok :)
13:35 FROGGS (or changed order)
13:44 sergot joined #perl6-lwp-gsoc
14:09 sergot dalek is out, so: ] [Mon May 26 16:32:04 2014]
14:09 sergot 15:44 [Users #perl6-lwp-gsoc]
14:09 sergot ah
14:09 sergot https://github.com/sergot/openssl/commit/744f202edb82080ccb0eb4b029319c82a6780f44
14:09 sergot SSL_CIPHER added
14:10 FROGGS thanks :o)
14:11 sergot This is really interesting :)
14:57 sergot https://github.com/sergot/openssl/commit/0b96acf80e63130cf5c44ab7c3b4833f82fbb9a2
14:57 sergot https://github.com/sergot/openssl/commit/adf5ea2595d052fc4e64fed016e2b2974494e72d
15:01 sergot https://github.com/sergot/openssl/commit/d6656f1511ca54e20a52f1060436776123eb8e91
15:03 sergot https://github.com/sergot/openssl/commit/3ec95af4d03d7ffc4236e2ca87b443eb69929bcc
15:04 sergot and more... :)
15:16 sergot SSL_write and read too.
15:16 sergot I'll make it works soone! (hope so) :)
15:16 sergot soon*
17:11 FROGGS joined #perl6-lwp-gsoc

| Channels | #perl6-lwp-gsoc index | Today | | Search | Google Search | Plain-Text | summary