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 */
25358090Smm
26310184Smm#ifndef ARCHIVE_OPENSSL_HMAC_PRIVATE_H_INCLUDED
27310184Smm#define ARCHIVE_OPENSSL_HMAC_PRIVATE_H_INCLUDED
28310184Smm
29358090Smm#ifndef __LIBARCHIVE_BUILD
30358090Smm#error This header is only to be used internally to libarchive.
31358090Smm#endif
32358090Smm
33310184Smm#include <openssl/hmac.h>
34310184Smm#include <openssl/opensslv.h>
35310184Smm
36337352Smm#if OPENSSL_VERSION_NUMBER < 0x10100000L || \
37337352Smm	(defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x20700000L)
38310184Smm#include <stdlib.h> /* malloc, free */
39310184Smm#include <string.h> /* memset */
40310184Smmstatic inline HMAC_CTX *HMAC_CTX_new(void)
41310184Smm{
42310184Smm	HMAC_CTX *ctx = (HMAC_CTX *)calloc(1, sizeof(HMAC_CTX));
43310184Smm	return ctx;
44310184Smm}
45310184Smm
46310184Smmstatic inline void HMAC_CTX_free(HMAC_CTX *ctx)
47310184Smm{
48310184Smm	HMAC_CTX_cleanup(ctx);
49310184Smm	memset(ctx, 0, sizeof(*ctx));
50310184Smm	free(ctx);
51310184Smm}
52310184Smm#endif
53310184Smm
54310184Smm#endif
55