2 Bacula® - The Network Backup Solution
4 Copyright (C) 2005-2007 Free Software Foundation Europe e.V.
6 The main author of Bacula is Kern Sibbald, with contributions from
7 many others, a complete list can be found in the file AUTHORS.
8 This program is Free Software; you can redistribute it and/or
9 modify it under the terms of version two of the GNU General Public
10 License as published by the Free Software Foundation and included
13 This program is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 Bacula® is a registered trademark of John Walker.
24 The licensor of Bacula is the Free Software Foundation Europe
25 (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
26 Switzerland, email:ftf@fsfeurope.org.
29 * crypto.h Encryption support functions
31 * Author: Landon Fuller <landonf@opendarwin.org>
35 * This file was contributed to the Bacula project by Landon Fuller.
37 * Landon Fuller has been granted a perpetual, worldwide, non-exclusive,
38 * no-charge, royalty-free, irrevocable copyright * license to reproduce,
39 * prepare derivative works of, publicly display, publicly perform,
40 * sublicense, and distribute the original work contributed by Landon Fuller
41 * to the Bacula project in source or object form.
43 * If you wish to license these contributions under an alternate open source
44 * license please contact Landon Fuller <landonf@opendarwin.org>.
50 /* Opaque X509 Public/Private Key Pair Structure */
51 typedef struct X509_Keypair X509_KEYPAIR;
53 /* Opaque Message Digest Structure */
54 /* Digest is defined (twice) in crypto.c */
55 typedef struct Digest DIGEST;
57 /* Opaque Message Signature Structure */
58 typedef struct Signature SIGNATURE;
60 /* Opaque PKI Symmetric Key Data Structure */
61 typedef struct Crypto_Session CRYPTO_SESSION;
63 /* Opaque Encryption/Decryption Context Structure */
64 typedef struct Cipher_Context CIPHER_CONTEXT;
66 /* PEM Decryption Passphrase Callback */
67 typedef int (CRYPTO_PEM_PASSWD_CB) (char *buf, int size, const void *userdata);
71 /* These are stored on disk and MUST NOT change */
72 CRYPTO_DIGEST_NONE = 0,
73 CRYPTO_DIGEST_MD5 = 1,
74 CRYPTO_DIGEST_SHA1 = 2,
75 CRYPTO_DIGEST_SHA256 = 3,
76 CRYPTO_DIGEST_SHA512 = 4
81 /* These are not stored on disk */
82 CRYPTO_CIPHER_AES_128_CBC,
83 CRYPTO_CIPHER_AES_192_CBC,
84 CRYPTO_CIPHER_AES_256_CBC,
85 CRYPTO_CIPHER_BLOWFISH_CBC
88 /* Crypto API Errors */
90 CRYPTO_ERROR_NONE = 0, /* No error */
91 CRYPTO_ERROR_NOSIGNER = 1, /* Signer not found */
92 CRYPTO_ERROR_NORECIPIENT = 2, /* Recipient not found */
93 CRYPTO_ERROR_INVALID_DIGEST = 3, /* Unsupported digest algorithm */
94 CRYPTO_ERROR_INVALID_CRYPTO = 4, /* Unsupported encryption algorithm */
95 CRYPTO_ERROR_BAD_SIGNATURE = 5, /* Signature is invalid */
96 CRYPTO_ERROR_DECRYPTION = 6, /* Decryption error */
97 CRYPTO_ERROR_INTERNAL = 7 /* Internal Error */
100 /* Message Digest Sizes */
101 #define CRYPTO_DIGEST_MD5_SIZE 16 /* 128 bits */
102 #define CRYPTO_DIGEST_SHA1_SIZE 20 /* 160 bits */
103 #define CRYPTO_DIGEST_SHA256_SIZE 32 /* 256 bits */
104 #define CRYPTO_DIGEST_SHA512_SIZE 64 /* 512 bits */
106 /* Maximum Message Digest Size */
109 /* Let OpenSSL define a few things */
110 #define CRYPTO_DIGEST_MAX_SIZE EVP_MAX_MD_SIZE
111 #define CRYPTO_CIPHER_MAX_BLOCK_SIZE EVP_MAX_BLOCK_LENGTH
113 #else /* HAVE_OPENSSL */
116 * This must be kept in sync with the available message digest algorithms.
117 * Just in case someone forgets, I've added assertions
118 * to crypto_digest_finalize().
123 #define CRYPTO_DIGEST_MAX_SIZE CRYPTO_DIGEST_SHA1_SIZE
125 #define CRYPTO_DIGEST_MAX_SIZE CRYPTO_DIGEST_SHA512_SIZE
129 #define CRYPTO_CIPHER_MAX_BLOCK_SIZE 0
131 #endif /* HAVE_OPENSSL */
133 #endif /* __CRYPTO_H_ */