Home | History | Annotate | Line # | Download | only in libarchive
      1 /*-
      2 * Copyright (c) 2003-2007 Tim Kientzle
      3 * Copyright (c) 2011 Andres Mejia
      4 * All rights reserved.
      5 *
      6 * Redistribution and use in source and binary forms, with or without
      7 * modification, are permitted provided that the following conditions
      8 * are met:
      9 * 1. Redistributions of source code must retain the above copyright
     10 *    notice, this list of conditions and the following disclaimer.
     11 * 2. Redistributions in binary form must reproduce the above copyright
     12 *    notice, this list of conditions and the following disclaimer in the
     13 *    documentation and/or other materials provided with the distribution.
     14 *
     15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
     16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     18 * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
     19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     25 */
     26 
     27 #ifndef ARCHIVE_DIGEST_PRIVATE_H_INCLUDED
     28 #define ARCHIVE_DIGEST_PRIVATE_H_INCLUDED
     29 
     30 #ifndef __LIBARCHIVE_BUILD
     31 #error This header is only to be used internally to libarchive.
     32 #endif
     33 #ifndef __LIBARCHIVE_CONFIG_H_INCLUDED
     34 #error "Should have include config.h first!"
     35 #endif
     36 
     37 /*
     38  * Crypto support in various Operating Systems:
     39  *
     40  * NetBSD:
     41  * - MD5 and SHA1 in libc: without _ after algorithm name
     42  * - SHA2 in libc: with _ after algorithm name
     43  *
     44  * OpenBSD:
     45  * - MD5, SHA1 and SHA2 in libc: without _ after algorithm name
     46  * - OpenBSD 4.4 and earlier have SHA2 in libc with _ after algorithm name
     47  *
     48  * DragonFly and FreeBSD:
     49  * - MD5 libmd: without _ after algorithm name
     50  * - SHA1, SHA256 and SHA512 in libmd: with _ after algorithm name
     51  *
     52  * Mac OS X (10.4 and later):
     53  * - MD5, SHA1 and SHA2 in libSystem: with CC_ prefix and _ after algorithm name
     54  *
     55  * OpenSSL:
     56  * - MD5, SHA1 and SHA2 in libcrypto: with _ after algorithm name
     57  *
     58  * Windows:
     59  * - MD5, SHA1 and SHA2 in archive_crypto.c using Windows crypto API
     60  */
     61 
     62 /* libc crypto headers */
     63 #if defined(ARCHIVE_CRYPTO_MD5_LIBC)
     64 #include <md5.h>
     65 #endif
     66 #if defined(ARCHIVE_CRYPTO_RMD160_LIBC)
     67 #include <rmd160.h>
     68 #endif
     69 #if defined(ARCHIVE_CRYPTO_SHA1_LIBC)
     70 #include <sha1.h>
     71 #endif
     72 #if defined(ARCHIVE_CRYPTO_SHA256_LIBC) ||\
     73   defined(ARCHIVE_CRYPTO_SHA256_LIBC2) ||\
     74   defined(ARCHIVE_CRYPTO_SHA256_LIBC3) ||\
     75   defined(ARCHIVE_CRYPTO_SHA384_LIBC) ||\
     76   defined(ARCHIVE_CRYPTO_SHA384_LIBC2) ||\
     77   defined(ARCHIVE_CRYPTO_SHA384_LIBC3) ||\
     78   defined(ARCHIVE_CRYPTO_SHA512_LIBC) ||\
     79   defined(ARCHIVE_CRYPTO_SHA512_LIBC2) ||\
     80   defined(ARCHIVE_CRYPTO_SHA512_LIBC3)
     81 #include <sha2.h>
     82 #endif
     83 
     84 /* libmd crypto headers */
     85 #if defined(ARCHIVE_CRYPTO_MD5_LIBMD) ||\
     86   defined(ARCHIVE_CRYPTO_RMD160_LIBMD) ||\
     87   defined(ARCHIVE_CRYPTO_SHA1_LIBMD) ||\
     88   defined(ARCHIVE_CRYPTO_SHA256_LIBMD) ||\
     89   defined(ARCHIVE_CRYPTO_SHA512_LIBMD)
     90 #define	ARCHIVE_CRYPTO_LIBMD 1
     91 #endif
     92 
     93 #if defined(ARCHIVE_CRYPTO_MD5_LIBMD)
     94 #include <md5.h>
     95 #endif
     96 #if defined(ARCHIVE_CRYPTO_RMD160_LIBMD)
     97 #include <ripemd.h>
     98 #endif
     99 #if defined(ARCHIVE_CRYPTO_SHA1_LIBMD)
    100 #include <sha.h>
    101 #endif
    102 #if defined(ARCHIVE_CRYPTO_SHA256_LIBMD)
    103 #include <sha256.h>
    104 #endif
    105 #if defined(ARCHIVE_CRYPTO_SHA512_LIBMD)
    106 #include <sha512.h>
    107 #endif
    108 
    109 /* libSystem crypto headers */
    110 #if defined(ARCHIVE_CRYPTO_MD5_LIBSYSTEM) ||\
    111   defined(ARCHIVE_CRYPTO_SHA1_LIBSYSTEM) ||\
    112   defined(ARCHIVE_CRYPTO_SHA256_LIBSYSTEM) ||\
    113   defined(ARCHIVE_CRYPTO_SHA384_LIBSYSTEM) ||\
    114   defined(ARCHIVE_CRYPTO_SHA512_LIBSYSTEM)
    115 #include <CommonCrypto/CommonDigest.h>
    116 #define	ARCHIVE_CRYPTO_CommonCrypto 1
    117 #endif
    118 
    119 /* mbed TLS crypto headers */
    120 #if defined(ARCHIVE_CRYPTO_MD5_MBEDTLS)
    121 #include <mbedtls/md5.h>
    122 #endif
    123 #if defined(ARCHIVE_CRYPTO_RMD160_MBEDTLS)
    124 #include <mbedtls/ripemd160.h>
    125 #endif
    126 #if defined(ARCHIVE_CRYPTO_SHA1_MBEDTLS)
    127 #include <mbedtls/sha1.h>
    128 #endif
    129 #if defined(ARCHIVE_CRYPTO_SHA256_MBEDTLS)
    130 #include <mbedtls/sha256.h>
    131 #endif
    132 #if defined(ARCHIVE_CRYPTO_SHA384_MBEDTLS) ||\
    133   defined(ARCHIVE_CRYPTO_SHA512_MBEDTLS)
    134 #include <mbedtls/sha512.h>
    135 #endif
    136 
    137 /* Nettle crypto headers */
    138 #if defined(ARCHIVE_CRYPTO_MD5_NETTLE)
    139 #include <nettle/md5.h>
    140 #endif
    141 #if defined(ARCHIVE_CRYPTO_RMD160_NETTLE)
    142 #include <nettle/ripemd160.h>
    143 #endif
    144 #if defined(ARCHIVE_CRYPTO_SHA1_NETTLE) ||\
    145   defined(ARCHIVE_CRYPTO_SHA256_NETTLE) ||\
    146   defined(ARCHIVE_CRYPTO_SHA384_NETTLE) ||\
    147   defined(ARCHIVE_CRYPTO_SHA512_NETTLE)
    148 #include <nettle/sha.h>
    149 #endif
    150 
    151 /* OpenSSL crypto headers */
    152 #if defined(ARCHIVE_CRYPTO_MD5_OPENSSL) ||\
    153   defined(ARCHIVE_CRYPTO_RMD160_OPENSSL) ||\
    154   defined(ARCHIVE_CRYPTO_SHA1_OPENSSL) ||\
    155   defined(ARCHIVE_CRYPTO_SHA256_OPENSSL) ||\
    156   defined(ARCHIVE_CRYPTO_SHA384_OPENSSL) ||\
    157   defined(ARCHIVE_CRYPTO_SHA512_OPENSSL)
    158 #define	ARCHIVE_CRYPTO_OPENSSL 1
    159 #include "archive_openssl_evp_private.h"
    160 #endif
    161 
    162 /* Windows crypto headers */
    163 #if defined(ARCHIVE_CRYPTO_MD5_WIN)    ||\
    164   defined(ARCHIVE_CRYPTO_SHA1_WIN)   ||\
    165   defined(ARCHIVE_CRYPTO_SHA256_WIN) ||\
    166   defined(ARCHIVE_CRYPTO_SHA384_WIN) ||\
    167   defined(ARCHIVE_CRYPTO_SHA512_WIN)
    168 #if defined(HAVE_BCRYPT_H) && _WIN32_WINNT >= _WIN32_WINNT_VISTA
    169 /* don't use bcrypt when XP needs to be supported */
    170 #include <bcrypt.h>
    171 #define	ARCHIVE_CRYPTO_CNG 1
    172 typedef struct {
    173   int   valid;
    174   BCRYPT_ALG_HANDLE  hAlg;
    175   BCRYPT_HASH_HANDLE hHash;
    176 } Digest_CTX;
    177 #else
    178 #include <windows.h>
    179 #include <wincrypt.h>
    180 #define	ARCHIVE_CRYPTO_WINCRYPT 1
    181 typedef struct {
    182   int   valid;
    183   HCRYPTPROV  cryptProv;
    184   HCRYPTHASH  hash;
    185 } Digest_CTX;
    186 #endif
    187 #endif
    188 
    189 /* typedefs */
    190 #if defined(ARCHIVE_CRYPTO_MD5_LIBC)
    191 typedef MD5_CTX archive_md5_ctx;
    192 #elif defined(ARCHIVE_CRYPTO_MD5_LIBMD)
    193 typedef MD5_CTX archive_md5_ctx;
    194 #elif defined(ARCHIVE_CRYPTO_MD5_LIBSYSTEM)
    195 typedef CC_MD5_CTX archive_md5_ctx;
    196 #elif defined(ARCHIVE_CRYPTO_MD5_WIN)
    197 typedef Digest_CTX archive_md5_ctx;
    198 #elif defined(ARCHIVE_CRYPTO_MD5_MBEDTLS)
    199 #define	ARCHIVE_CRYPTO_MBED 1
    200 typedef mbedtls_md5_context archive_md5_ctx;
    201 #elif defined(ARCHIVE_CRYPTO_MD5_NETTLE)
    202 #define	ARCHIVE_CRYPTO_NETTLE 1
    203 typedef struct md5_ctx archive_md5_ctx;
    204 #elif defined(ARCHIVE_CRYPTO_MD5_OPENSSL)
    205 typedef EVP_MD_CTX *archive_md5_ctx;
    206 #else
    207 typedef unsigned char archive_md5_ctx;
    208 #endif
    209 
    210 #if defined(ARCHIVE_CRYPTO_RMD160_LIBC)
    211 typedef RMD160_CTX archive_rmd160_ctx;
    212 #elif defined(ARCHIVE_CRYPTO_RMD160_LIBMD)
    213 typedef RIPEMD160_CTX archive_rmd160_ctx;
    214 #elif defined(ARCHIVE_CRYPTO_RMD160_MBEDTLS)
    215 #define	ARCHIVE_CRYPTO_MBED 1
    216 typedef mbedtls_ripemd160_context archive_rmd160_ctx;
    217 #elif defined(ARCHIVE_CRYPTO_RMD160_NETTLE)
    218 #define	ARCHIVE_CRYPTO_NETTLE 1
    219 typedef struct ripemd160_ctx archive_rmd160_ctx;
    220 #elif defined(ARCHIVE_CRYPTO_RMD160_OPENSSL)
    221 typedef EVP_MD_CTX *archive_rmd160_ctx;
    222 #else
    223 typedef unsigned char archive_rmd160_ctx;
    224 #endif
    225 
    226 #if defined(ARCHIVE_CRYPTO_SHA1_LIBC)
    227 typedef SHA1_CTX archive_sha1_ctx;
    228 #elif defined(ARCHIVE_CRYPTO_SHA1_LIBMD)
    229 typedef SHA1_CTX archive_sha1_ctx;
    230 #elif defined(ARCHIVE_CRYPTO_SHA1_LIBSYSTEM)
    231 typedef CC_SHA1_CTX archive_sha1_ctx;
    232 #elif defined(ARCHIVE_CRYPTO_SHA1_WIN)
    233 typedef Digest_CTX archive_sha1_ctx;
    234 #elif defined(ARCHIVE_CRYPTO_SHA1_MBEDTLS)
    235 #define	ARCHIVE_CRYPTO_MBED 1
    236 typedef mbedtls_sha1_context archive_sha1_ctx;
    237 #elif defined(ARCHIVE_CRYPTO_SHA1_NETTLE)
    238 #define	ARCHIVE_CRYPTO_NETTLE 1
    239 typedef struct sha1_ctx archive_sha1_ctx;
    240 #elif defined(ARCHIVE_CRYPTO_SHA1_OPENSSL)
    241 typedef EVP_MD_CTX *archive_sha1_ctx;
    242 #else
    243 typedef unsigned char archive_sha1_ctx;
    244 #endif
    245 
    246 #if defined(ARCHIVE_CRYPTO_SHA256_LIBC)
    247 typedef SHA256_CTX archive_sha256_ctx;
    248 #elif defined(ARCHIVE_CRYPTO_SHA256_LIBC2)
    249 typedef SHA256_CTX archive_sha256_ctx;
    250 #elif defined(ARCHIVE_CRYPTO_SHA256_LIBC3)
    251 typedef SHA2_CTX archive_sha256_ctx;
    252 #elif defined(ARCHIVE_CRYPTO_SHA256_LIBMD)
    253 typedef SHA256_CTX archive_sha256_ctx;
    254 #elif defined(ARCHIVE_CRYPTO_SHA256_LIBSYSTEM)
    255 typedef CC_SHA256_CTX archive_sha256_ctx;
    256 #elif defined(ARCHIVE_CRYPTO_SHA256_WIN)
    257 typedef Digest_CTX archive_sha256_ctx;
    258 #elif defined(ARCHIVE_CRYPTO_SHA256_MBEDTLS)
    259 #define	ARCHIVE_CRYPTO_MBED 1
    260 typedef mbedtls_sha256_context archive_sha256_ctx;
    261 #elif defined(ARCHIVE_CRYPTO_SHA256_NETTLE)
    262 #define	ARCHIVE_CRYPTO_NETTLE 1
    263 typedef struct sha256_ctx archive_sha256_ctx;
    264 #elif defined(ARCHIVE_CRYPTO_SHA256_OPENSSL)
    265 typedef EVP_MD_CTX *archive_sha256_ctx;
    266 #else
    267 typedef unsigned char archive_sha256_ctx;
    268 #endif
    269 
    270 #if defined(ARCHIVE_CRYPTO_SHA384_LIBC)
    271 typedef SHA384_CTX archive_sha384_ctx;
    272 #elif defined(ARCHIVE_CRYPTO_SHA384_LIBC2)
    273 typedef SHA384_CTX archive_sha384_ctx;
    274 #elif defined(ARCHIVE_CRYPTO_SHA384_LIBC3)
    275 typedef SHA2_CTX archive_sha384_ctx;
    276 #elif defined(ARCHIVE_CRYPTO_SHA384_LIBSYSTEM)
    277 typedef CC_SHA512_CTX archive_sha384_ctx;
    278 #elif defined(ARCHIVE_CRYPTO_SHA384_WIN)
    279 typedef Digest_CTX archive_sha384_ctx;
    280 #elif defined(ARCHIVE_CRYPTO_SHA384_MBEDTLS)
    281 #define	ARCHIVE_CRYPTO_MBED 1
    282 typedef mbedtls_sha512_context archive_sha384_ctx;
    283 #elif defined(ARCHIVE_CRYPTO_SHA384_NETTLE)
    284 #define	ARCHIVE_CRYPTO_NETTLE 1
    285 typedef struct sha384_ctx archive_sha384_ctx;
    286 #elif defined(ARCHIVE_CRYPTO_SHA384_OPENSSL)
    287 typedef EVP_MD_CTX *archive_sha384_ctx;
    288 #else
    289 typedef unsigned char archive_sha384_ctx;
    290 #endif
    291 
    292 #if defined(ARCHIVE_CRYPTO_SHA512_LIBC)
    293 typedef SHA512_CTX archive_sha512_ctx;
    294 #elif defined(ARCHIVE_CRYPTO_SHA512_LIBC2)
    295 typedef SHA512_CTX archive_sha512_ctx;
    296 #elif defined(ARCHIVE_CRYPTO_SHA512_LIBC3)
    297 typedef SHA2_CTX archive_sha512_ctx;
    298 #elif defined(ARCHIVE_CRYPTO_SHA512_LIBMD)
    299 typedef SHA512_CTX archive_sha512_ctx;
    300 #elif defined(ARCHIVE_CRYPTO_SHA512_LIBSYSTEM)
    301 typedef CC_SHA512_CTX archive_sha512_ctx;
    302 #elif defined(ARCHIVE_CRYPTO_SHA512_WIN)
    303 typedef Digest_CTX archive_sha512_ctx;
    304 #elif defined(ARCHIVE_CRYPTO_SHA512_MBEDTLS)
    305 #define	ARCHIVE_CRYPTO_MBED 1
    306 typedef mbedtls_sha512_context archive_sha512_ctx;
    307 #elif defined(ARCHIVE_CRYPTO_SHA512_NETTLE)
    308 #define	ARCHIVE_CRYPTO_NETTLE 1
    309 typedef struct sha512_ctx archive_sha512_ctx;
    310 #elif defined(ARCHIVE_CRYPTO_SHA512_OPENSSL)
    311 typedef EVP_MD_CTX *archive_sha512_ctx;
    312 #else
    313 typedef unsigned char archive_sha512_ctx;
    314 #endif
    315 
    316 /* defines */
    317 #if defined(ARCHIVE_CRYPTO_MD5_LIBC) ||\
    318   defined(ARCHIVE_CRYPTO_MD5_LIBMD) ||	\
    319   defined(ARCHIVE_CRYPTO_MD5_LIBSYSTEM) ||\
    320   defined(ARCHIVE_CRYPTO_MD5_MBEDTLS) ||\
    321   defined(ARCHIVE_CRYPTO_MD5_NETTLE) ||\
    322   defined(ARCHIVE_CRYPTO_MD5_OPENSSL) ||\
    323   defined(ARCHIVE_CRYPTO_MD5_WIN)
    324 #define ARCHIVE_HAS_MD5
    325 #endif
    326 #define archive_md5_init(ctx)\
    327   __archive_digest.md5init(ctx)
    328 #define archive_md5_final(ctx, md)\
    329   __archive_digest.md5final(ctx, md)
    330 #define archive_md5_update(ctx, buf, n)\
    331   __archive_digest.md5update(ctx, buf, n)
    332 
    333 #if defined(ARCHIVE_CRYPTO_RMD160_LIBC) ||\
    334   defined(ARCHIVE_CRYPTO_RMD160_MBEDTLS) ||\
    335   defined(ARCHIVE_CRYPTO_RMD160_NETTLE) ||\
    336   defined(ARCHIVE_CRYPTO_RMD160_OPENSSL)
    337 #define ARCHIVE_HAS_RMD160
    338 #endif
    339 #define archive_rmd160_init(ctx)\
    340   __archive_digest.rmd160init(ctx)
    341 #define archive_rmd160_final(ctx, md)\
    342   __archive_digest.rmd160final(ctx, md)
    343 #define archive_rmd160_update(ctx, buf, n)\
    344   __archive_digest.rmd160update(ctx, buf, n)
    345 
    346 #if defined(ARCHIVE_CRYPTO_SHA1_LIBC) ||\
    347   defined(ARCHIVE_CRYPTO_SHA1_LIBMD) ||	\
    348   defined(ARCHIVE_CRYPTO_SHA1_LIBSYSTEM) ||\
    349   defined(ARCHIVE_CRYPTO_SHA1_MBEDTLS) ||\
    350   defined(ARCHIVE_CRYPTO_SHA1_NETTLE) ||\
    351   defined(ARCHIVE_CRYPTO_SHA1_OPENSSL) ||\
    352   defined(ARCHIVE_CRYPTO_SHA1_WIN)
    353 #define ARCHIVE_HAS_SHA1
    354 #endif
    355 #define archive_sha1_init(ctx)\
    356   __archive_digest.sha1init(ctx)
    357 #define archive_sha1_final(ctx, md)\
    358   __archive_digest.sha1final(ctx, md)
    359 #define archive_sha1_update(ctx, buf, n)\
    360   __archive_digest.sha1update(ctx, buf, n)
    361 
    362 #if defined(ARCHIVE_CRYPTO_SHA256_LIBC) ||\
    363   defined(ARCHIVE_CRYPTO_SHA256_LIBC2) ||\
    364   defined(ARCHIVE_CRYPTO_SHA256_LIBC3) ||\
    365   defined(ARCHIVE_CRYPTO_SHA256_LIBMD) ||\
    366   defined(ARCHIVE_CRYPTO_SHA256_LIBSYSTEM) ||\
    367   defined(ARCHIVE_CRYPTO_SHA256_MBEDTLS) ||\
    368   defined(ARCHIVE_CRYPTO_SHA256_NETTLE) ||\
    369   defined(ARCHIVE_CRYPTO_SHA256_OPENSSL) ||\
    370   defined(ARCHIVE_CRYPTO_SHA256_WIN)
    371 #define ARCHIVE_HAS_SHA256
    372 #endif
    373 #define archive_sha256_init(ctx)\
    374   __archive_digest.sha256init(ctx)
    375 #define archive_sha256_final(ctx, md)\
    376   __archive_digest.sha256final(ctx, md)
    377 #define archive_sha256_update(ctx, buf, n)\
    378   __archive_digest.sha256update(ctx, buf, n)
    379 
    380 #if defined(ARCHIVE_CRYPTO_SHA384_LIBC) ||\
    381   defined(ARCHIVE_CRYPTO_SHA384_LIBC2) ||\
    382   defined(ARCHIVE_CRYPTO_SHA384_LIBC3) ||\
    383   defined(ARCHIVE_CRYPTO_SHA384_LIBSYSTEM) ||\
    384   defined(ARCHIVE_CRYPTO_SHA384_MBEDTLS) ||\
    385   defined(ARCHIVE_CRYPTO_SHA384_NETTLE) ||\
    386   defined(ARCHIVE_CRYPTO_SHA384_OPENSSL) ||\
    387   defined(ARCHIVE_CRYPTO_SHA384_WIN)
    388 #define ARCHIVE_HAS_SHA384
    389 #endif
    390 #define archive_sha384_init(ctx)\
    391   __archive_digest.sha384init(ctx)
    392 #define archive_sha384_final(ctx, md)\
    393   __archive_digest.sha384final(ctx, md)
    394 #define archive_sha384_update(ctx, buf, n)\
    395   __archive_digest.sha384update(ctx, buf, n)
    396 
    397 #if defined(ARCHIVE_CRYPTO_SHA512_LIBC) ||\
    398   defined(ARCHIVE_CRYPTO_SHA512_LIBC2) ||\
    399   defined(ARCHIVE_CRYPTO_SHA512_LIBC3) ||\
    400   defined(ARCHIVE_CRYPTO_SHA512_LIBMD) ||\
    401   defined(ARCHIVE_CRYPTO_SHA512_LIBSYSTEM) ||\
    402   defined(ARCHIVE_CRYPTO_SHA512_MBEDTLS) ||\
    403   defined(ARCHIVE_CRYPTO_SHA512_NETTLE) ||\
    404   defined(ARCHIVE_CRYPTO_SHA512_OPENSSL) ||\
    405   defined(ARCHIVE_CRYPTO_SHA512_WIN)
    406 #define ARCHIVE_HAS_SHA512
    407 #endif
    408 #define archive_sha512_init(ctx)\
    409   __archive_digest.sha512init(ctx)
    410 #define archive_sha512_final(ctx, md)\
    411   __archive_digest.sha512final(ctx, md)
    412 #define archive_sha512_update(ctx, buf, n)\
    413   __archive_digest.sha512update(ctx, buf, n)
    414 
    415 /* Minimal interface to digest functionality for internal use in libarchive */
    416 struct archive_digest
    417 {
    418   /* Message Digest */
    419   int (*md5init)(archive_md5_ctx *ctx);
    420   int (*md5update)(archive_md5_ctx *, const void *, size_t);
    421   int (*md5final)(archive_md5_ctx *, void *);
    422   int (*rmd160init)(archive_rmd160_ctx *);
    423   int (*rmd160update)(archive_rmd160_ctx *, const void *, size_t);
    424   int (*rmd160final)(archive_rmd160_ctx *, void *);
    425   int (*sha1init)(archive_sha1_ctx *);
    426   int (*sha1update)(archive_sha1_ctx *, const void *, size_t);
    427   int (*sha1final)(archive_sha1_ctx *, void *);
    428   int (*sha256init)(archive_sha256_ctx *);
    429   int (*sha256update)(archive_sha256_ctx *, const void *, size_t);
    430   int (*sha256final)(archive_sha256_ctx *, void *);
    431   int (*sha384init)(archive_sha384_ctx *);
    432   int (*sha384update)(archive_sha384_ctx *, const void *, size_t);
    433   int (*sha384final)(archive_sha384_ctx *, void *);
    434   int (*sha512init)(archive_sha512_ctx *);
    435   int (*sha512update)(archive_sha512_ctx *, const void *, size_t);
    436   int (*sha512final)(archive_sha512_ctx *, void *);
    437 };
    438 
    439 extern const struct archive_digest __archive_digest;
    440 
    441 #endif
    442