Apache Portable Runtime
Loading...
Searching...
No Matches
apr_crypto.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_H
18#define APR_CRYPTO_H
19
20#include "apu.h"
21#include "apr_pools.h"
22#include "apr_tables.h"
23#include "apr_hash.h"
24#include "apu_errno.h"
25#include "apr_thread_proc.h"
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31/**
32 * @file apr_crypto.h
33 * @brief APR-UTIL Crypto library
34 */
35/**
36 * @defgroup APR_Util_Crypto Crypto routines
37 * @ingroup APR
38 * @{
39 */
40
41#if APU_HAVE_CRYPTO || defined(DOXYGEN)
42
43#ifndef APU_CRYPTO_RECOMMENDED_DRIVER
44#if APU_HAVE_COMMONCRYPTO
45/** Recommended driver for this platform */
46#define APU_CRYPTO_RECOMMENDED_DRIVER "commoncrypto"
47#else
48#if APU_HAVE_OPENSSL
49/** Recommended driver for this platform */
50#define APU_CRYPTO_RECOMMENDED_DRIVER "openssl"
51#else
52#if APU_HAVE_NSS
53/** Recommended driver for this platform */
54#define APU_CRYPTO_RECOMMENDED_DRIVER "nss"
55#else
56#if APU_HAVE_MSCNG
57/** Recommended driver for this platform */
58#define APU_CRYPTO_RECOMMENDED_DRIVER "mscng"
59#else
60#if APU_HAVE_MSCAPI
61/** Recommended driver for this platform */
62#define APU_CRYPTO_RECOMMENDED_DRIVER "mscapi"
63#else
64#endif
65#endif
66#endif
67#endif
68#endif
69#endif
70
71/**
72 * Symmetric Key types understood by the library.
73 *
74 * NOTE: It is expected that this list will grow over time.
75 *
76 * Interoperability Matrix:
77 *
78 * The matrix is based on the testcrypto.c unit test, which attempts to
79 * test whether a simple encrypt/decrypt will succeed, as well as testing
80 * whether an encrypted string by one library can be decrypted by the
81 * others.
82 *
83 * Some libraries will successfully encrypt and decrypt their own data,
84 * but won't decrypt data from another library. It is hoped that over
85 * time these anomalies will be found and fixed, but until then it is
86 * recommended that ciphers are chosen that interoperate across platform.
87 *
88 * An X below means the test passes, it does not necessarily mean that
89 * encryption performed is correct or secure. Applications should stick
90 * to ciphers that pass the interoperablity tests on the right hand side
91 * of the table.
92 *
93 * Aligned data is data whose length is a multiple of the block size for
94 * the chosen cipher. Padded data is data that is not aligned by block
95 * size and must be padded by the crypto library.
96 *
97 * OpenSSL CommonCrypto NSS Interop
98 * Align Pad Align Pad Align Pad Align Pad
99 * 3DES_192/CBC X X X X X X X X
100 * 3DES_192/ECB X X X X
101 * AES_256/CBC X X X X X X X X
102 * AES_256/ECB X X X X X X
103 * AES_192/CBC X X X X X X
104 * AES_192/ECB X X X X X
105 * AES_128/CBC X X X X X X
106 * AES_128/ECB X X X X X
107 *
108 * Conclusion: for padded data, use 3DES_192/CBC or AES_256/CBC. For
109 * aligned data, use 3DES_192/CBC, AES_256/CBC or AES_256/ECB.
110 */
111
112/**
113 * Types of ciphers.
114 */
115typedef enum
116{
117 APR_KEY_NONE, APR_KEY_3DES_192, /** 192 bit (3-Key) 3DES */
118 APR_KEY_AES_128, /** 128 bit AES */
119 APR_KEY_AES_192, /** 192 bit AES */
121/** 256 bit AES */
123
124/**
125 * Types of modes supported by the ciphers.
126 */
127typedef enum
128{
129 APR_MODE_NONE, /** An error condition */
130 APR_MODE_ECB, /** Electronic Code Book */
132/** Cipher Block Chaining */
134
135/**
136 * Types of digests supported by the apr_crypto_key() function.
137 */
138typedef enum
139{
140 APR_CRYPTO_DIGEST_NONE, /** An error condition */
148
149/**
150 * Structure returned by the crypto_get_block_key_digests() function.
151 */
153 /** The digest used with this crypto operation. */
155 /** The digest size used with this digest operation */
157 /** The block size used with this digest operation */
160
161/**
162 * Types of ciphers supported by the apr_
163 */
164typedef enum
165{
166 APR_CRYPTO_CIPHER_AUTO, /** Choose the recommended cipher / autodetect the cipher */
167 APR_CRYPTO_CIPHER_AES_256_CTR, /** AES 256 - CTR mode */
170
171/**
172 * Structure representing a backend crypto driver.
173 *
174 * This structure is created with apr_crypto_get_driver().
175 */
177
178/**
179 * Structure to support a group of crypto operations.
180 *
181 * This structure is created with apr_crypto_make().
182 */
184
185/**
186 * Structure representing the configuration of the given backend
187 * crypto library.
188 */
190
191/**
192 * Structure representing a key prepared for encryption, decryption,
193 * signing or verifying.
194 *
195 * This structure is created using the apr_crypto_key() function.
196 */
198
199/**
200 * Structure representing a block context for encryption, decryption,
201 * signing or verifying.
202 *
203 * This structure is created using the apr_crypto_block_encrypt_init()
204 * and apr_crypto_block_decrypt_init() functions.
205 */
207
208/**
209 * Structure representing a digest context for signing or verifying.
210 *
211 * This structure is created using the apr_crypto_digest_init() function.
212 */
214
215/**
216 * Structure returned by the crypto_get_block_key_types() function.
217 */
219 /** The cipher used with this crypto operation. */
221 /** The key size used with this crypto operation */
223 /** The block size used with this crypto operation */
225 /** The initialisation vector size used with this crypto operation */
228
229/**
230 * Structure returned by the crypto_get_block_key_modes() function.
231 */
233 /** The mode used with this crypto operation. */
236
237/**
238 * Structure describing a key to be derived from PBKDF2 to be passed by the
239 * apr_crypto_key() function.
240 *
241 * Derived keys are used for encryption and decryption.
242 *
243 * Implementations must use apr_crypto_key_rec_make() to allocate
244 * this structure.
245 */
247 /** The passphrase used by the key generation algorithm */
248 const char *pass;
249 /** The length of the passphrase */
250 apr_size_t passLen;
251 /** The salt used by the key derivation algorithm */
252 const unsigned char * salt;
253 /** The length of the salt. */
254 apr_size_t saltLen;
255 /** The number of iterations used by the key derivation function */
258
259/**
260 * Structure describing a raw key to be passed by the
261 * apr_crypto_key() function.
262 *
263 * Raw keys are used for encryption and decryption, and must match
264 * the correct sizes for each cipher.
265 *
266 * Implementations must use apr_crypto_key_rec_make() to allocate
267 * this structure.
268 */
269typedef struct apr_crypto_secret_t {
270 /** The raw secret key used for encrypt / decrypt. Must be
271 * the same size as the block size of the cipher being used.
272 */
273 const unsigned char *secret;
274 /** The length of the secret key. */
275 apr_size_t secretLen;
277
278/**
279 * Structure describing a simple digest hash to be generated by the
280 * apr_crypto_key() function.
281 *
282 * Implementations must use apr_crypto_key_rec_make() to allocate
283 * this structure.
284 */
285typedef struct apr_crypto_key_hash_t {
286 /** The digest used for the HMAC. */
289
290/**
291 * Structure describing a HMAC key and digest to be generated by the
292 * apr_crypto_key() function.
293 *
294 * Implementations must use apr_crypto_key_rec_make() to allocate
295 * this structure.
296 */
297typedef struct apr_crypto_key_hmac_t {
298 /** The secret used for the HMAC */
299 const unsigned char *secret;
300 /** The length of the secret used for the HMAC */
301 apr_size_t secretLen;
302 /** The digest used for the HMAC. */
305
306/**
307 * Structure describing a CMAC key and digest to be generated by the
308 * apr_crypto_key() function.
309 *
310 * Implementations must use apr_crypto_key_rec_make() to allocate
311 * this structure.
312 */
313typedef struct apr_crypto_key_cmac_t {
314 /** The secret used for the CMAC */
315 const unsigned char *secret;
316 /** The length of the secret used for the CMAC */
317 apr_size_t secretLen;
318 /** The digest used for the CMAC. */
321
322/**
323 * Structure used to create a hashed digest.
324 *
325 * Implementations must use apr_crypto_digest_rec_make() to allocate
326 * this structure.
327 */
329 /** The message digest */
330 unsigned char *s;
331 /** The length of the message digest */
332 apr_size_t slen;
333 /** The digest algorithm */
336
337/**
338 * Structure used to create a signature.
339 *
340 * Implementations must use apr_crypto_digest_rec_make() to allocate
341 * this structure.
342 */
344 /** The message digest */
345 unsigned char *s;
346 /** The length of the message digest */
347 apr_size_t slen;
348 /** The digest algorithm */
351
352/**
353 * Structure used to create a signature for verification.
354 *
355 * Implementations must use apr_crypto_digest_rec_make() to allocate
356 * this structure.
357 */
359 /** The message digest generated */
360 unsigned char *s;
361 /** The length of the message digest */
362 apr_size_t slen;
363 /** The message digest to be verified against */
364 const unsigned char *v;
365 /** The length of the message digest */
366 apr_size_t vlen;
367 /** The digest algorithm */
370
371/**
372 * Types of keys supported by the apr_crypto_key() function and the
373 * apr_crypto_key_rec_t structure.
374 */
375typedef enum {
376 /**
377 * Key is derived from a passphrase.
378 *
379 * Used with the encrypt / decrypt functions.
380 */
382 /**
383 * Key is derived from a raw key.
384 *
385 * Used with the encrypt / decrypt functions.
386 */
388 /**
389 * Simple digest, no key.
390 *
391 * Used with the digest functions.
392 */
394 /**
395 * HMAC Key is derived from a raw key.
396 *
397 * Used with the digest functions.
398 */
400 /**
401 * CMAC Key is derived from a raw key.
402 *
403 * Used with the digest functions.
404 */
407
408/**
409 * Types of digests supported by the apr_crypto_digest() functions and the
410 * apr_crypto_digest_rec_t structure.
411 */
412typedef enum {
413 /**
414 * Simple digest operation.
415 *
416 * Use with apr_crypto_key_rec_t APR_CRYPTO_KTYPE_HASH.
417 */
419 /**
420 * Sign operation.
421 *
422 * Use with apr_crypto_key_rec_t APR_CRYPTO_KTYPE_HMAC or
423 * APR_CRYPTO_KTYPE_CMAC.
424 */
426 /**
427 * Verify operation.
428 *
429 * Use with apr_crypto_key_rec_t APR_CRYPTO_KTYPE_HMAC or
430 * APR_CRYPTO_KTYPE_CMAC.
431 */
434
435/**
436 * Structure describing a key to be generated by the
437 * apr_crypto_key() function.
438 *
439 * Implementations must use apr_crypto_key_rec_make() to allocate
440 * this structure.
441 */
442typedef struct apr_crypto_key_rec_t {
443 /** The type of the key. */
445 /** The cipher used with this crypto operation. */
447 /** The mode used with this crypto operation. */
449 /** Non zero if padding should be used with this crypto operation. */
450 int pad;
451 /** Details of each key, based on the key type. */
452 union {
453 /**
454 * This key is generated using a PBE algorithm from a given
455 * passphrase, and can be used to encrypt / decrypt.
456 *
457 * Key type: APR_CRYPTO_KTYPE_PASSPHRASE
458 */
460 /**
461 * This is a raw key matching the block size of the given
462 * cipher, and can be used to encrypt / decrypt.
463 *
464 * Key type: APR_CRYPTO_KTYPE_SECRET
465 */
467 /**
468 * This represents a simple digest with no key.
469 *
470 * Key type: APR_CRYPTO_KTYPE_HASH
471 */
473 /**
474 * This is a key of arbitrary length used with an HMAC.
475 *
476 * Key type: APR_CRYPTO_KTYPE_HMAC
477 */
479 /**
480 * This is a key of arbitrary length used with a CMAC.
481 *
482 * Key type: APR_CRYPTO_KTYPE_CMAC
483 */
485 } k;
487
488/**
489 * Structure describing a digest to be hashed, signed or verified.
490 *
491 * This structure is passed to the apr_crypto_digest_init() and
492 * apr_crypto_digest() functions.
493 *
494 * Implementations must use apr_crypto_digest_rec_make() to allocate
495 * this structure.
496 */
498 /** The type of the digest record. */
500 /** Details of each digest, based on the digest type. */
501 union {
505 } d;
507
508/**
509 * @brief Perform once-only initialisation. Call once only.
510 *
511 * @param pool - pool to register any shutdown cleanups, etc
512 * @return APR_ENOTIMPL in case of no crypto support.
513 */
515
516/* TODO: doxygen */
517APR_DECLARE(apr_status_t) apr_crypto_lib_version(const char *name,
518 const char **version);
519APR_DECLARE(apr_status_t) apr_crypto_lib_init(const char *name,
520 const char *params,
521 const apu_err_t **result,
522 apr_pool_t *pool);
523APR_DECLARE(apr_status_t) apr_crypto_lib_term(const char *name);
524APR_DECLARE(int) apr_crypto_lib_is_active(const char *name);
525
526/**
527 * @brief Zero out the buffer provided when the pool is cleaned up.
528 *
529 * @param pool - pool to register the cleanup
530 * @param buffer - buffer to zero out
531 * @param size - size of the buffer to zero out
532 */
534 apr_size_t size);
535
536/**
537 * @brief Always zero out the buffer provided, without being optimized out by
538 * the compiler.
539 *
540 * @param buffer - buffer to zero out
541 * @param size - size of the buffer to zero out
542 */
543APR_DECLARE(apr_status_t) apr_crypto_memzero(void *buffer, apr_size_t size);
544
545/**
546 * @brief Timing attacks safe buffers comparison, where the executing time does
547 * not depend on the bytes compared but solely on the number of bytes.
548 *
549 * @param buf1 - first buffer to compare
550 * @param buf2 - second buffer to compare
551 * @param size - size of the buffers to compare
552 * @return 1 if the buffers are equals, 0 otherwise.
553 */
554APR_DECLARE(int) apr_crypto_equals(const void *buf1, const void *buf2,
555 apr_size_t size);
556
557/**
558 * @brief Get the driver struct for a name
559 *
560 * @param driver - pointer to driver struct.
561 * @param name - driver name
562 * @param params - array of initialisation parameters
563 * @param result - result and error message on failure
564 * @param pool - (process) pool to register cleanup
565 * @return APR_SUCCESS for success
566 * @return APR_ENOTIMPL for no driver (when DSO not enabled)
567 * @return APR_EDSOOPEN if DSO driver file can't be opened
568 * @return APR_ESYMNOTFOUND if the driver file doesn't contain a driver
569 * @remarks NSS: the params can have "dir", "key3", "cert7" and "secmod"
570 * keys, each followed by an equal sign and a value. Such key/value pairs can
571 * be delimited by space or tab. If the value contains a space, surround the
572 * whole key value pair in quotes: "dir=My Directory".
573 * @remarks OpenSSL: currently no params are supported.
574 */
576 const apr_crypto_driver_t **driver,
577 const char *name, const char *params, const apu_err_t **result,
578 apr_pool_t *pool);
579
580/**
581 * @brief Return the name of the driver.
582 *
583 * @param driver - The driver in use.
584 * @return The name of the driver.
585 */
587 const apr_crypto_driver_t *driver);
588
589/**
590 * @brief Get the result of the last operation on a context. If the result
591 * is NULL, the operation was successful.
592 * @param result - the result structure
593 * @param f - context pointer
594 * @return APR_SUCCESS for success
595 */
597 const apr_crypto_t *f);
598
599/**
600 * @brief Create a context for supporting encryption. Keys, certificates,
601 * algorithms and other parameters will be set per context. More than
602 * one context can be created at one time. A cleanup will be automatically
603 * registered with the given pool to guarantee a graceful shutdown.
604 * @param f - context pointer will be written here
605 * @param driver - driver to use
606 * @param params - array of key parameters
607 * @param pool - process pool
608 * @return APR_ENOENGINE when the engine specified does not exist. APR_EINITENGINE
609 * if the engine cannot be initialised.
610 * @remarks NSS: currently no params are supported.
611 * @remarks OpenSSL legacy: prior to v3, use "engine=[engine]" to set the engine.
612 * @remarks OpenSSL3+: use "provider=[provider]" to set the provider to load, can
613 * be specified more than once.
614 * @remarks OpenSSL3.5+: "name=[value]" params specified after each "provider"
615 * are applied to that provider.
616 */
618 const apr_crypto_driver_t *driver, const char *params,
619 apr_pool_t *pool);
620
621/**
622 * @brief Get a hash table of key digests, keyed by the name of the digest against
623 * a pointer to apr_crypto_block_key_digest_t, which in turn begins with an
624 * integer.
625 *
626 * @param digests - hashtable of key digests keyed to constants.
627 * @param f - encryption context
628 * @return APR_SUCCESS for success
629 */
631 const apr_crypto_t *f);
632
633/**
634 * @brief Get a hash table of key types, keyed by the name of the type against
635 * a pointer to apr_crypto_block_key_type_t, which in turn begins with an
636 * integer.
637 *
638 * @param types - hashtable of key types keyed to constants.
639 * @param f - encryption context
640 * @return APR_SUCCESS for success
641 */
643 const apr_crypto_t *f);
644
645/**
646 * @brief Get a hash table of key modes, keyed by the name of the mode against
647 * a pointer to apr_crypto_block_key_mode_t, which in turn begins with an
648 * integer.
649 *
650 * @param modes - hashtable of key modes keyed to constants.
651 * @param f - encryption context
652 * @return APR_SUCCESS for success
653 */
655 const apr_crypto_t *f);
656
657/**
658 * @brief Create a key record to be passed to apr_crypto_key().
659 * @param ktype The apr_crypto_key_type to use.
660 * @param p The pool to use.
661 * @return Returns a blank structure of the correct size.
662 */
665
666/**
667 * @brief Create a digest record to be passed to apr_crypto_digest_init().
668 * @param dtype The type of digest record to create.
669 * @param p The pool to use.
670 * @return Returns a blank structure of the correct size.
671 */
674
675/**
676 * @brief Create a key from the provided secret or passphrase. The key is cleaned
677 * up when the context is cleaned, and may be reused with multiple
678 * encryption, decryption, signing or verifying operations. The choice of
679 * key type much match the intended operation.
680 * @note If *key is NULL, a apr_crypto_key_t will be created from a pool. If
681 * *key is not NULL, *key must point at a previously created structure.
682 * @param key The key returned, see note.
683 * @param rec The key record, from which the key will be derived.
684 * @param f The context to use.
685 * @param p The pool to use.
686 * @return APR_ENOKEY if the pass phrase is missing or empty, or if a backend
687 * error occurred while generating the key.
688 * @return APR_ENOCIPHER if the type or mode
689 * is not supported by the particular backend.
690 * @return APR_EKEYTYPE if the key type is
691 * not known.
692 * @return APR_EPADDING if padding was requested but is not supported.
693 * @return APR_ENOTIMPL if not implemented.
694 */
696 const apr_crypto_key_rec_t *rec, const apr_crypto_t *f, apr_pool_t *p);
697
698/**
699 * @brief Create a key from the given passphrase. By default, the PBKDF2
700 * algorithm is used to generate the key from the passphrase. It is expected
701 * that the same pass phrase will generate the same key, regardless of the
702 * backend crypto platform used. The key is cleaned up when the context
703 * is cleaned, and may be reused with multiple encryption or decryption
704 * operations.
705 * @note If *key is NULL, a apr_crypto_key_t will be created from a pool. If
706 * *key is not NULL, *key must point at a previously created structure.
707 * @param key The key returned, see note.
708 * @param ivSize The size of the initialisation vector will be returned, based
709 * on whether an IV is relevant for this type of crypto.
710 * @param pass The passphrase to use.
711 * @param passLen The passphrase length in bytes
712 * @param salt The salt to use.
713 * @param saltLen The salt length in bytes
714 * @param type 3DES_192, AES_128, AES_192, AES_256.
715 * @param mode Electronic Code Book / Cipher Block Chaining.
716 * @param doPad Pad if necessary.
717 * @param iterations Number of iterations to use in algorithm
718 * @param f The context to use.
719 * @param p The pool to use.
720 * @return APR_ENOKEY if the pass phrase is missing or empty, or if a backend
721 * error occurred while generating the key.
722 * @return APR_ENOCIPHER if the type or mode
723 * is not supported by the particular backend.
724 * @return APR_EKEYTYPE if the key type is
725 * not known.
726 * @return APR_EPADDING if padding was requested but is not supported.
727 * @return APR_ENOTIMPL if not implemented.
728 * @deprecated Replaced by apr_crypto_key().
729 */
731 apr_size_t *ivSize, const char *pass, apr_size_t passLen,
732 const unsigned char * salt, apr_size_t saltLen,
734 const apr_crypto_block_key_mode_e mode, const int doPad,
735 const int iterations, const apr_crypto_t *f, apr_pool_t *p);
736
737/**
738 * @brief Initialise a context for encrypting arbitrary data using the given key.
739 * @note If *ctx is NULL, a apr_crypto_block_t will be created from a pool. If
740 * *ctx is not NULL, *ctx must point at a previously created structure.
741 * @param ctx The block context returned, see note.
742 * @param iv Optional initialisation vector. If the buffer pointed to is NULL,
743 * an IV will be created at random, in space allocated from the pool.
744 * If the buffer pointed to is not NULL, the IV in the buffer will be
745 * used.
746 * @param key The key structure to use.
747 * @param blockSize The block size of the cipher.
748 * @param p The pool to use.
749 * @return APR_ENOIV if an initialisation vector is required but not specified.
750 * @return APR_EINIT if the backend failed to initialise the context.
751 * @return APR_ENOTIMPL if not implemented.
752 * @return APR_EINVAL if the key type does not support the given operation.
753 */
755 apr_crypto_block_t **ctx, const unsigned char **iv,
756 const apr_crypto_key_t *key, apr_size_t *blockSize, apr_pool_t *p);
757
758/**
759 * @brief Encrypt data provided by in, write it to out.
760 * @note The number of bytes written will be written to outlen. If
761 * out is NULL, outlen will contain the maximum size of the
762 * buffer needed to hold the data, including any data
763 * generated by apr_crypto_block_encrypt_finish below. If *out points
764 * to NULL, a buffer sufficiently large will be created from
765 * the pool provided. If *out points to a not-NULL value, this
766 * value will be used as a buffer instead.
767 * @param out Address of a buffer to which data will be written,
768 * see note.
769 * @param outlen Length of the output will be written here.
770 * @param in Address of the buffer to read.
771 * @param inlen Length of the buffer to read.
772 * @param ctx The block context to use.
773 * @return APR_ECRYPT if an error occurred.
774 * @return APR_ENOTIMPL if not implemented.
775 * @return APR_EINVAL if the key type does not support the given operation.
776 */
778 apr_size_t *outlen, const unsigned char *in, apr_size_t inlen,
779 apr_crypto_block_t *ctx);
780
781/**
782 * @brief Encrypt final data block, write it to out.
783 * @note If necessary the final block will be written out after being
784 * padded. Typically the final block will be written to the
785 * same buffer used by apr_crypto_block_encrypt, offset by the
786 * number of bytes returned as actually written by the
787 * apr_crypto_block_encrypt() call. After this call, the context
788 * is cleaned and can be reused by apr_crypto_block_encrypt_init().
789 * @param out Address of a buffer to which data will be written. This
790 * buffer must already exist, and is usually the same
791 * buffer used by apr_crypto_block_encrypt(). See note.
792 * @param outlen Length of the output will be written here.
793 * @param ctx The block context to use.
794 * @return APR_ECRYPT if an error occurred.
795 * @return APR_EPADDING if padding was enabled and the block was incorrectly
796 * formatted.
797 * @return APR_ENOTIMPL if not implemented.
798 * @return APR_EINVAL if the key type does not support the given operation.
799 */
801 apr_size_t *outlen, apr_crypto_block_t *ctx);
802
803/**
804 * @brief Initialise a context for decrypting arbitrary data using the given key.
805 * @note If *ctx is NULL, a apr_crypto_block_t will be created from a pool. If
806 * *ctx is not NULL, *ctx must point at a previously created structure.
807 * @param ctx The block context returned, see note.
808 * @param blockSize The block size of the cipher.
809 * @param iv Optional initialisation vector.
810 * @param key The key structure to use.
811 * @param p The pool to use.
812 * @return APR_ENOIV if an initialisation vector is required but not specified.
813 * @return APR_EINIT if the backend failed to initialise the context.
814 * @return APR_ENOTIMPL if not implemented.
815 * @return APR_EINVAL if the key type does not support the given operation.
816 */
818 apr_crypto_block_t **ctx, apr_size_t *blockSize,
819 const unsigned char *iv, const apr_crypto_key_t *key, apr_pool_t *p);
820
821/**
822 * @brief Decrypt data provided by in, write it to out.
823 * @note The number of bytes written will be written to outlen. If
824 * out is NULL, outlen will contain the maximum size of the
825 * buffer needed to hold the data, including any data
826 * generated by apr_crypto_block_decrypt_finish below. If *out points
827 * to NULL, a buffer sufficiently large will be created from
828 * the pool provided. If *out points to a not-NULL value, this
829 * value will be used as a buffer instead.
830 * @param out Address of a buffer to which data will be written,
831 * see note.
832 * @param outlen Length of the output will be written here.
833 * @param in Address of the buffer to read.
834 * @param inlen Length of the buffer to read.
835 * @param ctx The block context to use.
836 * @return APR_ECRYPT if an error occurred.
837 * @return APR_ENOTIMPL if not implemented.
838 * @return APR_EINVAL if the key type does not support the given operation.
839 */
841 apr_size_t *outlen, const unsigned char *in, apr_size_t inlen,
842 apr_crypto_block_t *ctx);
843
844/**
845 * @brief Decrypt final data block, write it to out.
846 * @note If necessary the final block will be written out after being
847 * padded. Typically the final block will be written to the
848 * same buffer used by apr_crypto_block_decrypt, offset by the
849 * number of bytes returned as actually written by the
850 * apr_crypto_block_decrypt() call. After this call, the context
851 * is cleaned and can be reused by apr_crypto_block_decrypt_init().
852 * @param out Address of a buffer to which data will be written. This
853 * buffer must already exist, and is usually the same
854 * buffer used by apr_crypto_block_decrypt(). See note.
855 * @param outlen Length of the output will be written here.
856 * @param ctx The block context to use.
857 * @return APR_ECRYPT if an error occurred.
858 * @return APR_EPADDING if padding was enabled and the block was incorrectly
859 * formatted.
860 * @return APR_ENOTIMPL if not implemented.
861 * @return APR_EINVAL if the key type does not support the given operation.
862 */
864 apr_size_t *outlen, apr_crypto_block_t *ctx);
865
866/**
867 * @brief Clean encryption / decryption context.
868 * @note After cleanup, a context is free to be reused if necessary.
869 * @param ctx The block context to use.
870 * @return Returns APR_ENOTIMPL if not supported.
871 */
873
874/**
875 * @brief Initialise a context for hashing, signing or verifying arbitrary
876 * data.
877 *
878 * This function supports:
879 * - Simple hashing (MD5, SHA1, SHA224, SHA256, SHA384, SHA512).
880 * - HMAC (with a secret key)
881 * - CMAC (with a secret key)
882 *
883 * Details of the key and the type of digest to be performed are
884 * passed in the constant apr_crypto_key_t structure, which can be
885 * reused by many calls to apr_crypto_digest_init().
886 *
887 * Details of this particular operation are read from and written to
888 * the apr_crypto_digest_rec_t structure, which is expected to
889 * contain the message digest to be verified, as well as message
890 * digest generated during the hashing or signing process. This
891 * structure will be modified by each digest operation, and cannot be
892 * shared.
893 * @note If *d is NULL, a apr_crypto_digest_t will be created from a pool. If
894 * *d is not NULL, *d must point at a previously created structure.
895 * @param d The digest context returned, see note.
896 * @param key The key structure to use.
897 * @param rec The digest record indicating whether we want to sign or verify.
898 * This record contains digest we want to verify against, as well as
899 * the signature we have generated.
900 * @param p The pool to use.
901 * @return APR_SUCCESS if successful.
902 * @return APR_ENOIV if an initialisation vector is required but not specified.
903 * @return APR_EINIT if the backend failed to initialise the context.
904 * @return APR_ENOTIMPL if not implemented.
905 * @return APR_EINVAL if the key type does not support the given operation.
906 */
909
910/**
911 * @brief Update the digest with data provided by in.
912 * @param digest The block context to use.
913 * @param in Address of the buffer to digest.
914 * @param inlen Length of the buffer to digest.
915 * @return APR_SUCCESS if successful.
916 * @return APR_ECRYPT if an error occurred.
917 * @return APR_ENOTIMPL if not implemented.
918 * @return APR_EINVAL if the key type does not support the given operation.
919 */
921 const unsigned char *in, apr_size_t inlen);
922
923/**
924 * @brief Finalise the digest and write the result.
925 *
926 * The result is written to the apr_crypto_digest_rec_t structure
927 * passed into apr_crypto_digest_init().
928 *
929 * If verification is requested, this function will return the
930 * result of the verification.
931 * @note After this call, the context is cleaned and can be reused by
932 * apr_crypto_digest_init().
933 * @param digest The digest context to use.
934 * @return APR_SUCCESS if hash, signing or verification was successful.
935 * @return APR_ENOVERIFY if the verification failed.
936 * @return APR_ECRYPT if an error occurred.
937 * @return APR_EPADDING if padding was enabled and the block was incorrectly
938 * formatted.
939 * @return APR_ENOTIMPL if not implemented.
940 * @return APR_EINVAL if the key type does not support the given operation.
941 */
943
944/**
945 * @brief One shot digest on a single memory buffer.
946 * @param key The key structure to use.
947 * @param rec The digest record indicating whether we want to sign or verify.
948 * This record contains digest we want to verify against, as well as
949 * the signature we have generated. This record will contain the digest
950 * calculated.
951 * @param in Address of the buffer to digest.
952 * @param inlen Length of the buffer to digest.
953 * @param p The pool to use.
954 * @return APR_ENOIV if an initialisation vector is required but not specified.
955 * @return APR_EINIT if the backend failed to initialise the context.
956 * @return APR_ENOTIMPL if not implemented.
957 * @return APR_EINVAL if the key type does not support the given operation.
958 */
960 apr_crypto_digest_rec_t *rec, const unsigned char *in, apr_size_t inlen,
961 apr_pool_t *p);
962
963/**
964 * @brief Clean digest context.
965 * @note After cleanup, a digest context is free to be reused if necessary.
966 * @param ctx The digest context to use.
967 * @return Returns APR_ENOTIMPL if not supported.
968 */
970
971/**
972 * @brief Clean encryption / decryption context.
973 * @note After cleanup, a context is free to be reused if necessary.
974 * @param f The context to use.
975 * @return Returns APR_ENOTIMPL if not supported.
976 */
978
979/**
980 * @brief Shutdown the crypto library.
981 * @note After shutdown, it is expected that the init function can be called again.
982 * @param driver - driver to use
983 * @return Returns APR_ENOTIMPL if not supported.
984 */
986 const apr_crypto_driver_t *driver);
987
988#if APU_HAVE_CRYPTO_PRNG
989
990/**
991 * Cryptographic Pseudo Random Number Generator (CPRNG).
992 *
993 * Allows to generate cryptographically secure random bytes indefinitely
994 * given an initial seed of \ref APR_CRYPTO_PRNG_SEED_SIZE bytes (32), which
995 * is either provided by the caller or automatically gathered from the system.
996 * The CPRNG can also be re-seeded at any time, or after a process is fork()ed.
997 *
998 * The internal key is renewed every \ref APR_CRYPTO_PRNG_SEED_SIZE random
999 * bytes produced and those data once returned to the caller are cleared from
1000 * the internal state, which ensures forward secrecy.
1001 *
1002 * This CPRNG is fast, based on a stream cipher, and will never block besides
1003 * the initial seed or any reseed if it depends on the system entropy.
1004 *
1005 * Finally, it can be used either globally (locked in multithread environment),
1006 * per-thread (a lock free instance is automatically created for each thread on
1007 * first use), or created as standalone instance (manageable independently).
1008 */
1009
1010#define APR_CRYPTO_PRNG_SEED_SIZE 32
1011
1012#define APR_CRYPTO_PRNG_LOCKED (0x1)
1013#define APR_CRYPTO_PRNG_PER_THREAD (0x2)
1014#define APR_CRYPTO_PRNG_MASK (0x3)
1015
1016/** Opaque CPRNG state */
1017typedef struct apr_crypto_prng_t apr_crypto_prng_t;
1018
1019/**
1020 * @brief Perform global initialisation. Call once only.
1021 *
1022 * @param pool Used to allocate memory and register cleanups
1023 * @param crypto The crypto context to use. If NULL, one will be created from
1024 * the recommended crypto implementation.
1025 * @param cipher The cipher to use.
1026 * @param bufsize The size of the buffer used to cache upcoming random bytes.
1027 * @param seed A custom seed of \ref APR_CRYPTO_PRNG_SEED_SIZE bytes,
1028 * or NULL for the seed to be gathered from system entropy.
1029 * @param flags \ref APR_CRYPTO_PRNG_PER_THREAD to allow for per-thread CPRNG,
1030 * or zero.
1031 * @return APR_EREINIT if called more than once,
1032 * any system error (APR_ENOMEM, ...).
1033 */
1034APR_DECLARE(apr_status_t) apr_crypto_prng_init(apr_pool_t *pool, apr_crypto_t *crypto,
1035 apr_crypto_cipher_e cipher, apr_size_t bufsize, const unsigned char seed[], int flags);
1036
1037/**
1038 * @brief Terminate global initialisation if needed, before automatic cleanups.
1039 *
1040 * @return APR_EINIT if \ref apr_crypto_prng_init() was not called.
1041 */
1042APR_DECLARE(apr_status_t) apr_crypto_prng_term(void);
1043
1044/**
1045 * @brief Generate cryptographically secure random bytes from the global CPRNG.
1046 *
1047 * @param buf The destination buffer
1048 * @param len The destination length
1049 * @return APR_EINIT if \ref apr_crypto_prng_init() was not called.
1050 * any system error (APR_ENOMEM, ...).
1051 */
1052APR_DECLARE(apr_status_t) apr_crypto_random_bytes(void *buf, apr_size_t len);
1053
1054#if APR_HAS_THREADS
1055/**
1056 * @brief Generate cryptographically secure random bytes from the CPRNG of
1057 * the current thread.
1058 *
1059 * @param buf The destination buffer
1060 * @param len The destination length
1061 * @return APR_EINIT if \ref apr_crypto_prng_init() was not called or
1062 * called without \ref APR_CRYPTO_PRNG_PER_THREAD,
1063 * any system error (APR_ENOMEM, ...).
1064 */
1065APR_DECLARE(apr_status_t) apr_crypto_random_thread_bytes(void *buf,
1066 apr_size_t len);
1067#endif
1068
1069/**
1070 * @brief Create a standalone CPRNG.
1071 *
1072 * @param pcprng The CPRNG created.
1073 * @param crypto The crypto context to use. If NULL, one will be created from
1074 * the recommended crypto implementation.
1075 * @param cipher The cipher to use.
1076 * @param bufsize The size of the buffer used to cache upcoming random bytes.
1077 * @param flags \ref APR_CRYPTO_PRNG_LOCKED to control concurrent accesses,
1078 * or zero.
1079 * @param seed A custom seed of \ref APR_CRYPTO_PRNG_SEED_SIZE bytes,
1080 * or NULL for the seed to be gathered from system entropy.
1081 * @param pool Used to allocate memory and register cleanups, or NULL
1082 * if the memory should be managed outside (besides per-thread
1083 * which has an automatic memory management with no pool, when
1084 * NULL is given the caller is responsible for calling
1085 * \ref apr_crypto_prng_destroy() or some memory would leak.
1086 * @return APR_EINVAL if \ref bufsize is too large or flags are unknown,
1087 * APR_ENOTIMPL if \ref APR_CRYPTO_PRNG_LOCKED with !APR_HAS_THREADS,
1088 * APR_ENOCIPHER if neither Chacha20 nor AES-256-CTR are available,
1089 * any system error (APR_ENOMEM, ...).
1090 */
1091APR_DECLARE(apr_status_t) apr_crypto_prng_create(apr_crypto_prng_t **pcprng,
1092 apr_crypto_t *crypto, apr_crypto_cipher_e cipher, apr_size_t bufsize,
1093 int flags, const unsigned char seed[], apr_pool_t *pool);
1094
1095/**
1096 * @brief Destroy a standalone CPRNG.
1097 *
1098 * @param cprng The CPRNG to destroy.
1099 * @return APR_SUCCESS.
1100 */
1101APR_DECLARE(apr_status_t) apr_crypto_prng_destroy(apr_crypto_prng_t *cprng);
1102
1103/**
1104 * @brief Rekey a CPRNG.
1105 *
1106 * @param cprng The CPRNG, or NULL for all the created CPRNGs (but per-thread).
1107 * @return Any system error (APR_ENOMEM, ...).
1108 */
1109APR_DECLARE(apr_status_t) apr_crypto_prng_rekey(apr_crypto_prng_t *cprng);
1110
1111/**
1112 * @brief Reseed a CPRNG.
1113 *
1114 * @param cprng The CPRNG to reseed, or NULL for the global CPRNG.
1115 * @param seed A custom seed of \ref APR_CRYPTO_PRNG_SEED_SIZE bytes,
1116 * or NULL for the seed to be gathered from system entropy.
1117 * @return Any system error (APR_ENOMEM, ...).
1118 */
1119APR_DECLARE(apr_status_t) apr_crypto_prng_reseed(apr_crypto_prng_t *cprng,
1120 const unsigned char seed[]);
1121
1122#if APR_HAS_FORK
1123#define APR_CRYPTO_FORK_INPARENT 0
1124#define APR_CRYPTO_FORK_INCHILD 1
1125
1126/**
1127 * @brief Rekey a CPRNG in the parent and/or child process after a fork(),
1128 * so that they don't share the same state.
1129 *
1130 * @param cprng The CPRNG, or NULL for all the created CPRNGs (but per-thread).
1131 * @param in_child Whether in the child process (non zero), or in the parent
1132 * process otherwise (zero).
1133 *
1134 * @return Any system error (APR_ENOMEM, ...).
1135 */
1136APR_DECLARE(apr_status_t) apr_crypto_prng_after_fork(apr_crypto_prng_t *cprng,
1137 int flags);
1138#endif
1139
1140/**
1141 * @brief Generate cryptographically secure random bytes from a CPRNG.
1142 *
1143 * @param cprng The CPRNG, or NULL for the global CPRNG.
1144 * @param buf The destination buffer
1145 * @param len The destination length
1146 * @return Any system error (APR_ENOMEM, ...).
1147 */
1148APR_DECLARE(apr_status_t) apr_crypto_prng_bytes(apr_crypto_prng_t *cprng,
1149 void *buf, apr_size_t len);
1150
1151#endif /* APU_HAVE_CRYPTO_PRNG */
1152
1153#endif /* APU_HAVE_CRYPTO */
1154
1155/** @} */
1156
1157#ifdef __cplusplus
1158}
1159#endif
1160
1161#endif
APR Hash Tables.
APR memory allocation.
APR Table library.
APR Thread and Process Library.
APR-Util Error Codes.
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
#define APR_DECLARE(type)
Definition apr.h:523
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