2 Bacula(R) - The Network Backup Solution
4 Copyright (C) 2000-2016 Kern Sibbald
6 The original author of Bacula is Kern Sibbald, with contributions
7 from many others, a complete list can be found in the file AUTHORS.
9 You may use this file and others of this release according to the
10 license defined in the LICENSE file, which includes the Affero General
11 Public License, v3.0 ("AGPLv3") and some additional permissions and
12 terms pursuant to its AGPLv3 Section 7.
14 This notice must be preserved when any source code is
15 conveyed and/or propagated.
17 Bacula(R) is a registered trademark of Kern Sibbald.
20 * crypto.h Encryption support functions
22 * Author: Landon Fuller <landonf@opendarwin.org>
26 * This file was contributed to the Bacula project by Landon Fuller.
28 * Landon Fuller has been granted a perpetual, worldwide, non-exclusive,
29 * no-charge, royalty-free, irrevocable copyright * license to reproduce,
30 * prepare derivative works of, publicly display, publicly perform,
31 * sublicense, and distribute the original work contributed by Landon Fuller
32 * to the Bacula project in source or object form.
34 * If you wish to license these contributions under an alternate open source
35 * license please contact Landon Fuller <landonf@opendarwin.org>.
41 /* Opaque X509 Public/Private Key Pair Structure */
42 typedef struct X509_Keypair X509_KEYPAIR;
44 /* Opaque Message Digest Structure */
45 /* Digest is defined (twice) in crypto.c */
46 typedef struct Digest DIGEST;
48 /* Opaque Message Signature Structure */
49 typedef struct Signature SIGNATURE;
51 /* Opaque PKI Symmetric Key Data Structure */
52 typedef struct Crypto_Session CRYPTO_SESSION;
54 /* Opaque Encryption/Decryption Context Structure */
55 typedef struct Cipher_Context CIPHER_CONTEXT;
57 /* PEM Decryption Passphrase Callback */
58 typedef int (CRYPTO_PEM_PASSWD_CB) (char *buf, int size, const void *userdata);
62 /* These are stored on disk and MUST NOT change */
63 CRYPTO_DIGEST_NONE = 0,
64 CRYPTO_DIGEST_MD5 = 1,
65 CRYPTO_DIGEST_SHA1 = 2,
66 CRYPTO_DIGEST_SHA256 = 3,
67 CRYPTO_DIGEST_SHA512 = 4
72 # define CRYPTO_DIGEST_DEFAULT CRYPTO_DIGEST_SHA256
74 # define CRYPTO_DIGEST_DEFAULT CRYPTO_DIGEST_SHA1
79 /* These are not stored on disk */
80 CRYPTO_CIPHER_AES_128_CBC, /* Keep AES128 as the first one */
81 CRYPTO_CIPHER_AES_192_CBC,
82 CRYPTO_CIPHER_AES_256_CBC,
83 CRYPTO_CIPHER_BLOWFISH_CBC
86 /* Crypto API Errors */
88 CRYPTO_ERROR_NONE = 0, /* No error */
89 CRYPTO_ERROR_NOSIGNER = 1, /* Signer not found */
90 CRYPTO_ERROR_NORECIPIENT = 2, /* Recipient not found */
91 CRYPTO_ERROR_INVALID_DIGEST = 3, /* Unsupported digest algorithm */
92 CRYPTO_ERROR_INVALID_CRYPTO = 4, /* Unsupported encryption algorithm */
93 CRYPTO_ERROR_BAD_SIGNATURE = 5, /* Signature is invalid */
94 CRYPTO_ERROR_DECRYPTION = 6, /* Decryption error */
95 CRYPTO_ERROR_INTERNAL = 7 /* Internal Error */
98 /* Message Digest Sizes */
99 #define CRYPTO_DIGEST_MD5_SIZE 16 /* 128 bits */
100 #define CRYPTO_DIGEST_SHA1_SIZE 20 /* 160 bits */
101 #define CRYPTO_DIGEST_SHA256_SIZE 32 /* 256 bits */
102 #define CRYPTO_DIGEST_SHA512_SIZE 64 /* 512 bits */
104 /* Maximum Message Digest Size */
107 /* Let OpenSSL define a few things */
108 #define CRYPTO_DIGEST_MAX_SIZE EVP_MAX_MD_SIZE
109 #define CRYPTO_CIPHER_MAX_BLOCK_SIZE EVP_MAX_BLOCK_LENGTH
111 #else /* HAVE_OPENSSL */
114 * This must be kept in sync with the available message digest algorithms.
115 * Just in case someone forgets, I've added assertions
116 * to crypto_digest_finalize().
121 #define CRYPTO_DIGEST_MAX_SIZE CRYPTO_DIGEST_SHA1_SIZE
123 #define CRYPTO_DIGEST_MAX_SIZE CRYPTO_DIGEST_SHA512_SIZE
127 #define CRYPTO_CIPHER_MAX_BLOCK_SIZE 0
129 #endif /* HAVE_OPENSSL */
131 #endif /* __CRYPTO_H_ */