3 #include <protocols/dumprestore.h>
14 #include <openssl/evp.h>
15 #include <openssl/rand.h>
16 #include <openssl/pkcs12.h>
19 #ifndef _transformation_H
20 #define _transformation_H
23 * Compression/encryption hooks.
26 * 1. should it be a failure if compress/decompress is called and we DON'T have the code included?
29 typedef struct transformation
{
34 lzo_align_t __LZO_MMODEL
*LZO_WorkMem
;
41 #endif /* HAVE_ZLIB */
46 #endif /* HAVE_ZLIB */
51 // encryption/decryption key
52 unsigned char key
[EVP_MAX_KEY_LENGTH
];
56 const EVP_CIPHER
*cipher
;
60 // this assumes we're multi-process but not multi-threaded
61 EVP_CIPHER_CTX
*dataCtx
;
62 EVP_CIPHER_CTX
*ivCtx
;
68 * The name of the compression/encryption algorithm, for
74 * Is this mandatory even if the size of the buffer increases?
75 * As a general rule compression is optional * and encryption is
81 * Initialize the system.
82 * (mode: 1 = compress/encrypt, 0 = decompress/decrypt)
84 int (*initialize
) __P((struct transformation
*xform
, int mode
));
87 * Shut down the system
89 int (*shutdown
) __P((struct transformation
*xform
));
92 * Do anything necessary after forking the process.
94 int (*startNewTape
) __P((struct transformation
*xform
,
95 struct tapebuf
*tpbin
, unsigned long *destlen
));
98 * The dump process is master-slave with the actual
99 * disk and dump tape access handled by the slave processes.
100 * This method performs any initialization required by
101 * the latter process. (E.g., some encryption libraries
102 * must be reinitialized.)
104 int (*startDiskIOProcess
) __P((struct transformation
*xform
));
107 * Clean up everything before the slave process ends.
109 int (*endDiskIOProcess
) __P((struct transformation
*xform
));
112 * Compress/encrypt buffer.
114 int (*compress
) __P((struct transformation
*xform
, struct tapebuf
*, unsigned long *destlen
,
115 const char *src
, int srclen
));
118 * Decompress/decrypt buffer.
120 int (*decompress
) __P((struct transformation
*xform
, struct tapebuf
*, unsigned long *destlen
,
121 const char *src
, int srclen
, char **reason
));
125 extern Transformation transformation_null
;
128 extern Transformation
*transformation_lzo_factory(int enc
);
129 #endif /* HAVE_ZLIB */
132 extern Transformation
*transformation_zlib_factory(int enc
, int complvl
);
133 #endif /* HAVE_ZLIB */
136 extern Transformation
*transformation_bzlib_factory(int enc
, int complvl
);
137 #endif /* HAVE_BZLIB */
140 extern Transformation
*transformation_ssl_factory(int enc
, int complvl
,
141 const char *ciphername
, const char *digestname
);
142 #endif /* HAVE_OPENSSL */
144 #endif /* _transformation_H */