paivana

HTTP paywall reverse proxy
Log | Files | Refs | Submodules | README | LICENSE

paivana-httpd_cookie.h (2699B)


      1 /*
      2      This file is part of GNUnet.
      3      Copyright (C) 2026 Taler Systems SA
      4 
      5      Paivana is free software; you can redistribute it and/or
      6      modify it under the terms of the GNU General Public License
      7      as published by the Free Software Foundation; either version
      8      3, or (at your option) any later version.
      9 
     10      Paivana is distributed in the hope that it will be useful,
     11      but WITHOUT ANY WARRANTY; without even the implied warranty
     12      of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
     13      the GNU General Public License for more details.
     14 
     15      You should have received a copy of the GNU General Public
     16      License along with Paivana; see the file COPYING.  If not,
     17      write to the Free Software Foundation, Inc., 51 Franklin
     18      Street, Fifth Floor, Boston, MA 02110-1301, USA.
     19 */
     20 
     21 /**
     22  * @author Christian Grothoff
     23  * @file paivana-httpd_cookie.h
     24  *
     25  * @brief cookie generation and verification logic
     26  */
     27 #ifndef PAIVANA_HTTPD_COOKIE_H
     28 #define PAIVANA_HTTPD_COOKIE_H
     29 
     30 #include <gnunet/gnunet_util_lib.h>
     31 
     32 /**
     33  * Secret for the cookie generation.
     34  */
     35 extern struct GNUNET_HashCode paivana_secret;
     36 
     37 
     38 /**
     39  * Nonce generated client-side in Paivana protocol.
     40  */
     41 struct PAIVANA_Nonce
     42 {
     43   /**
     44    * Some 128-bit value.
     45    */
     46   uint32_t val[4];
     47 };
     48 
     49 
     50 /**
     51  * Check if the given cookie currently grants access.
     52  *
     53  * @param cookie the cookie
     54  * @param website URL of the site the cookie is for
     55  * @param ca_len number of bytes in @a ca
     56  * @param ca client address
     57  * @return true if the cookie is OK
     58  */
     59 bool
     60 PAIVANA_HTTPD_check_cookie (const char *cookie,
     61                             const char *website,
     62                             size_t ca_len,
     63                             const void *ca);
     64 
     65 /**
     66  * Compute access cookie hash for the given @a expiration and @a ca.
     67  *
     68  * @param expiration expiration time of the cookie
     69  * @param website URL of the site the cookie is for
     70  * @param ca_len number of bytes in @a ca
     71  * @param ca client address
     72  * @param[out] c set to the cookie hash
     73  */
     74 char *
     75 PAIVANA_HTTPD_compute_cookie (struct GNUNET_TIME_Timestamp cur_time,
     76                               const char *website,
     77                               size_t ca_len,
     78                               const void *ca);
     79 
     80 
     81 /**
     82  * Compute the Paivana ID for the given @a cur_time,
     83  * @a website and @a nonce.
     84  *
     85  * @param cur_time time chosen (by client)
     86  * @param website website to be accessed
     87  * @param nonce client-selected nonce
     88  * @return corresponding Paivana ID.
     89  */
     90 char *
     91 PAIVANA_HTTPD_compute_paivana_id (struct GNUNET_TIME_Timestamp cur_time,
     92                                   const char *website,
     93                                   const struct PAIVANA_Nonce *nonce);
     94 
     95 
     96 #endif