| 1 |
/* |
| 2 |
* Copyright (c) 2016 SURFnet bv |
| 3 |
* All rights reserved. |
| 4 |
* |
| 5 |
* Redistribution and use in source and binary forms, with or without |
| 6 |
* modification, are permitted provided that the following conditions |
| 7 |
* are met: |
| 8 |
* 1. Redistributions of source code must retain the above copyright |
| 9 |
* notice, this list of conditions and the following disclaimer. |
| 10 |
* 2. Redistributions in binary form must reproduce the above copyright |
| 11 |
* notice, this list of conditions and the following disclaimer in the |
| 12 |
* documentation and/or other materials provided with the distribution. |
| 13 |
* |
| 14 |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
| 15 |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 16 |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 17 |
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY |
| 18 |
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 19 |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE |
| 20 |
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 21 |
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER |
| 22 |
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
| 23 |
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN |
| 24 |
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 25 |
*/ |
| 26 |
|
| 27 |
/***************************************************************************** |
| 28 |
OSSLComp.h |
| 29 |
|
| 30 |
Adding OpenSSL forward-compatible code as suggested by OpenSSL |
| 31 |
*****************************************************************************/ |
| 32 |
|
| 33 |
#ifndef _SOFTHSM_V2_OSSLCOMP_H |
| 34 |
#define _SOFTHSM_V2_OSSLCOMP_H |
| 35 |
|
| 36 |
#include "config.h" |
| 37 |
#include <openssl/opensslv.h> |
| 38 |
|
| 39 |
#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) |
| 40 |
|
| 41 |
#include <openssl/evp.h> |
| 42 |
#include <openssl/hmac.h> |
| 43 |
#include <openssl/dh.h> |
| 44 |
#include <openssl/dsa.h> |
| 45 |
#ifdef WITH_ECC |
| 46 |
#include <openssl/ecdsa.h> |
| 47 |
#endif |
| 48 |
#include <openssl/rsa.h> |
| 49 |
|
| 50 |
// EVP digest routines |
| 51 |
EVP_MD_CTX *EVP_MD_CTX_new(void); |
| 52 |
void EVP_MD_CTX_free(EVP_MD_CTX *ctx); |
| 53 |
|
| 54 |
// HMAC routines |
| 55 |
HMAC_CTX *HMAC_CTX_new(void); |
| 56 |
void HMAC_CTX_free(HMAC_CTX *ctx); |
| 57 |
|
| 58 |
// DH routines |
| 59 |
void DH_get0_pqg(const DH *dh, |
| 60 |
const BIGNUM **p, const BIGNUM **q, const BIGNUM **g); |
| 61 |
int DH_set0_pqg(DH *dh, BIGNUM *p, BIGNUM *q, BIGNUM *g); |
| 62 |
void DH_get0_key(const DH *dh, const BIGNUM **pub_key, const BIGNUM **priv_key); |
| 63 |
int DH_set0_key(DH *dh, BIGNUM *pub_key, BIGNUM *priv_key); |
| 64 |
long DH_get_length(const DH *dh); |
| 65 |
int DH_set_length(DH *dh, long length); |
| 66 |
|
| 67 |
// DSA routines |
| 68 |
void DSA_get0_pqg(const DSA *d, |
| 69 |
const BIGNUM **p, const BIGNUM **q, const BIGNUM **g); |
| 70 |
int DSA_set0_pqg(DSA *d, BIGNUM *p, BIGNUM *q, BIGNUM *g); |
| 71 |
void DSA_get0_key(const DSA *d, |
| 72 |
const BIGNUM **pub_key, const BIGNUM **priv_key); |
| 73 |
int DSA_set0_key(DSA *d, BIGNUM *pub_key, BIGNUM *priv_key); |
| 74 |
|
| 75 |
// DSA_SIG routines |
| 76 |
void DSA_SIG_get0(const DSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps); |
| 77 |
int DSA_SIG_set0(DSA_SIG *sig, BIGNUM *r, BIGNUM *s); |
| 78 |
|
| 79 |
// ECDSA_SIG routines |
| 80 |
#ifdef WITH_ECC |
| 81 |
void ECDSA_SIG_get0(const ECDSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps); |
| 82 |
int ECDSA_SIG_set0(ECDSA_SIG *sig, BIGNUM *r, BIGNUM *s); |
| 83 |
#endif |
| 84 |
|
| 85 |
// EDDSA |
| 86 |
#ifdef WITH_EDDSA |
| 87 |
#error This OpenSSL version is incompatible with EDDSA |
| 88 |
#endif |
| 89 |
|
| 90 |
// RSA routines |
| 91 |
int RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d); |
| 92 |
int RSA_set0_factors(RSA *r, BIGNUM *p, BIGNUM *q); |
| 93 |
int RSA_set0_crt_params(RSA *r, BIGNUM *dmp1, BIGNUM *dmq1, BIGNUM *iqmp); |
| 94 |
void RSA_get0_key(const RSA *r, |
| 95 |
const BIGNUM **n, const BIGNUM **e, const BIGNUM **d); |
| 96 |
void RSA_get0_factors(const RSA *r, const BIGNUM **p, const BIGNUM **q); |
| 97 |
void RSA_get0_crt_params(const RSA *r, |
| 98 |
const BIGNUM **dmp1, const BIGNUM **dmq1, |
| 99 |
const BIGNUM **iqmp); |
| 100 |
|
| 101 |
#endif |
| 102 |
|
| 103 |
#endif // !_SOFTHSM_V2_OSSLCOMP_H |