libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

md5_ext.h (2898B)


      1 /*
      2      This file is part of GNU libmicrohttpd
      3      Copyright (C) 2022-2024 Evgeny Grin (Karlson2k)
      4 
      5      GNU libmicrohttpd is free software; you can redistribute it and/or
      6      modify it under the terms of the GNU Lesser General Public
      7      License as published by the Free Software Foundation; either
      8      version 2.1 of the License, or (at your option) any later version.
      9 
     10      This library is distributed in the hope that it will be useful,
     11      but WITHOUT ANY WARRANTY; without even the implied warranty of
     12      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     13      Lesser General Public License for more details.
     14 
     15      You should have received a copy of the GNU Lesser General Public
     16      License along with GNU libmicrohttpd.
     17      If not, see <http://www.gnu.org/licenses/>.
     18 */
     19 /**
     20  * @file microhttpd/md5_ext.h
     21  * @brief  Wrapper declarations for MD5 calculation performed by TLS library
     22  * @author Karlson2k (Evgeny Grin)
     23  */
     24 #ifndef MHD_MD5_EXT_H
     25 #define MHD_MD5_EXT_H 1
     26 
     27 #include "mhd_options.h"
     28 #include <stdint.h>
     29 #ifdef HAVE_STDDEF_H
     30 #include <stddef.h>  /* for size_t */
     31 #endif /* HAVE_STDDEF_H */
     32 
     33 /**
     34  * Size of MD5 resulting digest in bytes
     35  * This is the final digest size, not intermediate hash.
     36  */
     37 #define MD5_DIGEST_SIZE (16)
     38 
     39 /* Actual declaration is in GnuTLS lib header */
     40 struct hash_hd_st;
     41 
     42 /**
     43  * Indicates that struct Md5CtxExt has 'ext_error'
     44  */
     45 #define MHD_MD5_HAS_EXT_ERROR 1
     46 
     47 /**
     48  * MD5 calculation context
     49  */
     50 struct Md5CtxExt
     51 {
     52   struct hash_hd_st *handle; /**< Hash calculation handle */
     53   int ext_error; /**< Non-zero if external error occurs during init or hashing */
     54 };
     55 
     56 /**
     57  * Indicates that MHD_MD5_init_one_time() function is present.
     58  */
     59 #define MHD_MD5_HAS_INIT_ONE_TIME 1
     60 
     61 /**
     62  * Initialise structure for MD5 calculation, allocate resources.
     63  *
     64  * This function must not be called more than one time for @a ctx.
     65  *
     66  * @param ctx the calculation context
     67  */
     68 void
     69 MHD_MD5_init_one_time (struct Md5CtxExt *ctx);
     70 
     71 
     72 /**
     73  * MD5 process portion of bytes.
     74  *
     75  * @param ctx the calculation context
     76  * @param data bytes to add to hash
     77  * @param length number of bytes in @a data
     78  */
     79 void
     80 MHD_MD5_update (struct Md5CtxExt *ctx,
     81                 const uint8_t *data,
     82                 size_t length);
     83 
     84 
     85 /**
     86  * Indicates that MHD_MD5_finish_reset() function is available
     87  */
     88 #define MHD_MD5_HAS_FINISH_RESET 1
     89 
     90 /**
     91  * Finalise MD5 calculation, return digest, reset hash calculation.
     92  *
     93  * @param ctx the calculation context
     94  * @param[out] digest set to the hash, must be #MD5_DIGEST_SIZE bytes
     95  */
     96 void
     97 MHD_MD5_finish_reset (struct Md5CtxExt *ctx,
     98                       uint8_t digest[MD5_DIGEST_SIZE]);
     99 
    100 /**
    101  * Indicates that MHD_MD5_deinit() function is present
    102  */
    103 #define MHD_MD5_HAS_DEINIT 1
    104 
    105 /**
    106  * Free allocated resources.
    107  *
    108  * @param ctx the calculation context
    109  */
    110 void
    111 MHD_MD5_deinit (struct Md5CtxExt *ctx);
    112 
    113 #endif /* MHD_MD5_EXT_H */