41#if APU_HAVE_CRYPTO || defined(DOXYGEN)
43#ifndef APU_CRYPTO_RECOMMENDED_DRIVER
44#if APU_HAVE_COMMONCRYPTO
46#define APU_CRYPTO_RECOMMENDED_DRIVER "commoncrypto"
50#define APU_CRYPTO_RECOMMENDED_DRIVER "openssl"
54#define APU_CRYPTO_RECOMMENDED_DRIVER "nss"
58#define APU_CRYPTO_RECOMMENDED_DRIVER "mscng"
62#define APU_CRYPTO_RECOMMENDED_DRIVER "mscapi"
117 APR_KEY_NONE, APR_KEY_3DES_192,
140 APR_CRYPTO_DIGEST_NONE,
166 APR_CRYPTO_CIPHER_AUTO,
364 const unsigned char *
v;
518 const char **version);
524APR_DECLARE(
int) apr_crypto_lib_is_active(
const char *name);
577 const char *name,
const char *params,
const apu_err_t **result,
731 apr_size_t *ivSize,
const char *pass, apr_size_t passLen,
732 const unsigned char * salt, apr_size_t saltLen,
778 apr_size_t *outlen,
const unsigned char *in, apr_size_t inlen,
841 apr_size_t *outlen,
const unsigned char *in, apr_size_t inlen,
921 const unsigned char *in, apr_size_t inlen);
988#if APU_HAVE_CRYPTO_PRNG
1010#define APR_CRYPTO_PRNG_SEED_SIZE 32
1012#define APR_CRYPTO_PRNG_LOCKED (0x1)
1013#define APR_CRYPTO_PRNG_PER_THREAD (0x2)
1014#define APR_CRYPTO_PRNG_MASK (0x3)
1017typedef struct apr_crypto_prng_t apr_crypto_prng_t;
1093 int flags,
const unsigned char seed[],
apr_pool_t *pool);
1120 const unsigned char seed[]);
1123#define APR_CRYPTO_FORK_INPARENT 0
1124#define APR_CRYPTO_FORK_INCHILD 1
1149 void *buf, apr_size_t len);
APR Thread and Process Library.
apr_status_t apr_crypto_block_encrypt_finish(unsigned char *out, apr_size_t *outlen, apr_crypto_block_t *ctx)
Encrypt final data block, write it to out.
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)
Get the driver struct for a name.
apr_status_t apr_crypto_block_cleanup(apr_crypto_block_t *ctx)
Clean encryption / decryption context.
apr_status_t apr_crypto_digest_update(apr_crypto_digest_t *digest, const unsigned char *in, apr_size_t inlen)
Update the digest with data provided by in.
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)
Initialise a context for encrypting arbitrary data using the given key.
apr_status_t apr_crypto_make(apr_crypto_t **f, const apr_crypto_driver_t *driver, const char *params, apr_pool_t *pool)
Create a context for supporting encryption. Keys, certificates, algorithms and other parameters will ...
int apr_crypto_equals(const void *buf1, const void *buf2, apr_size_t size)
Timing attacks safe buffers comparison, where the executing time does not depend on the bytes compare...
apr_status_t apr_crypto_cleanup(apr_crypto_t *f)
Clean encryption / decryption context.
apr_status_t apr_crypto_get_block_key_digests(apr_hash_t **digests, const apr_crypto_t *f)
Get a hash table of key digests, keyed by the name of the digest against a pointer to apr_crypto_bloc...
struct apr_crypto_key_t apr_crypto_key_t
Definition apr_crypto.h:197
apr_status_t apr_crypto_get_block_key_modes(apr_hash_t **modes, const apr_crypto_t *f)
Get a hash table of key modes, keyed by the name of the mode against a pointer to apr_crypto_block_ke...
apr_crypto_key_rec_t * apr_crypto_key_rec_make(apr_crypto_key_type ktype, apr_pool_t *p)
Create a key record to be passed to apr_crypto_key().
apr_status_t apr_crypto_shutdown(const apr_crypto_driver_t *driver)
Shutdown the crypto library.
apr_status_t apr_crypto_get_block_key_types(apr_hash_t **types, const apr_crypto_t *f)
Get a hash table of key types, keyed by the name of the type against a pointer to apr_crypto_block_ke...
const char * apr_crypto_driver_name(const apr_crypto_driver_t *driver)
Return the name of the driver.
apr_status_t apr_crypto_memzero(void *buffer, apr_size_t size)
Always zero out the buffer provided, without being optimized out by the compiler.
apr_crypto_digest_rec_t * apr_crypto_digest_rec_make(apr_crypto_digest_type_e dtype, apr_pool_t *p)
Create a digest record to be passed to apr_crypto_digest_init().
struct apr_crypto_t apr_crypto_t
Definition apr_crypto.h:183
apr_status_t apr_crypto_clear(apr_pool_t *pool, void *buffer, apr_size_t size)
Zero out the buffer provided when the pool is cleaned up.
apr_status_t apr_crypto_digest_final(apr_crypto_digest_t *digest)
Finalise the digest and write the result.
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)
Create a key from the provided secret or passphrase. The key is cleaned up when the context is cleane...
struct apr_crypto_driver_t apr_crypto_driver_t
Definition apr_crypto.h:176
apr_status_t apr_crypto_digest(const apr_crypto_key_t *key, apr_crypto_digest_rec_t *rec, const unsigned char *in, apr_size_t inlen, apr_pool_t *p)
One shot digest on a single memory buffer.
apr_status_t apr_crypto_error(const apu_err_t **result, const apr_crypto_t *f)
Get the result of the last operation on a context. If the result is NULL, the operation was successfu...
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)
Encrypt data provided by in, write it to out.
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)
Create a key from the given passphrase. By default, the PBKDF2 algorithm is used to generate the key ...
apr_crypto_key_type
Definition apr_crypto.h:375
apr_status_t apr_crypto_digest_init(apr_crypto_digest_t **d, const apr_crypto_key_t *key, apr_crypto_digest_rec_t *rec, apr_pool_t *p)
Initialise a context for hashing, signing or verifying arbitrary data.
apr_status_t apr_crypto_digest_cleanup(apr_crypto_digest_t *ctx)
Clean digest context.
apr_crypto_block_key_digest_e
Definition apr_crypto.h:139
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)
Initialise a context for decrypting arbitrary data using the given key.
apr_crypto_digest_type_e
Definition apr_crypto.h:412
apr_status_t apr_crypto_block_decrypt_finish(unsigned char *out, apr_size_t *outlen, apr_crypto_block_t *ctx)
Decrypt final data block, write it to out.
apr_crypto_block_key_type_e
Definition apr_crypto.h:116
apr_status_t apr_crypto_init(apr_pool_t *pool)
Perform once-only initialisation. Call once only.
struct apr_crypto_block_t apr_crypto_block_t
Definition apr_crypto.h:206
struct apr_crypto_digest_t apr_crypto_digest_t
Definition apr_crypto.h:213
apr_crypto_block_key_mode_e
Definition apr_crypto.h:128
struct apr_crypto_config_t apr_crypto_config_t
Definition apr_crypto.h:189
apr_crypto_cipher_e
Definition apr_crypto.h:165
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)
Decrypt data provided by in, write it to out.
@ APR_CRYPTO_KTYPE_HASH
Definition apr_crypto.h:393
@ APR_CRYPTO_KTYPE_PASSPHRASE
Definition apr_crypto.h:381
@ APR_CRYPTO_KTYPE_SECRET
Definition apr_crypto.h:387
@ APR_CRYPTO_KTYPE_HMAC
Definition apr_crypto.h:399
@ APR_CRYPTO_KTYPE_CMAC
Definition apr_crypto.h:405
@ APR_CRYPTO_DIGEST_SHA512
Definition apr_crypto.h:146
@ APR_CRYPTO_DIGEST_SHA384
Definition apr_crypto.h:145
@ APR_CRYPTO_DIGEST_SHA224
Definition apr_crypto.h:143
@ APR_CRYPTO_DIGEST_SHA256
Definition apr_crypto.h:144
@ APR_CRYPTO_DIGEST_MD5
Definition apr_crypto.h:141
@ APR_CRYPTO_DIGEST_SHA1
Definition apr_crypto.h:142
@ APR_CRYPTO_DTYPE_HASH
Definition apr_crypto.h:418
@ APR_CRYPTO_DTYPE_SIGN
Definition apr_crypto.h:425
@ APR_CRYPTO_DTYPE_VERIFY
Definition apr_crypto.h:432
@ APR_KEY_AES_128
Definition apr_crypto.h:118
@ APR_KEY_AES_256
Definition apr_crypto.h:120
@ APR_KEY_AES_192
Definition apr_crypto.h:119
@ APR_MODE_CBC
Definition apr_crypto.h:131
@ APR_MODE_ECB
Definition apr_crypto.h:130
@ APR_CRYPTO_CIPHER_CHACHA20
Definition apr_crypto.h:168
@ APR_CRYPTO_CIPHER_AES_256_CTR
Definition apr_crypto.h:167
int apr_status_t
Definition apr_errno.h:44
struct apr_hash_t apr_hash_t
Definition apr_hash.h:52
struct apr_pool_t apr_pool_t
Definition apr_pools.h:60
Definition apr_crypto.h:152
int digestsize
Definition apr_crypto.h:156
apr_crypto_block_key_digest_e type
Definition apr_crypto.h:154
int blocksize
Definition apr_crypto.h:158
Definition apr_crypto.h:232
apr_crypto_block_key_mode_e mode
Definition apr_crypto.h:234
Definition apr_crypto.h:218
apr_crypto_block_key_type_e type
Definition apr_crypto.h:220
int keysize
Definition apr_crypto.h:222
int ivsize
Definition apr_crypto.h:226
int blocksize
Definition apr_crypto.h:224
Definition apr_crypto.h:328
unsigned char * s
Definition apr_crypto.h:330
apr_crypto_block_key_digest_e digest
Definition apr_crypto.h:334
apr_size_t slen
Definition apr_crypto.h:332
Definition apr_crypto.h:497
apr_crypto_digest_type_e dtype
Definition apr_crypto.h:499
union apr_crypto_digest_rec_t::@3 d
Definition apr_crypto.h:343
unsigned char * s
Definition apr_crypto.h:345
apr_size_t slen
Definition apr_crypto.h:347
apr_crypto_block_key_digest_e digest
Definition apr_crypto.h:349
Definition apr_crypto.h:358
const unsigned char * v
Definition apr_crypto.h:364
apr_size_t slen
Definition apr_crypto.h:362
unsigned char * s
Definition apr_crypto.h:360
apr_size_t vlen
Definition apr_crypto.h:366
apr_crypto_block_key_digest_e digest
Definition apr_crypto.h:368
Definition apr_crypto.h:313
const unsigned char * secret
Definition apr_crypto.h:315
apr_size_t secretLen
Definition apr_crypto.h:317
apr_crypto_block_key_digest_e digest
Definition apr_crypto.h:319
Definition apr_crypto.h:285
apr_crypto_block_key_digest_e digest
Definition apr_crypto.h:287
Definition apr_crypto.h:297
apr_crypto_block_key_digest_e digest
Definition apr_crypto.h:303
const unsigned char * secret
Definition apr_crypto.h:299
apr_size_t secretLen
Definition apr_crypto.h:301
Definition apr_crypto.h:442
int pad
Definition apr_crypto.h:450
apr_crypto_key_hash_t hash
Definition apr_crypto.h:472
apr_crypto_key_type ktype
Definition apr_crypto.h:444
apr_crypto_secret_t secret
Definition apr_crypto.h:466
union apr_crypto_key_rec_t::@2 k
apr_crypto_key_hmac_t hmac
Definition apr_crypto.h:478
apr_crypto_block_key_mode_e mode
Definition apr_crypto.h:448
apr_crypto_block_key_type_e type
Definition apr_crypto.h:446
apr_crypto_key_cmac_t cmac
Definition apr_crypto.h:484
apr_crypto_passphrase_t passphrase
Definition apr_crypto.h:459
Definition apr_crypto.h:246
apr_size_t saltLen
Definition apr_crypto.h:254
int iterations
Definition apr_crypto.h:256
const unsigned char * salt
Definition apr_crypto.h:252
const char * pass
Definition apr_crypto.h:248
apr_size_t passLen
Definition apr_crypto.h:250
Definition apr_crypto.h:269
apr_size_t secretLen
Definition apr_crypto.h:275
const unsigned char * secret
Definition apr_crypto.h:273
Definition apu_errno.h:418