1 #pragma once
2 
3 #include <memory>
4 #include <vector>
5 
6 #include <android-base/result.h>
7 
8 namespace hwtrust {
9 
10 // Hide the details of the rust binding from clients with an opaque type.
11 struct BoxedDiceChain;
12 
13 class DiceChain final {
14 public:
15   enum class Kind {
16     kVsr13,
17     kVsr14,
18     kVsr15,
19     kVsr16,
20   };
21 
22   static android::base::Result<DiceChain> Verify(const std::vector<uint8_t>& chain, DiceChain::Kind kind) noexcept;
23 
24   ~DiceChain();
25   DiceChain(DiceChain&&) = default;
26 
27   android::base::Result<std::vector<std::vector<uint8_t>>> CosePublicKeys() const noexcept;
28 
29   bool IsProper() const noexcept;
30 
31 private:
32   DiceChain(std::unique_ptr<BoxedDiceChain> chain, size_t size) noexcept;
33 
34   std::unique_ptr<BoxedDiceChain> chain_;
35   size_t size_;
36 };
37 
38 } // namespace hwtrust
39