1 /*---------------------------------------------------------------------------* 2 Project: TwlSDK - OS - include 3 File: systemCall.h 4 5 Copyright 2007-2008 Nintendo. All rights reserved. 6 7 These coded instructions, statements, and computer programs contain 8 proprietary information of Nintendo of America Inc. and/or Nintendo 9 Company Ltd., and are protected by Federal copyright law. They may 10 not be disclosed to third parties or copied or duplicated in any form, 11 in whole or in part, without the prior written consent of Nintendo. 12 13 $Log: $ 14 $NoKeywords: $ 15 *---------------------------------------------------------------------------*/ 16 17 #ifndef TWL_OS_SYSTEMCALL_H_ 18 #define TWL_OS_SYSTEMCALL_H_ 19 20 #define SVC_SHA1_DIGEST_SIZE 20 21 #define SVC_SHA1_BLOCK_SIZE 64 22 #define SVC_RSA1024_BLOCK_SIZE 128 23 24 #ifdef __cplusplus 25 extern "C" { 26 #endif 27 28 typedef struct 29 { 30 u32* head; 31 u32* tail; 32 u32 size; 33 } 34 SVCSignHeapContext; 35 36 typedef struct SVCSHA1Context 37 { 38 u32 h0,h1,h2,h3,h4; 39 u32 Nl,Nh; 40 u32 data[16]; 41 int num; 42 void (*sha_block)(struct SVCSHA1Context *c, const u8 *W, int num); 43 } 44 SVCSHA1Context; 45 46 typedef struct SVCHMACSHA1Context 47 { 48 SVCSHA1Context sha1_ctx; 49 u8 key[SVC_SHA1_BLOCK_SIZE]; 50 u32 keylen; 51 } 52 SVCHMACSHA1Context; 53 54 typedef struct 55 { 56 void* output; 57 const void* input; 58 const void* key; 59 } 60 SVCSignBuffers; 61 62 63 void SVC_InitSignHeap( 64 SVCSignHeapContext* acmemory_pool, 65 void* heap, 66 u32 len 67 ); 68 69 int SVC_DecryptRSA( 70 const SVCSignHeapContext* acmemory_pool, 71 const SVCSignBuffers* pData, 72 u32* len // Output size 73 ); 74 75 int SVC_DecryptSign( 76 const SVCSignHeapContext* acmemory_pool, 77 void* buffer, // Output domain 78 const void* sgn_ptr, // Pointer to data 79 const void* key_ptr // Pointer to key 80 ); 81 82 int SVC_DecryptSignDER( 83 const SVCSignHeapContext* acmemory_pool, 84 void* buffer, // Output domain 85 const void* sgn_ptr, // Pointer to data 86 const void* key_ptr // Pointer to key 87 ); 88 89 void SVC_SHA1Init( SVCSHA1Context *ctx ); 90 void SVC_SHA1Update( SVCSHA1Context *ctx, const void *data, u32 len ); 91 void SVC_SHA1GetHash( SVCSHA1Context *ctx, void *md ); 92 93 void SVC_CalcSHA1( 94 void* md, // Output domain 95 const void* data, // Pointer to data 96 u32 len // Data length 97 ); 98 99 int SVC_CompareSHA1( 100 const void* decedHash, // SVC_Decrypto* output 101 const void* digest // SVC_GetDigest output 102 ); 103 104 int SVC_RandomSHA1( 105 void* dest_ptr, // Pointer to the output data 106 u32 dest_len, // Output data length 107 const void* src_ptr, // Pointer to the input data 108 u32 src_len // Input data length 109 ); 110 111 s32 SVC_UncompressLZ8FromDevice( const void* srcp, 112 void* destp, 113 const void* paramp, 114 const MIReadStreamCallbacks *callbacks 115 ); 116 117 void SVC_HMACSHA1Init( SVCHMACSHA1Context *ctx, const void *key, u32 keylen ); 118 void SVC_HMACSHA1Update( SVCHMACSHA1Context *ctx, const void *data, u32 len ); 119 void SVC_HMACSHA1GetHash( SVCHMACSHA1Context *ctx, void* md ); 120 void SVC_CalcHMACSHA1( void* md, const void* data, u32 len, const void* key, u32 keylen ); 121 122 123 #ifdef __cplusplus 124 } /* extern "C" */ 125 #endif 126 127 /* TWL_OS_SYSTEMCALL_H_ */ 128 #endif 129