PS2SDK
PS2 Homebrew Libraries
Loading...
Searching...
No Matches
keyman.c
1#include <stdio.h>
2#include <sysclib.h>
3
4#include "secrman.h"
5
6#include "main.h"
7#include "keyman.h"
8
9#if 0
10static void _printf2(const char *format, ...);
11#endif
12
13// 0x00002a80
14#if 0
15static void _printf2(const char *format, ...){
16
17}
18#endif
19
20// 0x00002bd0
21void store_kbit(void *buffer, const void *kbit)
22{
23 const SecrKELFHeader_t *header = buffer;
24 int offset = 0x20;
25 u8 *kbit_offset;
26
27 if (header->BIT_count > 0)
28 offset += header->BIT_count * 0x10; // They used a loop for this. D:
29 if (((header->flags) & 1) != 0)
30 offset += ((unsigned char *)buffer)[offset] + 1;
31 if (((header->flags) & 0xF000) == 0)
32 offset += 8;
33
34 kbit_offset = (u8 *)buffer + offset;
35 memcpy((void *)kbit_offset, kbit, 16);
36 _printf2("kbit_offset: %p\n", kbit_offset);
37}
38
39// 0x00002d38
40void store_kc(void *buffer, const void *kc)
41{
42 const SecrKELFHeader_t *header = buffer;
43 int offset = 0x20;
44 u8 *kc_offset;
45
46 if (header->BIT_count > 0)
47 offset += header->BIT_count * 0x10; // They used a loop for this. D:
48 if (((header->flags) & 1) != 0)
49 offset += ((unsigned char *)buffer)[offset] + 1;
50 if (((header->flags) & 0xF000) == 0)
51 offset += 8;
52
53 kc_offset = (u8 *)buffer + offset + 0x10;
54 memcpy((void *)kc_offset, kc, 16);
55 _printf2("kc_offset: %p\n", kc_offset);
56}
57
58// 0x00002b20
59void get_Kbit(const void *buffer, void *Kbit)
60{
61 const SecrKELFHeader_t *header = buffer;
62 int offset = sizeof(SecrKELFHeader_t);
63 u8 *kbit_offset;
64
65 if (header->BIT_count > 0)
66 offset += header->BIT_count * sizeof(SecrBitBlockData_t); // They used a loop for this. D:
67 if (((header->flags) & 1) != 0)
68 offset += ((unsigned char *)buffer)[offset] + 1;
69 if (((header->flags) & 0xF000) == 0)
70 offset += 8;
71
72 kbit_offset = (u8 *)buffer + offset;
73 memcpy(Kbit, (void *)kbit_offset, 16);
74 _printf2("kbit_offset: %p\n", kbit_offset);
75}
76
77// 0x00002c80
78void get_Kc(const void *buffer, void *Kc)
79{
80 const SecrKELFHeader_t *header = buffer;
81 int offset = sizeof(SecrKELFHeader_t);
82 u8 *kc_offset;
83
84 if (header->BIT_count > 0)
85 offset += header->BIT_count * sizeof(SecrBitBlockData_t); // They used a loop for this. D:
86 if (((header->flags) & 1) != 0)
87 offset += ((unsigned char *)buffer)[offset] + 1;
88 if (((header->flags) & 0xF000) == 0)
89 offset += 8;
90
91 kc_offset = (u8 *)buffer + offset + 0x10; // Goes after Kbit
92 memcpy(Kc, (void *)kc_offset, 16);
93 _printf2("kc_offset: %p\n", kc_offset);
94}
95
96// 0x00002df0 - unused.
97void get_icvps2(const void *buffer, void *icvps2)
98{
99 u8 *pICVPS2;
100
101 pICVPS2 = (u8 *)buffer + ((SecrKELFHeader_t *)buffer)->KELF_header_size - 8;
102 memcpy(icvps2, (void *)pICVPS2, 8);
103 _printf2("icvps2_offset %p\n", pICVPS2);
104}
105
106// 0x00002e4c
107void store_icvps2(void *buffer, const void *icvps2)
108{
109 u8 *pICVPS2;
110
111 pICVPS2 = (u8 *)buffer + ((SecrKELFHeader_t *)buffer)->KELF_header_size - 8;
112 memcpy((void *)pICVPS2, icvps2, 8);
113 _printf2("icvps2_offset %p\n", pICVPS2);
114}
struct KELF_Header SecrKELFHeader_t
struct SecrBitBlockData SecrBitBlockData_t