Apache2
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
apr_crypto_internal.h
Go to the documentation of this file.
1 /* Licensed to the Apache Software Foundation (ASF) under one or more
2  * contributor license agreements. See the NOTICE file distributed with
3  * this work for additional information regarding copyright ownership.
4  * The ASF licenses this file to You under the Apache License, Version 2.0
5  * (the "License"); you may not use this file except in compliance with
6  * the License. You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef APR_CRYPTO_INTERNAL_H
18 #define APR_CRYPTO_INTERNAL_H
19 
20 #include <stdarg.h>
21 
22 #include "apr_crypto.h"
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 #if APU_HAVE_CRYPTO
29 
30 struct apr_crypto_driver_t {
31 
33  const char *name;
34 
42  apr_status_t (*init)(apr_pool_t *pool, const char *params,
43  const apu_err_t **result);
44 
58  const char *params, apr_pool_t *pool);
59 
68  apr_status_t (*get_block_key_digests)(apr_hash_t **types,
69  const apr_crypto_t *f);
70 
79  apr_status_t (*get_block_key_types)(apr_hash_t **types,
80  const apr_crypto_t *f);
81 
90  apr_status_t (*get_block_key_modes)(apr_hash_t **modes,
91  const apr_crypto_t *f);
92 
121  apr_status_t (*passphrase)(apr_crypto_key_t **key, apr_size_t *ivSize,
122  const char *pass, apr_size_t passLen, const unsigned char * salt,
123  apr_size_t saltLen, const apr_crypto_block_key_type_e type,
124  const apr_crypto_block_key_mode_e mode, const int doPad,
125  const int iterations, const apr_crypto_t *f, apr_pool_t *p);
126 
143  apr_status_t (*block_encrypt_init)(apr_crypto_block_t **ctx,
144  const unsigned char **iv, const apr_crypto_key_t *key,
145  apr_size_t *blockSize, apr_pool_t *p);
146 
165  apr_status_t (*block_encrypt)(unsigned char **out, apr_size_t *outlen,
166  const unsigned char *in, apr_size_t inlen, apr_crypto_block_t *ctx);
167 
186  apr_status_t (*block_encrypt_finish)(unsigned char *out,
187  apr_size_t *outlen, apr_crypto_block_t *ctx);
188 
204  apr_status_t (*block_decrypt_init)(apr_crypto_block_t **ctx,
205  apr_size_t *blockSize, const unsigned char *iv,
206  const apr_crypto_key_t *key, apr_pool_t *p);
207 
226  apr_status_t (*block_decrypt)(unsigned char **out, apr_size_t *outlen,
227  const unsigned char *in, apr_size_t inlen, apr_crypto_block_t *ctx);
228 
247  apr_status_t (*block_decrypt_finish)(unsigned char *out,
248  apr_size_t *outlen, apr_crypto_block_t *ctx);
249 
264  apr_status_t (*digest_init)(apr_crypto_digest_t **d,
266 
276  apr_status_t (*digest_update)(apr_crypto_digest_t *digest,
277  const unsigned char *in, apr_size_t inlen);
278 
290  apr_status_t (*digest_final)(apr_crypto_digest_t *digest);
291 
304  apr_status_t (*digest)(const apr_crypto_key_t *key,
305  apr_crypto_digest_rec_t *rec, const unsigned char *in,
306  apr_size_t inlen, apr_pool_t *p);
307 
314  apr_status_t (*block_cleanup)(apr_crypto_block_t *ctx);
315 
322  apr_status_t (*digest_cleanup)(apr_crypto_digest_t *ctx);
323 
330  apr_status_t (*cleanup)(apr_crypto_t *f);
331 
338 
345  apr_status_t (*error)(const apu_err_t **result, const apr_crypto_t *f);
346 
363  apr_status_t (*key)(apr_crypto_key_t **key, const apr_crypto_key_rec_t *rec,
364  const apr_crypto_t *f, apr_pool_t *p);
365 
366 };
367 
368 #if APU_HAVE_OPENSSL
369 #include <openssl/crypto.h>
370 
371 #ifndef APR_USE_OPENSSL_PRE_1_1_API
372 #if defined(LIBRESSL_VERSION_NUMBER)
373 /* LibreSSL declares OPENSSL_VERSION_NUMBER == 2.0 but does not necessarily
374  * include changes from OpenSSL >= 1.1 (new functions, macros, * deprecations,
375  * ...), so we have to work around this...
376  */
377 #define APR_USE_OPENSSL_PRE_1_0_API (0)
378 #define APR_USE_OPENSSL_PRE_1_1_API (LIBRESSL_VERSION_NUMBER < 0x2070000f)
379 #define APR_USE_OPENSSL_PRE_1_1_1_API (1)
380 #else /* defined(LIBRESSL_VERSION_NUMBER) */
381 #define APR_USE_OPENSSL_PRE_1_0_API (OPENSSL_VERSION_NUMBER < 0x10000000L)
382 #define APR_USE_OPENSSL_PRE_1_1_API (OPENSSL_VERSION_NUMBER < 0x10100000L)
383 #define APR_USE_OPENSSL_PRE_1_1_1_API (OPENSSL_VERSION_NUMBER < 0x10101000L)
384 #endif /* defined(LIBRESSL_VERSION_NUMBER) */
385 #endif /* ndef APR_USE_OPENSSL_PRE_1_1_API */
386 
387 const char *apr__crypto_openssl_version(void);
388 apr_status_t apr__crypto_openssl_init(const char *params,
389  const apu_err_t **result,
390  apr_pool_t *pool);
391 apr_status_t apr__crypto_openssl_term(void);
392 #endif
393 
394 #if APU_HAVE_NSS
395 const char *apr__crypto_nss_version(void);
396 apr_status_t apr__crypto_nss_init(const char *params,
397  const apu_err_t **result,
398  apr_pool_t *pool);
399 apr_status_t apr__crypto_nss_term(void);
400 #endif
401 
402 #if APU_HAVE_COMMONCRYPTO
403 const char *apr__crypto_commoncrypto_version(void);
404 apr_status_t apr__crypto_commoncrypto_init(const char *params,
405  const apu_err_t **result,
406  apr_pool_t *pool);
407 apr_status_t apr__crypto_commoncrypto_term(void);
408 #endif
409 
410 #if APU_HAVE_MSCAPI
411 const char *apr__crypto_mscapi_version(void);
412 apr_status_t apr__crypto_mscapi_init(const char *params,
413  const apu_err_t **result,
414  apr_pool_t *pool);
415 apr_status_t apr__crypto_mscapi_term(void);
416 #endif
417 
418 #if APU_HAVE_MSCNG
419 const char *apr__crypto_mscng_version(void);
420 apr_status_t apr__crypto_mscng_init(const char *params,
421  const apu_err_t **result,
422  apr_pool_t *pool);
423 apr_status_t apr__crypto_mscng_term(void);
424 #endif
425 
426 #endif
427 
428 #ifdef __cplusplus
429 }
430 #endif
431 
432 #endif
size_t apr_size_t
Definition: apr.h:375
Definition: apr_crypto.h:432
struct apr_crypto_key_t apr_crypto_key_t
Definition: apr_crypto.h:187
apr_bucket_brigade request_rec apr_pool_t * pool
Definition: mod_dav.h:552
struct apr_crypto_t apr_crypto_t
Definition: apr_crypto.h:173
struct apr_crypto_digest_t apr_crypto_digest_t
Definition: apr_crypto.h:203
apr_crypto_block_key_mode_e
Definition: apr_crypto.h:127
Definition: apr_crypto.h:487
APR-UTIL Crypto library.
struct apr_crypto_driver_t apr_crypto_driver_t
Definition: apr_crypto.h:166
#define shutdown
Definition: apr_arch_os2calls.h:55
apr_crypto_block_key_type_e
Definition: apr_crypto.h:115
struct apr_crypto_block_t apr_crypto_block_t
Definition: apr_crypto.h:196
struct apr_hash_t apr_hash_t
Definition: apr_hash.h:52
apr_pool_t * p
const char const dav_options_provider * provider
Definition: mod_dav.h:2588
const char * name
Definition: mod_dav.h:726
Definition: apu_errno.h:169
struct apr_pool_t apr_pool_t
Definition: apr_pools.h:60
typedef void(APR_THREAD_FUNC *PFN_HSE_IO_COMPLETION)(EXTENSION_CONTROL_BLOCK *ecb
int apr_status_t
Definition: apr_errno.h:44