2015-01-28 20:10:59 +01:00
|
|
|
/*
|
|
|
|
This file is part of TALER
|
2015-03-15 17:17:29 +01:00
|
|
|
Copyright (C) 2014, 2015 GNUnet e.V.
|
2015-01-28 20:10:59 +01:00
|
|
|
|
|
|
|
TALER is free software; you can redistribute it and/or modify it under the
|
|
|
|
terms of the GNU Affero General Public License as published by the Free Software
|
|
|
|
Foundation; either version 3, or (at your option) any later version.
|
|
|
|
|
|
|
|
TALER is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
|
|
A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Affero General Public License along with
|
|
|
|
TALER; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/>
|
|
|
|
*/
|
|
|
|
/**
|
2015-03-15 17:17:29 +01:00
|
|
|
* @file mint/taler-mint-httpd_keystate.h
|
2015-01-28 20:10:59 +01:00
|
|
|
* @brief management of our private signing keys (denomination keys)
|
|
|
|
* @author Florian Dold
|
|
|
|
* @author Benedikt Mueller
|
|
|
|
* @author Christian Grothoff
|
|
|
|
*/
|
|
|
|
#ifndef TALER_MINT_HTTPD_KEYSTATE_H
|
|
|
|
#define TALER_MINT_HTTPD_KEYSTATE_H
|
|
|
|
|
|
|
|
#include <gnunet/gnunet_util_lib.h>
|
|
|
|
#include <microhttpd.h>
|
|
|
|
#include "taler-mint-httpd.h"
|
2015-03-28 11:06:00 +01:00
|
|
|
#include "taler_mintdb_lib.h"
|
2015-01-28 20:10:59 +01:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Snapshot of the (coin and signing)
|
|
|
|
* keys (including private keys) of the mint.
|
|
|
|
*/
|
2015-03-27 19:58:40 +01:00
|
|
|
struct TMH_KS_StateHandle;
|
2015-01-28 20:10:59 +01:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Acquire the key state of the mint. Updates keys if necessary.
|
2015-03-27 19:58:40 +01:00
|
|
|
* For every call to #TMH_KS_acquire(), a matching call
|
|
|
|
* to #TMH_KS_release() must be made.
|
2015-01-28 20:10:59 +01:00
|
|
|
*
|
|
|
|
* @return the key state
|
|
|
|
*/
|
2015-03-27 19:58:40 +01:00
|
|
|
struct TMH_KS_StateHandle *
|
|
|
|
TMH_KS_acquire (void);
|
2015-01-28 20:10:59 +01:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Release key state, free if necessary (if reference count gets to zero).
|
|
|
|
*
|
|
|
|
* @param key_state the key state to release
|
|
|
|
*/
|
|
|
|
void
|
2015-03-27 19:58:40 +01:00
|
|
|
TMH_KS_release (struct TMH_KS_StateHandle *key_state);
|
2015-01-28 20:10:59 +01:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
2015-03-15 17:17:29 +01:00
|
|
|
* Look up the issue for a denom public key. Note that the result
|
|
|
|
* is only valid while the @a key_state is not released!
|
2015-01-28 20:10:59 +01:00
|
|
|
*
|
2015-03-28 15:42:07 +01:00
|
|
|
* @param key_state state to look in
|
2015-01-28 20:10:59 +01:00
|
|
|
* @param denom_pub denomination public key
|
|
|
|
* @return the denomination key issue,
|
|
|
|
* or NULL if denom_pub could not be found
|
|
|
|
*/
|
2015-03-28 12:29:35 +01:00
|
|
|
struct TALER_MINTDB_DenominationKeyIssueInformation *
|
2015-03-27 19:58:40 +01:00
|
|
|
TMH_KS_denomination_key_lookup (const struct TMH_KS_StateHandle *key_state,
|
|
|
|
const struct TALER_DenominationPublicKey *denom_pub);
|
2015-01-28 20:10:59 +01:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Read signals from a pipe in a loop, and reload keys from disk if
|
|
|
|
* SIGUSR1 is read from the pipe.
|
|
|
|
*
|
2015-03-15 17:17:29 +01:00
|
|
|
* @return #GNUNET_OK if we terminated normally,
|
|
|
|
* #GNUNET_SYSERR on error
|
2015-01-28 20:10:59 +01:00
|
|
|
*/
|
|
|
|
int
|
2015-03-27 19:58:40 +01:00
|
|
|
TMH_KS_loop (void);
|
2015-01-28 20:10:59 +01:00
|
|
|
|
|
|
|
|
2015-01-28 20:59:39 +01:00
|
|
|
/**
|
|
|
|
* Sign the message in @a purpose with the mint's signing
|
|
|
|
* key.
|
|
|
|
*
|
|
|
|
* @param purpose the message to sign
|
2015-03-28 15:42:07 +01:00
|
|
|
* @param[out] sig signature over purpose using current signing key
|
2015-01-28 20:59:39 +01:00
|
|
|
*/
|
|
|
|
void
|
2015-03-27 19:58:40 +01:00
|
|
|
TMH_KS_sign (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
|
|
|
|
struct TALER_MintSignatureP *sig);
|
2015-01-28 20:59:39 +01:00
|
|
|
|
2015-01-28 20:10:59 +01:00
|
|
|
|
2015-03-15 15:40:07 +01:00
|
|
|
/**
|
|
|
|
* Handle a "/keys" request
|
|
|
|
*
|
|
|
|
* @param rh context of the handler
|
|
|
|
* @param connection the MHD connection to handle
|
2015-03-28 15:42:07 +01:00
|
|
|
* @param[in,out] connection_cls the connection's closure (can be updated)
|
2015-03-15 15:40:07 +01:00
|
|
|
* @param upload_data upload data
|
2015-03-28 15:42:07 +01:00
|
|
|
* @param[in,out] upload_data_size number of bytes (left) in @a upload_data
|
2015-03-15 15:40:07 +01:00
|
|
|
* @return MHD result code
|
|
|
|
*/
|
|
|
|
int
|
2015-03-27 19:58:40 +01:00
|
|
|
TMH_KS_handler_keys (struct TMH_RequestHandler *rh,
|
|
|
|
struct MHD_Connection *connection,
|
|
|
|
void **connection_cls,
|
|
|
|
const char *upload_data,
|
|
|
|
size_t *upload_data_size);
|
2015-03-15 15:40:07 +01:00
|
|
|
|
2015-01-28 20:10:59 +01:00
|
|
|
|
|
|
|
#endif
|