-
Notifications
You must be signed in to change notification settings - Fork 0
/
ch.h
47 lines (36 loc) · 1.06 KB
/
ch.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
#ifndef __CH_H__
#define __CH_H__
#include <cstdio>
#include <string>
#include <jsoncons/json.hpp>
#include <jsoncons_ext/cbor/cbor.hpp>
class DecoderVerifier {
public:
DecoderVerifier();
~DecoderVerifier();
bool decode(const char* qrcode, size_t len);
bool getPayload(jsoncons::ojson & payload);
// return 'kid' filed of COSE, which is base64 encoded
// Example:
// DecoderVerifier dv;
// bool ret = dv.decode();
// if (ret) {
// std::string kid = dv.getKID();
// }
std::string getKID();
// set public key, which is X509 Certificate format without header and footer
bool setPublicKey(const std::string &k);
// true : verify successfully
// false : verify failed
bool verify();
enum class CertType {
UNKNOWN,
EU_DCC,
CH_LIGHT,
};
CertType getCertType();
private:
class DecoderVerifierImp;
DecoderVerifierImp* m_imp;
};
#endif