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