vitasdk
Documentation of the vitasdk
utils.h
Go to the documentation of this file.
1 
7 #ifndef _PSP2KERN_KERNEL_UTILS_H_
8 #define _PSP2KERN_KERNEL_UTILS_H_
9 
10 #include <vitasdk/build_utils.h>
11 #include <psp2kern/types.h>
12 
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16 
17 #define SCE_SHA1_BLOCK_SIZE 64
18 #define SCE_SHA1_DIGEST_SIZE 20
19 #define SCE_SHA224_BLOCK_SIZE 64
20 #define SCE_SHA224_DIGEST_SIZE 28
21 #define SCE_SHA256_BLOCK_SIZE 64
22 #define SCE_SHA256_DIGEST_SIZE 32
23 
24 typedef struct SceSha1Context {
25  uint32_t h[5];
26  uint16_t usRemains;
27  uint16_t usComputed;
28  uint64_t ullTotalLen;
31  uint32_t pad;
34 
35 typedef struct SceSha224Context {
36  uint32_t h[8];
37  uint32_t pad;
38  uint16_t usRemains;
39  uint16_t usComputed;
40  uint64_t ullTotalLen;
43  uint32_t pad2;
46 
47 typedef struct SceSha256Context {
48  uint32_t h[8];
49  uint32_t pad;
50  uint16_t usRemains;
51  uint16_t usComputed;
52  uint64_t ullTotalLen;
57 
59 
61  uint32_t size;
62  const void *pBufEnd;
63  void *cookie;
64  const void *(* SceDeflateDecompressPartialInputCallback)(struct SceDeflatePartialInputParam* param, uint32_t outputsize);
67 
68 typedef struct SceAesContext { // size is 0x3D0(0x10 + 0x1E0 * 2)
69  uint8_t data[976];
72 
74 int ksceSha1BlockUpdate(SceSha1Context *ctx, const void *plain, SceSize len);
75 int ksceSha1BlockResult(SceSha1Context *ctx, void *result);
76 int ksceSha1Digest(const void *plain, SceSize len, void *digest);
77 
79 int ksceSha224BlockUpdate(SceSha224Context *ctx, const void *plain, SceSize len);
80 int ksceSha224BlockResult(SceSha224Context *ctx, void *result);
81 int ksceSha224Digest(const void *plain, SceSize len, void *digest);
82 
84 int ksceSha256BlockUpdate(SceSha256Context *ctx, const void *plain, SceSize len);
85 int ksceSha256BlockResult(SceSha256Context *ctx, void *result);
86 int ksceSha256Digest(const void *plain, SceSize len, void *digest);
87 
88 int ksceHmacSha1Digest(const void *key, SceSize key_len, const void *plain, SceSize len, void *digest);
89 int ksceHmacSha224Digest(const void *key, SceSize key_len, const void *plain, SceSize len, void *digest);
90 int ksceHmacSha256Digest(const void *key, SceSize key_len, const void *plain, SceSize len, void *digest);
91 
100 int ksceGzipDecompress(void *dst, SceSize dst_size, const void *src, uint32_t *crc32);
101 
109 int ksceGzipIsValid(const void *src);
110 
123 int ksceGzipGetInfo(const void *src, const void **extra, const char **name, const char **comment, unsigned short *crc, const void **data);
124 
132 const char *ksceGzipGetName(const void *src);
133 
141 const char *ksceGzipGetComment(const void *src);
142 
150 const void *ksceGzipGetCompressedData(const void *src);
151 
163 int ksceZlibGetInfo(const void *src, unsigned char *cmf, unsigned char *flg, unsigned int *dictid, const void **data);
164 
172 const void *ksceZlibGetCompressedData(const void *src);
173 
182 int ksceZlibDecompress(void *dst, SceSize dst_size, const void *src, uint32_t *adler32);
183 
192 int ksceDeflateDecompress(void *dst, SceSize dst_size, const void *src, const void **next);
193 int ksceDeflateDecompressPartial(void *dst, SceSize dst_size, const void *src, const void **next, SceDeflatePartialInputParam *cbInfo);
194 
203 int ksceAesInit1(SceAesContext *ctx, SceSize blocksize, SceSize keysize, const void *key);
204 int ksceAesInit2(SceAesContext *ctx, SceSize blocksize, SceSize keysize, const void *key);
205 int ksceAesInit3(SceAesContext *ctx, SceSize blocksize, SceSize keysize, const void *key);
206 
207 int ksceAesDecrypt1(SceAesContext *ctx, const void *src, void *dst);
208 int ksceAesDecrypt2(SceAesContext *ctx, const void *src, void *dst);
209 
210 int ksceAesEncrypt1(SceAesContext *ctx, const void *src, void *dst);
211 int ksceAesEncrypt2(SceAesContext *ctx, const void *src, void *dst);
212 
213 #ifdef __cplusplus
214 }
215 #endif
216 
217 #endif /* _PSP2KERN_KERNEL_UTILS_H_ */
struct _SceBtHidRequest * next
Definition: bt.h:8
unsigned int SceSize
Definition: types.h:56
uint32_t h[5]
Definition: utils.h:25
#define SCE_SHA224_BLOCK_SIZE
Definition: utils.h:19
char result[SCE_SHA256_DIGEST_SIZE]
Definition: utils.h:54
int ksceAesEncrypt1(SceAesContext *ctx, const void *src, void *dst)
uint32_t pad
Definition: utils.h:31
int ksceSha256BlockResult(SceSha256Context *ctx, void *result)
VITASDK_BUILD_ASSERT_EQ(0x78, SceSha1Context)
char buf[SCE_SHA224_BLOCK_SIZE]
Definition: utils.h:41
uint16_t usRemains
Definition: utils.h:50
char result[SCE_SHA1_DIGEST_SIZE]
Definition: utils.h:30
int ksceAesInit2(SceAesContext *ctx, SceSize blocksize, SceSize keysize, const void *key)
uint32_t h[8]
Definition: utils.h:36
#define SCE_SHA256_BLOCK_SIZE
Definition: utils.h:21
int ksceAesEncrypt2(SceAesContext *ctx, const void *src, void *dst)
uint16_t usComputed
Definition: utils.h:51
int ksceZlibDecompress(void *dst, SceSize dst_size, const void *src, uint32_t *adler32)
const void * ksceZlibGetCompressedData(const void *src)
Get compressed data start address.
int ksceSha256BlockUpdate(SceSha256Context *ctx, const void *plain, SceSize len)
uint16_t usRemains
Definition: utils.h:26
int ksceDeflateDecompress(void *dst, SceSize dst_size, const void *src, const void **next)
uint16_t usRemains
Definition: utils.h:38
uint32_t size
Definition: utils.h:61
uint32_t pad2
Definition: utils.h:43
uint64_t ullTotalLen
Definition: utils.h:28
#define SCE_SHA256_DIGEST_SIZE
Definition: utils.h:22
int ksceSha1BlockResult(SceSha1Context *ctx, void *result)
uint8_t data[976]
Definition: utils.h:69
int ksceSha224BlockInit(SceSha224Context *ctx)
uint64_t ullTotalLen
Definition: utils.h:40
int ksceSha256BlockInit(SceSha256Context *ctx)
char buf[SCE_SHA1_BLOCK_SIZE]
Definition: utils.h:29
int ksceGzipGetInfo(const void *src, const void **extra, const char **name, const char **comment, unsigned short *crc, const void **data)
Get filename etc.
#define SCE_SHA1_BLOCK_SIZE
Definition: utils.h:17
int ksceSha1Digest(const void *plain, SceSize len, void *digest)
uint32_t pad
Definition: utils.h:37
#define SCE_SHA1_DIGEST_SIZE
Definition: utils.h:18
int ksceGzipIsValid(const void *src)
Check magic of Gzip header.
int ksceDeflateDecompressPartial(void *dst, SceSize dst_size, const void *src, const void **next, SceDeflatePartialInputParam *cbInfo)
int ksceAesInit3(SceAesContext *ctx, SceSize blocksize, SceSize keysize, const void *key)
uint32_t pad
Definition: utils.h:49
int ksceSha224BlockUpdate(SceSha224Context *ctx, const void *plain, SceSize len)
int ksceSha1BlockUpdate(SceSha1Context *ctx, const void *plain, SceSize len)
char buf[SCE_SHA256_BLOCK_SIZE]
Definition: utils.h:53
#define SCE_SHA224_DIGEST_SIZE
Definition: utils.h:20
uint32_t h[8]
Definition: utils.h:48
int ksceAesDecrypt1(SceAesContext *ctx, const void *src, void *dst)
int ksceZlibGetInfo(const void *src, unsigned char *cmf, unsigned char *flg, unsigned int *dictid, const void **data)
Get filename etc.
const void * ksceGzipGetCompressedData(const void *src)
Get compressed data start address.
int ksceSha256Digest(const void *plain, SceSize len, void *digest)
const char * ksceGzipGetComment(const void *src)
Get comment string address.
int ksceHmacSha256Digest(const void *key, SceSize key_len, const void *plain, SceSize len, void *digest)
int ksceAesInit1(SceAesContext *ctx, SceSize blocksize, SceSize keysize, const void *key)
int ksceSha1BlockInit(SceSha1Context *ctx)
int ksceHmacSha224Digest(const void *key, SceSize key_len, const void *plain, SceSize len, void *digest)
int ksceSha224Digest(const void *plain, SceSize len, void *digest)
char result[SCE_SHA224_DIGEST_SIZE]
Definition: utils.h:42
int ksceSha224BlockResult(SceSha224Context *ctx, void *result)
void * cookie
Definition: utils.h:63
uint64_t ullTotalLen
Definition: utils.h:52
int ksceGzipDecompress(void *dst, SceSize dst_size, const void *src, uint32_t *crc32)
int ksceAesDecrypt2(SceAesContext *ctx, const void *src, void *dst)
int ksceHmacSha1Digest(const void *key, SceSize key_len, const void *plain, SceSize len, void *digest)
uint16_t usComputed
Definition: utils.h:39
uint16_t usComputed
Definition: utils.h:27
const char * ksceGzipGetName(const void *src)
Get filename string address.
const void * pBufEnd
Definition: utils.h:62
Definition: utils.h:68
Definition: utils.h:60
Definition: utils.h:24
Definition: utils.h:35
Definition: utils.h:47