| 6 |
| #define NAGRAM_READ_CERT_H |
| 7 |
| 8 | #include <string> |
| 9 | #include <sys/syscall.h> |
| 10 | #include <unistd.h> |
| 11 | #include "log.h" |
| 12 |
| 13 | #define APK_SIGNING_BLOCK_MAGIC "APK Sig Block 42" |
| 14 | #define SIGNATURE_SCHEME_V2_MAGIC 0x7109871a |
| 15 | #define EOCD_MAGIC 0x6054b50 |
| 16 |
| 17 | struct signing_block { |
| 18 | uint64_t block_sz; |
| 19 | struct id_value_pair { |
| 20 | uint64_t len; |
| 21 | struct /* v2_signature */ { |
| 22 | uint32_t id; |
| 23 | uint8_t value[0]; // size = (len - 4) |
| 24 | }; |
| 25 | } id_value_pair_sequence[0]; |
| 26 | uint64_t block_sz_; // *MUST* be same as block_sz |
| 27 | char magic[16]; // "APK Sig Block 42" |
| 28 | }; |
| 29 |
| 30 | struct EOCD { |
| 31 | uint32_t magic; // 0x6054b50 |
| 32 | uint8_t pad[8]; // 8 bytes of irrelevant data |
| 33 | uint32_t central_dir_sz; // size of central directory |
| 34 | uint32_t central_dir_off; // offset of central directory |
| 35 | uint16_t comment_sz; // size of comment |
| 36 | char comment[0]; |
| 37 | } __attribute__((packed)); |
| 38 |
| 39 | std::string read_certificate(int fd); |
| 40 |
| 41 | bool more_check(int fd, const char* path); |
| 42 |
| 43 | #endif //NAGRAM_READ_CERT_H |
| 44 |