Loading...
Searching...
No Matches
apr_crypto.h
Go to the documentation of this file.
/* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef APR_CRYPTO_H
#define APR_CRYPTO_H
#include "apu.h"
#include "apr_pools.h"
#include "apr_tables.h"
#include "apr_hash.h"
#include "apu_errno.h"
#ifdef __cplusplus
extern "C" {
#endif
#if APU_HAVE_CRYPTO
#ifndef APU_CRYPTO_RECOMMENDED_DRIVER
#if APU_HAVE_COMMONCRYPTO
#define APU_CRYPTO_RECOMMENDED_DRIVER "commoncrypto"
#else
#if APU_HAVE_OPENSSL
#define APU_CRYPTO_RECOMMENDED_DRIVER "openssl"
#else
#if APU_HAVE_NSS
#define APU_CRYPTO_RECOMMENDED_DRIVER "nss"
#else
#if APU_HAVE_MSCNG
#define APU_CRYPTO_RECOMMENDED_DRIVER "mscng"
#else
#if APU_HAVE_MSCAPI
#define APU_CRYPTO_RECOMMENDED_DRIVER "mscapi"
#else
#endif
#endif
#endif
#endif
#endif
#endif
typedef enum
{
APR_KEY_NONE, APR_KEY_3DES_192,
APR_KEY_AES_128,
APR_KEY_AES_192,
APR_KEY_AES_256
} apr_crypto_block_key_type_e;
typedef enum
{
APR_MODE_NONE,
APR_MODE_ECB,
APR_MODE_CBC
} apr_crypto_block_key_mode_e;
/* These are opaque structs. Instantiation is up to each backend */
typedef struct apr_crypto_driver_t apr_crypto_driver_t;
typedef struct apr_crypto_t apr_crypto_t;
typedef struct apr_crypto_config_t apr_crypto_config_t;
typedef struct apr_crypto_key_t apr_crypto_key_t;
typedef struct apr_crypto_block_t apr_crypto_block_t;
typedef struct apr_crypto_block_key_type_t {
apr_crypto_block_key_type_e type;
int keysize;
int blocksize;
int ivsize;
} apr_crypto_block_key_type_t;
typedef struct apr_crypto_block_key_mode_t {
apr_crypto_block_key_mode_e mode;
} apr_crypto_block_key_mode_t;
typedef struct apr_crypto_passphrase_t {
const char *pass;
apr_size_t passLen;
const unsigned char * salt;
apr_size_t saltLen;
int iterations;
} apr_crypto_passphrase_t;
typedef struct apr_crypto_secret_t {
const unsigned char *secret;
apr_size_t secretLen;
} apr_crypto_secret_t;
typedef enum {
APR_CRYPTO_KTYPE_PASSPHRASE = 1,
APR_CRYPTO_KTYPE_SECRET = 2,
} apr_crypto_key_type;
typedef struct apr_crypto_key_rec_t {
apr_crypto_key_type ktype;
apr_crypto_block_key_type_e type;
apr_crypto_block_key_mode_e mode;
int pad;
union {
apr_crypto_passphrase_t passphrase;
apr_crypto_secret_t secret;
} k;
} apr_crypto_key_rec_t;
APU_DECLARE(apr_status_t) apr_crypto_init(apr_pool_t *pool);
APU_DECLARE(apr_status_t) apr_crypto_clear(apr_pool_t *pool, void *buffer,
apr_size_t size);
APU_DECLARE(apr_status_t) apr_crypto_memzero(void *buffer, apr_size_t size);
APU_DECLARE(int) apr_crypto_equals(const void *buf1, const void *buf2,
apr_size_t size);
APU_DECLARE(apr_status_t) apr_crypto_get_driver(
const apr_crypto_driver_t **driver,
const char *name, const char *params, const apu_err_t **result,
apr_pool_t *pool);
APU_DECLARE(const char *) apr_crypto_driver_name(
const apr_crypto_driver_t *driver);
APU_DECLARE(apr_status_t) apr_crypto_error(const apu_err_t **result,
const apr_crypto_t *f);
APU_DECLARE(apr_status_t) apr_crypto_make(apr_crypto_t **f,
const apr_crypto_driver_t *driver, const char *params,
apr_pool_t *pool);
APU_DECLARE(apr_status_t) apr_crypto_get_block_key_types(apr_hash_t **types,
const apr_crypto_t *f);
APU_DECLARE(apr_status_t) apr_crypto_get_block_key_modes(apr_hash_t **modes,
const apr_crypto_t *f);
APU_DECLARE(apr_status_t) apr_crypto_key(apr_crypto_key_t **key,
const apr_crypto_key_rec_t *rec, const apr_crypto_t *f, apr_pool_t *p);
APU_DECLARE(apr_status_t) apr_crypto_passphrase(apr_crypto_key_t **key,
apr_size_t *ivSize, const char *pass, apr_size_t passLen,
const unsigned char * salt, apr_size_t saltLen,
const apr_crypto_block_key_type_e type,
const apr_crypto_block_key_mode_e mode, const int doPad,
const int iterations, const apr_crypto_t *f, apr_pool_t *p);
APU_DECLARE(apr_status_t) apr_crypto_block_encrypt_init(
apr_crypto_block_t **ctx, const unsigned char **iv,
const apr_crypto_key_t *key, apr_size_t *blockSize, apr_pool_t *p);
APU_DECLARE(apr_status_t) apr_crypto_block_encrypt(unsigned char **out,
apr_size_t *outlen, const unsigned char *in, apr_size_t inlen,
apr_crypto_block_t *ctx);
APU_DECLARE(apr_status_t) apr_crypto_block_encrypt_finish(unsigned char *out,
apr_size_t *outlen, apr_crypto_block_t *ctx);
APU_DECLARE(apr_status_t) apr_crypto_block_decrypt_init(
apr_crypto_block_t **ctx, apr_size_t *blockSize,
const unsigned char *iv, const apr_crypto_key_t *key, apr_pool_t *p);
APU_DECLARE(apr_status_t) apr_crypto_block_decrypt(unsigned char **out,
apr_size_t *outlen, const unsigned char *in, apr_size_t inlen,
apr_crypto_block_t *ctx);
APU_DECLARE(apr_status_t) apr_crypto_block_decrypt_finish(unsigned char *out,
apr_size_t *outlen, apr_crypto_block_t *ctx);
APU_DECLARE(apr_status_t) apr_crypto_block_cleanup(apr_crypto_block_t *ctx);
APU_DECLARE(apr_status_t) apr_crypto_cleanup(apr_crypto_t *f);
APU_DECLARE(apr_status_t) apr_crypto_shutdown(
const apr_crypto_driver_t *driver);
#endif /* APU_HAVE_CRYPTO */
#ifdef __cplusplus
}
#endif
#endif
apu_errno.h
APR-Util Error Codes.
apu_err_t
Definition apu_errno.h:161