1310184Smm/*-
2310184Smm * Copyright (c) 2003-2007 Tim Kientzle
3310184Smm * All rights reserved.
4310184Smm *
5310184Smm * Redistribution and use in source and binary forms, with or without
6310184Smm * modification, are permitted provided that the following conditions
7310184Smm * are met:
8310184Smm * 1. Redistributions of source code must retain the above copyright
9310184Smm *    notice, this list of conditions and the following disclaimer.
10310184Smm * 2. Redistributions in binary form must reproduce the above copyright
11310184Smm *    notice, this list of conditions and the following disclaimer in the
12310184Smm *    documentation and/or other materials provided with the distribution.
13310184Smm *
14310184Smm * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
15310184Smm * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16310184Smm * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17310184Smm * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
18310184Smm * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19310184Smm * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20310184Smm * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21310184Smm * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22310184Smm * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23310184Smm * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24310184Smm */
25358088Smm
26310184Smm#ifndef ARCHIVE_OPENSSL_EVP_PRIVATE_H_INCLUDED
27310184Smm#define ARCHIVE_OPENSSL_EVP_PRIVATE_H_INCLUDED
28310184Smm
29358088Smm#ifndef __LIBARCHIVE_BUILD
30358088Smm#error This header is only to be used internally to libarchive.
31358088Smm#endif
32358088Smm
33310184Smm#include <openssl/evp.h>
34310184Smm#include <openssl/opensslv.h>
35310184Smm
36310184Smm#if OPENSSL_VERSION_NUMBER < 0x10100000L
37310184Smm#include <stdlib.h> /* malloc, free */
38310184Smm#include <string.h> /* memset */
39310184Smmstatic inline EVP_MD_CTX *EVP_MD_CTX_new(void)
40310184Smm{
41310184Smm	EVP_MD_CTX *ctx = (EVP_MD_CTX *)calloc(1, sizeof(EVP_MD_CTX));
42310184Smm	return ctx;
43310184Smm}
44310184Smm
45310184Smmstatic inline void EVP_MD_CTX_free(EVP_MD_CTX *ctx)
46310184Smm{
47310184Smm	EVP_MD_CTX_cleanup(ctx);
48310184Smm	memset(ctx, 0, sizeof(*ctx));
49310184Smm	free(ctx);
50310184Smm}
51310184Smm#endif
52310184Smm
53310184Smm#endif
54