1 /* vim: set tabstop=8 shiftwidth=4 softtabstop=4 expandtab smarttab colorcolumn=80: */ 2 /* 3 * Copyright 2016 Red Hat, Inc. 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 #pragma once 19 20 /* Don't warn about deprecated functions. */ 21 #ifndef OPENSSL_API_COMPAT 22 /* 0x10101000L == 1.1.1. */ 23 #define OPENSSL_API_COMPAT 0x10101000L 24 #endif 25 26 #include <openssl/bn.h> 27 #include <openssl/hmac.h> 28 #include <openssl/ec.h> 29 #include <openssl/ecdsa.h> 30 #include <openssl/evp.h> 31 #include <openssl/rsa.h> 32 33 #if OPENSSL_VERSION_NUMBER < 0x10100000L 34 const unsigned char * 35 EVP_PKEY_get0_hmac(EVP_PKEY *pkey, size_t *len); 36 37 void 38 RSA_get0_key(const RSA *r, const BIGNUM **n, const BIGNUM **e, const BIGNUM **d); 39 40 void 41 RSA_get0_factors(const RSA *r, const BIGNUM **p, const BIGNUM **q); 42 43 void 44 RSA_get0_crt_params(const RSA *r, const BIGNUM **dmp1, const BIGNUM **dmq1, 45 const BIGNUM **iqmp); 46 47 RSA * 48 EVP_PKEY_get0_RSA(EVP_PKEY *pkey); 49 50 EC_KEY * 51 EVP_PKEY_get0_EC_KEY(EVP_PKEY *pkey); 52 53 int 54 RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d); 55 56 int 57 RSA_set0_factors(RSA *r, BIGNUM *p, BIGNUM *q); 58 59 int 60 RSA_set0_crt_params(RSA *r, BIGNUM *dmp1, BIGNUM *dmq1, BIGNUM *iqmp); 61 62 EVP_MD_CTX * 63 EVP_MD_CTX_new(void); 64 65 void 66 EVP_MD_CTX_free(EVP_MD_CTX *ctx); 67 68 void 69 ECDSA_SIG_get0(const ECDSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps); 70 71 int 72 ECDSA_SIG_set0(ECDSA_SIG *sig, BIGNUM *r, BIGNUM *s); 73 74 HMAC_CTX * 75 HMAC_CTX_new(void); 76 77 const EVP_MD * 78 HMAC_CTX_get_md(const HMAC_CTX *ctx); 79 80 void 81 HMAC_CTX_free(HMAC_CTX *ctx); 82 #endif 83