-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathsoft_token.h
67 lines (39 loc) · 1.65 KB
/
soft_token.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#ifndef ST_SOFT_TOKEN_H
#define ST_SOFT_TOKEN_H
#include "types.h"
#include <boost/iterator/filter_iterator.hpp>
typedef std::vector<CK_OBJECT_HANDLE> Handles;
typedef std::function<CK_OBJECT_HANDLE()> handle_iterator_t;
typedef std::map<CK_ATTRIBUTE_TYPE, attribute_t> Attributes;
typedef std::map<CK_OBJECT_HANDLE, Attributes> Objects;
typedef std::function<bool(const Objects::value_type&)> ObjectsPred;
typedef boost::filter_iterator<ObjectsPred, Objects::iterator> ObjectsIterator;
class soft_token_t {
public:
soft_token_t(const std::string& rcfile);
~soft_token_t();
bool ssh_agent() const;
bool ready() const;
bool logged() const;
bool login(const std::string& pin);
void logout();
std::string full_name() const;
Handles handles() const;
ObjectsIterator begin();
ObjectsIterator begin(Attributes attrs);
ObjectsIterator end();
static CK_OBJECT_HANDLE handle_invalid();
Attributes attributes(CK_OBJECT_HANDLE id) const;
bool has_object(CK_OBJECT_HANDLE id) const;
bool check(CK_OBJECT_HANDLE id, const Attributes& attrs) const;
std::string read(CK_OBJECT_HANDLE id);
CK_OBJECT_HANDLE write(const std::string& filename, const std::vector<unsigned char>& data, const Attributes& attrs = Attributes());
std::vector<unsigned char> sign(CK_OBJECT_HANDLE id, CK_MECHANISM_TYPE type, CK_BYTE_PTR pData, CK_ULONG ulDataLen);
std::vector<unsigned char> create_key(CK_OBJECT_CLASS klass, const Attributes& attrs) const;
private:
void check_storage();
void reset();
struct Pimpl;
std::auto_ptr<Pimpl> p_;
};
#endif