]> git.stg.codes - stg.git/blob - stglibs/crypto.lib/include/stg/bfstream.h
Merge branch 'stg-2.409-radius'
[stg.git] / stglibs / crypto.lib / include / stg / bfstream.h
1 #ifndef __STG_STGLIBS_BF_STREAM_H__
2 #define __STG_STGLIBS_BF_STREAM_H__
3
4 #include <string>
5 #include <cstddef> // size_t
6
7 namespace STG
8 {
9
10 class ENCRYPT_STREAM
11 {
12     public:
13         typedef bool (* CALLBACK)(const void * block, size_t size, void * data);
14
15         ENCRYPT_STREAM(const std::string & key, CALLBACK callback, void * data);
16         ~ENCRYPT_STREAM();
17         void Put(const void * data, size_t size, bool last = false);
18
19         bool IsOk() const;
20
21     private:
22         class IMPL;
23
24         IMPL * m_impl;
25 };
26
27 class DECRYPT_STREAM
28 {
29     public:
30         typedef bool (* CALLBACK)(const void * block, size_t size, void * data);
31
32         DECRYPT_STREAM(const std::string & key, CALLBACK callback, void * data);
33         ~DECRYPT_STREAM();
34         void Put(const void * data, size_t size, bool last = false);
35
36         bool IsOk() const;
37
38     private:
39         class IMPL;
40
41         IMPL * m_impl;
42 };
43
44 } // namespace STG
45
46 #endif