4 years agoAdd zb32_index function.
Werner Koch [Fri, 23 May 2014 17:19:11 +0000 (19:19 +0200)]
Add zb32_index function.

* src/util.c (zb32_index): New.
(zb32_encode): Factor table out to
(zb32asc): .. static global.

4 years agoCheck that GNUTLS 3.0 has been installed.
Werner Koch [Thu, 22 May 2014 14:02:22 +0000 (16:02 +0200)]
Check that GNUTLS 3.0 has been installed.

(LIBGNUTLS): Fix gnutls version check.

4 years agoAdd zb32 encoder.
Werner Koch [Thu, 22 May 2014 14:00:16 +0000 (16:00 +0200)]
Add zb32 encoder.

* src/util.c (zb32_encode): New.

The code has been taken from current GnuPG master common/zb32.c.

4 years agoMake use of the samethread mode keyword.
Werner Koch [Tue, 15 Apr 2014 14:40:48 +0000 (16:40 +0200)]
Make use of the samethread mode keyword.

* src/connection.c (connection_handler): Open stream with samethread.
* src/payprocd.c (already_running_p): Ditto.
* src/journal.c (start_record): Open memstream with samethread.

4 years agoestream: Implement "samethread" mode keyword.
Werner Koch [Tue, 15 Apr 2014 14:40:48 +0000 (16:40 +0200)]
estream: Implement "samethread" mode keyword.

* src/estream.c (estream_internal): Add field SAMETHREAD.
(init_stream_lock, lock_stream, trylock_stream, unlock_stream): Use it.
(parse_mode): Add arg SAMETHREAD and parse that keyword.
(es_initialize): Rename to ...
(init_stream_obj): this.  Add arg SAMETHREAD.
(es_create): Add arg SAMETHREAD.  Call init_stream_lock after
(doreadline): Call es_create with samethread flag.
(es_fopen, es_mopen, es_fopenmem, es_fopencookie, do_fdopen)
(do_fpopen, do_w32open): Implement "samethread" keyword.
(es_freopen): Take samthread flag from old stream.
(es_tmpfile): Call es)_create w/o samethread.

Note: Unfortunately es_tmpfile has no mode arg so that we can't use

4 years agoestream: Fix deadlock in s_fileno.
Werner Koch [Tue, 15 Apr 2014 14:40:48 +0000 (16:40 +0200)]
estream: Fix deadlock in s_fileno.

* src/estream.c (es_fileno_unlocked): Call the unlocked functions.

4 years agoestream: Add debug code to the lock functions.
Werner Koch [Tue, 15 Apr 2014 14:40:48 +0000 (16:40 +0200)]
estream: Add debug code to the lock functions.

4 years agoestream: Replace locking macros by functions.
Werner Koch [Tue, 15 Apr 2014 14:40:48 +0000 (16:40 +0200)]
estream: Replace locking macros by functions.


The macros were too hard to read and actually blew up the source.

4 years agoMove the command reference to a separate file.
Werner Koch [Tue, 15 Apr 2014 14:40:48 +0000 (16:40 +0200)]
Move the command reference to a separate file.


4 years agoAdd command CHECKAMOUNT
Werner Koch [Tue, 15 Apr 2014 14:40:48 +0000 (16:40 +0200)]

* src/connection.c (cmd_checkamount): New.

5 years agoRelease 0.1.0 payproc-0.1.0
Werner Koch [Tue, 15 Apr 2014 14:40:48 +0000 (16:40 +0200)]
Release 0.1.0

5 years agoReturn error messages and write a journal.
Werner Koch [Tue, 15 Apr 2014 14:40:48 +0000 (16:40 +0200)]
Return error messages and write a journal.

5 years agoPost release updates
Werner Koch [Thu, 3 Apr 2014 11:43:24 +0000 (13:43 +0200)]
Post release updates


5 years agoRelease 0.0.0 payproc-0.0.0
Werner Koch [Thu, 3 Apr 2014 11:37:14 +0000 (13:37 +0200)]
Release 0.0.0


