2 * crypto.h Encryption support functions
4 * Author: Landon Fuller <landonf@opendarwin.org>
8 * Copyright (C) 2005 Kern Sibbald
10 * This file was contributed to the Bacula project by Landon Fuller.
12 * Landon Fuller has been granted a perpetual, worldwide, non-exclusive,
13 * no-charge, royalty-free, irrevocable copyright * license to reproduce,
14 * prepare derivative works of, publicly display, publicly perform,
15 * sublicense, and distribute the original work contributed by Landon Fuller
16 * to the Bacula project in source or object form.
18 * If you wish to license these contributions under an alternate open source
19 * license please contact Landon Fuller <landonf@opendarwin.org>.
22 Copyright (C) 2005 Kern Sibbald
24 This program is free software; you can redistribute it and/or
25 modify it under the terms of the GNU General Public License
26 version 2 as amended with additional clauses defined in the
27 file LICENSE in the main source directory.
29 This program is distributed in the hope that it will be useful,
30 but WITHOUT ANY WARRANTY; without even the implied warranty of
31 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32 the file LICENSE for additional details.
39 /* Opaque X509 Public/Private Key Pair Structure */
40 typedef struct X509_Keypair X509_KEYPAIR;
42 /* Opaque Message Digest Structure */
43 typedef struct Digest DIGEST;
45 /* Opaque Message Signature Structure */
46 typedef struct Signature SIGNATURE;
48 /* Opaque PKI Symmetric Key Data Structure */
49 typedef struct Crypto_Recipients CRYPTO_RECIPIENTS;
51 /* PEM Decryption Passphrase Callback */
52 typedef int (CRYPTO_PEM_PASSWD_CB) (char *buf, int size, const void *userdata);
56 /* These are stored on disk and MUST NOT change */
57 CRYPTO_DIGEST_NONE = 0,
58 CRYPTO_DIGEST_MD5 = 1,
59 CRYPTO_DIGEST_SHA1 = 2,
60 CRYPTO_DIGEST_SHA256 = 3,
61 CRYPTO_DIGEST_SHA512 = 4
66 /* These are not stored on disk */
67 CRYPTO_CIPHER_AES_128_CBC,
68 CRYPTO_CIPHER_AES_192_CBC,
69 CRYPTO_CIPHER_AES_256_CBC,
70 CRYPTO_CIPHER_BLOWFISH_CBC
73 /* Crypto API Errors */
75 CRYPTO_ERROR_NONE = 0, /* No error */
76 CRYPTO_ERROR_NOSIGNER = 1, /* Signer not found */
77 CRYPTO_ERROR_INVALID_DIGEST = 2, /* Unsupported digest algorithm */
78 CRYPTO_ERROR_BAD_SIGNATURE = 3, /* Signature is invalid */
79 CRYPTO_ERROR_INTERNAL = 4 /* Internal Error */
82 /* Message Digest Sizes */
83 #define CRYPTO_DIGEST_MD5_SIZE 16 /* 128 bits */
84 #define CRYPTO_DIGEST_SHA1_SIZE 20 /* 160 bits */
85 #define CRYPTO_DIGEST_SHA256_SIZE 32 /* 256 bits */
86 #define CRYPTO_DIGEST_SHA512_SIZE 64 /* 512 bits */
88 /* Maximum Message Digest Size */
91 /* Let OpenSSL define it */
92 #define CRYPTO_DIGEST_MAX_SIZE EVP_MAX_MD_SIZE
94 #else /* HAVE_OPENSSL */
97 * This must be kept in sync with the available message digest algorithms.
98 * Just in case someone forgets, I've added assertions
99 * to crypto_digest_finalize().
104 #define CRYPTO_DIGEST_MAX_SIZE CRYPTO_DIGEST_SHA1_SIZE
106 #define CRYPTO_DIGEST_MAX_SIZE CRYPTO_DIGEST_SHA512_SIZE
109 #endif /* HAVE_OPENSSL */
111 #endif /* __CRYPTO_H_ */