aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/tvmauth/src/rw/keys.h
blob: b5877b767a416dbde991f49577b8511c1adb7711 (plain) (blame)
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
#pragma once 
 
#include <util/generic/ptr.h>
#include <util/generic/string.h>
 
#include <unordered_map> 
 
struct TRwInternal;
 
namespace NTvmAuth {
    namespace NRw { 
        namespace NPrivate {
            class TRwDestroyer {
            public:
                static void Destroy(TRwInternal* o);
            };
        }
 
        using TRw = THolder<TRwInternal, NPrivate::TRwDestroyer>;
        using TKeyId = ui32;

        struct TKeyPair { 
            TString Private;
            TString Public;
        }; 
        TKeyPair GenKeyPair(size_t size);
 
        class TRwPrivateKey { 
        public: 
            TRwPrivateKey(TStringBuf body, TKeyId id); 
 
            TKeyId GetId() const; 
            TString SignTicket(TStringBuf ticket) const; 
 
        private: 
            static TRw Deserialize(TStringBuf key); 
 
            TKeyId Id_;
            TRw Rw_;
            int SignLen_;
        }; 
 
        class TRwPublicKey { 
        public: 
            TRwPublicKey(TStringBuf body); 
 
            bool CheckSign(TStringBuf ticket, TStringBuf sign) const; 
 
        private: 
            static TRw Deserialize(TStringBuf key); 
 
            TRw Rw_;
        }; 
 
        using TPublicKeys = std::unordered_map<TKeyId, TRwPublicKey>; 

        class TSecureHeap {
        public:
            TSecureHeap(size_t totalSize, int minChunkSize);
            ~TSecureHeap();

            static void Init(size_t totalSize = 16 * 1024 * 1024, int minChunkSize = 16);
        };
    } 
}