Do not use this release for real transactions.

5 years agoVerify the TLS connection's peer.
Werner Koch [Thu, 3 Apr 2014 11:33:28 +0000 (13:33 +0200)]
Verify the TLS connection's peer.

* src/http.c (http_session_s): Add fields verify and servername.
(tls_ca_certlist): New.
(http_register_tls_ca): New.
(http_session_new): Set the CA certs into the credentials.
(send_request): Store the servername.
(http_verify_server_credentials): New.
* src/t-http.c (main): Register CAs.
(verify_callback): Call the new verify function.
* src/tlssupport.c (verify_callback): Ditto.
* src/tls-ca.pem: New.

We should implement a better system than to read the CA certs from the
file every time.  Keeping default credentials object would thus be

tls-ca.pem has certificates for  They use different root
CA and even a 1014 bit one.  The whole PKIX is anyway broken, so who
cares.  I considered to check just the fingerprint of the actual
certificate but that won't allow for an easy certificate replacement

5 years agoAdd a lot of more stuff.
Werner Koch [Wed, 2 Apr 2014 19:50:27 +0000 (21:50 +0200)]
Add a lot of more stuff.

* src/cred.c, src/cred.h: New.  Based on code from libassuan.
* src/t-connection.c: New.
* src/util.c (trim_spaces): New.  From GnuPG.
(keyvalue_put, keyvalue_putf): Add sanity check.
* src/util.h (spacep, digitp, hexdigitp): New.
(ascii_isspace): New.
* src/stripe.c (stripe_create_card_token): Replace test key by option
(stripe_charge_card): New.
* src/payprocd.c: Add option parsing.  Beautify disagnositcs for new
connections.  Allow setting of a stripe key.
(already_running_p): Implement.
(create_socket): Move log file setting to ...
(launch_server): here.
* src/connection.c (set_error): New.
(struct conn_s): Add field IDNO.
(currency_table): New.
(new_connection_obj): Set IDNO
(fd_from_connection_obj): New.
(id_from_connection_obj): New.
(capitalize_name): Add special case for brackets.
(valid_currency_p): New.
(convert_amount): New.
(cmd_cardtoken): Add plausibility checks.
(cmd_chargecard): New.
(cmd_getinfo): New.
(cmd_ping): New.
(connection_handler): Add new commands.  Call es_fflush.

5 years agoAdd argparse.c from GnuPG.
Werner Koch [Wed, 2 Apr 2014 19:41:25 +0000 (21:41 +0200)]
Add argparse.c from GnuPG.


5 years agoSimplify cJSON and add new macros.
Werner Koch [Wed, 2 Apr 2014 07:01:42 +0000 (09:01 +0200)]
Simplify cJSON and add new macros.

* src/cJSON.h: Re-indented.
(cjson_t): New.
(cjson_is_): New macros.
* src/cJSON.c: Re-indented.  Include errno.h and our util.h.
(ep): Remove global var.
(cJSON_GetErrorPtr): Remove.
(cJSON_strcasecmp): Cast args for use with tolower.
(cJSON_malloc, cJSON_free): Remove.  Change callers to use xtrymalloc
and xfree.
(cJSON_InitHooks): Remove.
(cJSON_strdup): Remove.  Change callers to use xtrystrdup.
(cJSON_New_Item): Simplify.
(cJSON_ParseWithOpts, cJSON_Parse): Add arg R_ERROFF.
(parse_string, parse_value, parse_array, parse_object): Add arg EP.

cJSON has been taken from  The README file has been
renamed to cJSON.readme and the files have been changed to GNU coding
standards.  Because that parser is small enough to be source copied it
does not make sense to treat it as a library and I changed the memory
allocation functions to the usual xmalloc ones. The only external
dependency now is out util.h which declares those functions.

The lowercase cjson_t better fits into our coding style as well as the
new macros.  Thanks to Dave Gamble for this nice parser.

5 years agoInitial checkin.
Werner Koch [Wed, 2 Apr 2014 06:46:36 +0000 (08:46 +0200)]
Initial checkin.